* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
-#undef GTK_DISABLE_DEPRECATED
-#include <config.h>
+#include "config.h"
#include <gtk/gtk.h>
static GtkActionGroup *action_group = NULL;
gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action)));
}
+static void
+recent_action (GtkAction *action)
+{
+ const gchar *name = gtk_action_get_name (action);
+ const gchar *typename = G_OBJECT_TYPE_NAME (action);
+ gchar *uri = gtk_recent_chooser_get_current_uri (GTK_RECENT_CHOOSER (action));
+
+ g_message ("Action %s (type=%s) activated (uri=%s)",
+ name, typename,
+ uri ? uri : "no item selected");
+ g_free (uri);
+}
+
static void
toggle_cnp_actions (GtkAction *action)
{
}
static void
-toolbar_style (GtkAction *action,
- gpointer user_data)
+toolbar_style (GtkAction *action)
{
GtkToolbarStyle style;
g_return_if_fail (toolbar != NULL);
- style = GPOINTER_TO_INT (user_data);
+
+ radio_action (action);
+
+ style = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
gtk_toolbar_set_style (toolbar, style);
}
{ "Menu2Action", NULL, "Menu _2" },
{ "Menu3Action", NULL, "_Dynamic Menu" },
+ { "attach", "mail-attachment", "_Attachment...", "<Control>m",
+ "Attach a file", G_CALLBACK (activate_action) },
{ "cut", GTK_STOCK_CUT, "C_ut", "<control>X",
"Cut the selected text to the clipboard", G_CALLBACK (activate_action) },
{ "copy", GTK_STOCK_COPY, "_Copy", "<control>C",
" <menuitem name=\"bold1\" action=\"bold\" />\n"
" <menuitem name=\"bold2\" action=\"bold\" />\n"
" <separator name=\"sep2\" />\n"
-" <menuitem name=\"toggle-cnp\" action=\"toggle-cnp\" />\n"
+" <menuitem name=\"recent\" action=\"recent\" />\n"
" <separator name=\"sep3\" />\n"
+" <menuitem name=\"toggle-cnp\" action=\"toggle-cnp\" />\n"
+" <separator name=\"sep4\" />\n"
" <menuitem name=\"quit\" action=\"quit\" />\n"
" </menu>\n"
" <menu name=\"Menu _2\" action=\"Menu2Action\">\n"
" <menuitem name=\"cut\" action=\"cut\" />\n"
" <menuitem name=\"copy\" action=\"copy\" />\n"
" <menuitem name=\"paste\" action=\"paste\" />\n"
-" <separator name=\"sep4\"/>\n"
-" <menuitem name=\"bold\" action=\"bold\" />\n"
" <separator name=\"sep5\"/>\n"
+" <menuitem name=\"bold\" action=\"bold\" />\n"
+" <separator name=\"sep6\"/>\n"
" <menuitem name=\"justify-left\" action=\"justify-left\" />\n"
" <menuitem name=\"justify-center\" action=\"justify-center\" />\n"
" <menuitem name=\"justify-right\" action=\"justify-right\" />\n"
" <menuitem name=\"justify-fill\" action=\"justify-fill\" />\n"
-" <separator name=\"sep6\"/>\n"
-" <menuitem name=\"customise-accels\" action=\"customise-accels\" />\n"
" <separator name=\"sep7\"/>\n"
+" <menuitem name=\"customise-accels\" action=\"customise-accels\" />\n"
+" <separator name=\"sep8\"/>\n"
" <menuitem action=\"toolbar-icons\" />\n"
" <menuitem action=\"toolbar-text\" />\n"
" <menuitem action=\"toolbar-both\" />\n"
" <menuitem action=\"toolbar-both-horiz\" />\n"
-" <separator name=\"sep8\"/>\n"
+" <separator name=\"sep9\"/>\n"
" <menuitem action=\"toolbar-small-icons\" />\n"
" <menuitem action=\"toolbar-large-icons\" />\n"
" </menu>\n"
- " <menu name=\"DynamicMenu\" action=\"Menu3Action\" />\n"
+" <menu name=\"DynamicMenu\" action=\"Menu3Action\" />\n"
" </menubar>\n"
" <toolbar name=\"toolbar\">\n"
+" <toolitem name=\"attach\" action=\"attach\" />\n"
" <toolitem name=\"cut\" action=\"cut\" />\n"
" <toolitem name=\"copy\" action=\"copy\" />\n"
" <toolitem name=\"paste\" action=\"paste\" />\n"
-" <separator name=\"sep9\" />\n"
-" <toolitem name=\"bold\" action=\"bold\" />\n"
+" <toolitem name=\"recent\" action=\"recent\" />\n"
" <separator name=\"sep10\" />\n"
+" <toolitem name=\"bold\" action=\"bold\" />\n"
+" <separator name=\"sep11\" />\n"
" <toolitem name=\"justify-left\" action=\"justify-left\" />\n"
" <toolitem name=\"justify-center\" action=\"justify-center\" />\n"
" <toolitem name=\"justify-right\" action=\"justify-right\" />\n"
" <toolitem name=\"justify-fill\" action=\"justify-fill\" />\n"
-" <separator name=\"sep11\"/>\n"
+" <separator name=\"sep12\"/>\n"
" <toolitem name=\"quit\" action=\"quit\" />\n"
" </toolbar>\n"
" <popup name=\"popup\">\n"
g_signal_connect_swapped (window, "destroy", G_CALLBACK (g_object_unref), merge);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
- box = gtk_vbox_new (FALSE, 0);
+ box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), box);
gtk_widget_show (box);
g_error_free (error);
}
- hbox = gtk_hbox_new (FALSE, 0);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_end (GTK_BOX (box), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
int
main (int argc, char **argv)
{
+ GtkAction *action;
+
gtk_init (&argc, &argv);
if (g_file_test ("accels", G_FILE_TEST_IS_REGULAR))
gtk_accel_map_load ("accels");
+ action = gtk_recent_action_new ("recent",
+ "Open Recent", "Open recent files",
+ NULL);
+ g_signal_connect (action, "item-activated",
+ G_CALLBACK (recent_action),
+ NULL);
+ g_signal_connect (action, "activate",
+ G_CALLBACK (recent_action),
+ NULL);
+
action_group = gtk_action_group_new ("TestActions");
gtk_action_group_add_actions (action_group,
entries, n_entries,
gtk_action_group_add_radio_actions (action_group,
toolbar_entries, n_toolbar_entries,
GTK_TOOLBAR_BOTH,
- G_CALLBACK (radio_action), NULL);
+ G_CALLBACK (toolbar_style), NULL);
+ gtk_action_group_add_action_with_accel (action_group, action, NULL);
create_window (action_group);
}
}
#endif
-
+
+ g_object_unref (action);
g_object_unref (action_group);
gtk_accel_map_save ("accels");