-#include <config.h>
+/* testmerge.c
+ * Copyright (C) 2003 James Henstridge
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+
+#define GDK_DISABLE_DEPRECATION_WARNINGS
+
#include <gtk/gtk.h>
#ifndef STDOUT_FILENO
gchar *dump;
dump = gtk_ui_manager_get_ui (merge);
- g_message (dump);
+ g_message ("%s", dump);
g_free (dump);
}
GTK_UI_MANAGER_TOOLBAR |
GTK_UI_MANAGER_POPUP);
- g_slist_foreach (toplevels, (GFunc)print_toplevel, NULL);
+ g_slist_foreach (toplevels, (GFunc) print_toplevel, NULL);
g_slist_free (toplevels);
}
gtk_ui_manager_set_add_tearoffs (merge, !add_tearoffs);
}
-static void
-toggle_dynamic (GtkWidget *button,
- GtkUIManager *merge)
+static gint
+delayed_toggle_dynamic (GtkUIManager *merge)
{
GtkAction *dyn;
static GtkActionGroup *dynamic = NULL;
"dyn1menu", "dyn1", GTK_UI_MANAGER_MENU, 0);
gtk_ui_manager_add_ui (merge, merge_id, "/menubar/EditMenu/dyn1menu",
"dyn1", "dyn1", GTK_UI_MANAGER_MENUITEM, 0);
- gtk_ui_manager_add_ui (merge, merge_id, "/menubar/EditMenu/dyn1menu",
- "dyn2", "dyn2", GTK_UI_MANAGER_AUTO, TRUE);
+ gtk_ui_manager_add_ui (merge, merge_id, "/menubar/EditMenu/dyn1menu/dyn1",
+ "dyn2", "dyn2", GTK_UI_MANAGER_AUTO, FALSE);
}
else
{
gtk_ui_manager_remove_ui (merge, merge_id);
merge_id = 0;
}
+
+ return FALSE;
}
+static void
+toggle_dynamic (GtkWidget *button,
+ GtkUIManager *merge)
+{
+ gdk_threads_add_timeout (2000, (GSourceFunc)delayed_toggle_dynamic, merge);
+}
static void
activate_action (GtkAction *action)
static GtkRadioActionEntry radio_entries[] = {
{ "justify-left", GTK_STOCK_JUSTIFY_LEFT, NULL, "<control>L",
"Left justify the text", JUSTIFY_LEFT },
- { "justify-center", GTK_STOCK_JUSTIFY_CENTER, NULL, "<control>E",
+ { "justify-center", GTK_STOCK_JUSTIFY_CENTER, NULL, "<super>E",
"Center justify the text", JUSTIFY_CENTER },
- { "justify-right", GTK_STOCK_JUSTIFY_RIGHT, NULL, "<control>R",
+ { "justify-right", GTK_STOCK_JUSTIFY_RIGHT, NULL, "<hyper>R",
"Right justify the text", JUSTIFY_RIGHT },
- { "justify-fill", GTK_STOCK_JUSTIFY_FILL, NULL, "<control>J",
+ { "justify-fill", GTK_STOCK_JUSTIFY_FILL, NULL, "<super><hyper>J",
"Fill justify the text", JUSTIFY_FILL },
};
static guint n_radio_entries = G_N_ELEMENTS (radio_entries);
GtkWidget *widget,
GtkBox *box)
{
- GtkWidget *handle_box;
-
- if (GTK_IS_TOOLBAR (widget))
- {
- handle_box = gtk_handle_box_new ();
- gtk_widget_show (handle_box);
- gtk_container_add (GTK_CONTAINER (handle_box), widget);
- gtk_box_pack_start (box, handle_box, FALSE, FALSE, 0);
- g_signal_connect_swapped (widget, "destroy",
- G_CALLBACK (gtk_widget_destroy), handle_box);
- }
- else
- gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
-
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
gtk_widget_show (widget);
}
"could not merge %s: %s", merge_ids[mergenum].filename,
err->message);
- g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (gtk_object_destroy), NULL);
+ g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (dialog);
g_clear_error (&err);
char *name;
gtk_tree_model_get (tree_model, iter, 0, &action, -1);
- g_object_get (G_OBJECT (action), "name", &name, NULL);
- g_object_set (G_OBJECT (cell), "text", name, NULL);
+ g_object_get (action, "name", &name, NULL);
+ g_object_set (cell, "text", name, NULL);
g_free (name);
g_object_unref (action);
}
gboolean sensitive;
gtk_tree_model_get (tree_model, iter, 0, &action, -1);
- g_object_get (G_OBJECT (action), "sensitive", &sensitive, NULL);
- g_object_set (G_OBJECT (cell), "active", sensitive, NULL);
+ g_object_get (action, "sensitive", &sensitive, NULL);
+ g_object_set (cell, "active", sensitive, NULL);
g_object_unref (action);
}
gboolean visible;
gtk_tree_model_get (tree_model, iter, 0, &action, -1);
- g_object_get (G_OBJECT (action), "visible", &visible, NULL);
- g_object_set (G_OBJECT (cell), "active", visible, NULL);
+ g_object_get (action, "visible", &visible, NULL);
+ g_object_set (cell, "active", visible, NULL);
g_object_unref (action);
}
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, 0, &action, -1);
- g_object_get (G_OBJECT (action), "sensitive", &sensitive, NULL);
- g_object_set (G_OBJECT (action), "sensitive", !sensitive, NULL);
+ g_object_get (action, "sensitive", &sensitive, NULL);
+ g_object_set (action, "sensitive", !sensitive, NULL);
gtk_tree_model_row_changed (model, path, &iter);
gtk_tree_path_free (path);
}
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, 0, &action, -1);
- g_object_get (G_OBJECT (action), "visible", &visible, NULL);
- g_object_set (G_OBJECT (action), "visible", !visible, NULL);
+ g_object_get (action, "visible", &visible, NULL);
+ g_object_set (action, "visible", !visible, NULL);
gtk_tree_model_row_changed (model, path, &iter);
gtk_tree_path_free (path);
}
GtkTreeIter *b,
gpointer user_data)
{
- GValue a_value = { 0, }, b_value = { 0, };
+ GValue a_value = G_VALUE_INIT, b_value = G_VALUE_INIT;
GtkAction *a_action, *b_action;
const gchar *a_name, *b_name;
gint retval = 0;
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, l->data, -1);
}
+
+ g_list_free (actions);
}
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
{
gtk_widget_grab_focus (drawing_area);
- if (event->button == 3 &&
+ if (gdk_event_triggers_context_menu ((GdkEvent *) event) &&
event->type == GDK_BUTTON_PRESS)
{
GtkWidget *menu = gtk_ui_manager_get_widget (merge, "/FileMenu");
if (data)
{
- g_object_get (G_OBJECT (data->action), "tooltip", &tooltip, NULL);
+ g_object_get (data->action, "tooltip", &tooltip, NULL);
gtk_statusbar_push (GTK_STATUSBAR (data->statusbar), 0,
tooltip ? tooltip : "");
g_object_set_data_full (G_OBJECT (proxy), "action-status",
data, action_status_destroy);
- g_signal_connect (proxy, "select", G_CALLBACK (set_tip), 0);
- g_signal_connect (proxy, "deselect", G_CALLBACK (unset_tip), 0);
+ g_signal_connect (proxy, "select", G_CALLBACK (set_tip), NULL);
+ g_signal_connect (proxy, "deselect", G_CALLBACK (unset_tip), NULL);
}
}
}
GtkActionGroup *action_group;
GtkAction *action;
GtkUIManager *merge;
- GtkWidget *window, *table, *frame, *menu_box, *vbox, *view;
+ GtkWidget *window, *grid, *frame, *menu_box, *vbox, *view;
GtkWidget *button, *area, *statusbar;
+ GtkWidget *box;
gint i;
gtk_init (&argc, &argv);
entries, n_entries,
NULL);
action = gtk_action_group_get_action (action_group, "EmptyMenu1Action");
- g_object_set (G_OBJECT (action), "hide_if_empty", FALSE, NULL);
+ g_object_set (action, "hide_if_empty", FALSE, NULL);
action = gtk_action_group_get_action (action_group, "EmptyMenu2Action");
- g_object_set (G_OBJECT (action), "hide_if_empty", TRUE, NULL);
+ g_object_set (action, "hide_if_empty", TRUE, NULL);
gtk_action_group_add_toggle_actions (action_group,
toggle_entries, n_toggle_entries,
NULL);
gtk_window_set_default_size (GTK_WINDOW (window), -1, 400);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
- table = gtk_table_new (2, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 2);
- gtk_table_set_col_spacings (GTK_TABLE (table), 2);
- gtk_container_set_border_width (GTK_CONTAINER (table), 2);
- gtk_container_add (GTK_CONTAINER (window), table);
+ grid = gtk_grid_new ();
+ gtk_grid_set_row_spacing (GTK_GRID (grid), 2);
+ gtk_grid_set_column_spacing (GTK_GRID (grid), 2);
+ gtk_container_set_border_width (GTK_CONTAINER (grid), 2);
+ gtk_container_add (GTK_CONTAINER (window), grid);
frame = gtk_frame_new ("Menus and Toolbars");
- gtk_table_attach (GTK_TABLE (table), frame, 0,2, 1,2,
- GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
+ gtk_grid_attach (GTK_GRID (grid), frame, 0, 1, 2, 1);
- menu_box = gtk_vbox_new (FALSE, 0);
+ menu_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_set_border_width (GTK_CONTAINER (menu_box), 2);
gtk_container_add (GTK_CONTAINER (frame), menu_box);
button = gtk_button_new ();
gtk_box_pack_end (GTK_BOX (menu_box), button, FALSE, FALSE, 0);
- gtk_action_connect_proxy (gtk_action_group_get_action (action_group, "AboutAction"),
- button);
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (button),
+ gtk_action_group_get_action (action_group, "AboutAction"));
+
gtk_widget_show (button);
button = gtk_check_button_new ();
gtk_box_pack_end (GTK_BOX (menu_box), button, FALSE, FALSE, 0);
- gtk_action_connect_proxy (gtk_action_group_get_action (action_group, "BoldAction"),
- button);
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (button),
+ gtk_action_group_get_action (action_group, "BoldAction"));
gtk_widget_show (button);
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_box_pack_end (GTK_BOX (menu_box), box, FALSE, FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (box), gtk_label_new ("Bold:"));
+ button = gtk_switch_new ();
+ gtk_container_add (GTK_CONTAINER (box), button);
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (button),
+ gtk_action_group_get_action (action_group, "BoldAction"));
+ gtk_widget_show_all (box);
+
merge = gtk_ui_manager_new ();
g_signal_connect (merge, "connect-proxy", G_CALLBACK (connect_proxy), statusbar);
gtk_ui_manager_get_accel_group (merge));
frame = gtk_frame_new ("UI Files");
- gtk_table_attach (GTK_TABLE (table), frame, 0,1, 0,1,
- GTK_FILL, GTK_FILL|GTK_EXPAND, 0, 0);
+ gtk_widget_set_vexpand (frame, TRUE);
+ gtk_grid_attach (GTK_GRID (grid), frame, 0, 0, 1, 1);
- vbox = gtk_vbox_new (FALSE, 2);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
view = create_tree_view (merge);
- gtk_table_attach (GTK_TABLE (table), view, 1,2, 0,1,
- GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
+ gtk_widget_set_hexpand (view, TRUE);
+ gtk_widget_set_vexpand (view, TRUE);
+ gtk_grid_attach (GTK_GRID (grid), view, 1, 0, 1, 1);
gtk_widget_show_all (window);
gtk_main ();
- g_object_unref (action_group);
+#ifdef DEBUG_UI_MANAGER
+ {
+ GList *action;
+
+ g_print ("\n> before unreffing the ui manager <\n");
+ for (action = gtk_action_group_list_actions (action_group);
+ action;
+ action = action->next)
+ {
+ GtkAction *a = action->data;
+ g_print (" action %s ref count %d\n",
+ gtk_action_get_name (a), G_OBJECT (a)->ref_count);
+ }
+ }
+#endif
+
g_object_unref (merge);
+#ifdef DEBUG_UI_MANAGER
+ {
+ GList *action;
+
+ g_print ("\n> after unreffing the ui manager <\n");
+ for (action = gtk_action_group_list_actions (action_group);
+ action;
+ action = action->next)
+ {
+ GtkAction *a = action->data;
+ g_print (" action %s ref count %d\n",
+ gtk_action_get_name (a), G_OBJECT (a)->ref_count);
+ }
+ }
+#endif
+
+ g_object_unref (action_group);
+
return 0;
}