Remove deprecated Gtk+ symbols
This patch removes all uses of deprecated Gtk+ symbols from mutter. https://bugzilla.gnome.org/show_bug.cgi?id=587991
This commit is contained in:
parent
7a04673dd7
commit
42e786b15b
@ -309,17 +309,15 @@ response_cb (GtkDialog *dialog,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dialog_cb (gpointer callback_data,
|
dialog_cb (GtkAction *action,
|
||||||
guint callback_action,
|
gpointer callback_data)
|
||||||
GtkWidget *widget)
|
|
||||||
{
|
{
|
||||||
make_dialog (GTK_WIDGET (callback_data), 1);
|
make_dialog (GTK_WIDGET (callback_data), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
modal_dialog_cb (gpointer callback_data,
|
modal_dialog_cb (GtkAction *action,
|
||||||
guint callback_action,
|
gpointer callback_data)
|
||||||
GtkWidget *widget)
|
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
|
|
||||||
@ -337,17 +335,15 @@ modal_dialog_cb (gpointer callback_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
no_parent_dialog_cb (gpointer callback_data,
|
no_parent_dialog_cb (GtkAction *action,
|
||||||
guint callback_action,
|
gpointer callback_data)
|
||||||
GtkWidget *widget)
|
|
||||||
{
|
{
|
||||||
make_dialog (NULL, 1);
|
make_dialog (NULL, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
utility_cb (gpointer callback_data,
|
utility_cb (GtkAction *action,
|
||||||
guint callback_action,
|
gpointer callback_data)
|
||||||
GtkWidget *widget)
|
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
@ -379,9 +375,8 @@ utility_cb (gpointer callback_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
toolbar_cb (gpointer callback_data,
|
toolbar_cb (GtkAction *action,
|
||||||
guint callback_action,
|
gpointer callback_data)
|
||||||
GtkWidget *widget)
|
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
@ -404,9 +399,8 @@ toolbar_cb (gpointer callback_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
menu_cb (gpointer callback_data,
|
menu_cb (GtkAction *action,
|
||||||
guint callback_action,
|
gpointer callback_data)
|
||||||
GtkWidget *widget)
|
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
@ -429,9 +423,8 @@ menu_cb (gpointer callback_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
override_redirect_cb (gpointer callback_data,
|
override_redirect_cb (GtkAction *action,
|
||||||
guint callback_action,
|
gpointer callback_data)
|
||||||
GtkWidget *widget)
|
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
@ -451,9 +444,8 @@ override_redirect_cb (gpointer callback_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
border_only_cb (gpointer callback_data,
|
border_only_cb (GtkAction *action,
|
||||||
guint callback_action,
|
gpointer callback_data)
|
||||||
GtkWidget *widget)
|
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
@ -477,9 +469,8 @@ border_only_cb (gpointer callback_data,
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static void
|
static void
|
||||||
changing_icon_cb (gpointer callback_data,
|
changing_icon_cb (GtkAction *action,
|
||||||
guint callback_action,
|
gpointer callback_data)
|
||||||
GtkWidget *widget)
|
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
@ -545,9 +536,8 @@ focus_label (GtkWidget *window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
splashscreen_cb (gpointer callback_data,
|
splashscreen_cb (GtkAction *action,
|
||||||
guint callback_action,
|
gpointer callback_data)
|
||||||
GtkWidget *widget)
|
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
GtkWidget *image;
|
GtkWidget *image;
|
||||||
@ -654,10 +644,27 @@ make_dock (int type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dock_cb (gpointer callback_data,
|
dock_cb (GtkAction *action,
|
||||||
guint callback_action,
|
gpointer callback_data)
|
||||||
GtkWidget *widget)
|
|
||||||
{
|
{
|
||||||
|
guint callback_action;
|
||||||
|
const gchar *name;
|
||||||
|
|
||||||
|
name = gtk_action_get_name (action);
|
||||||
|
|
||||||
|
if (!g_strcmp0 (name, "Top dock"))
|
||||||
|
callback_action = DOCK_TOP;
|
||||||
|
else if (!g_strcmp0 (name, "Bottom dock"))
|
||||||
|
callback_action = DOCK_BOTTOM;
|
||||||
|
else if (!g_strcmp0 (name, "Left dock"))
|
||||||
|
callback_action = DOCK_LEFT;
|
||||||
|
else if (!g_strcmp0 (name, "Right dock"))
|
||||||
|
callback_action = DOCK_RIGHT;
|
||||||
|
else if (!g_strcmp0 (name, "All docks"))
|
||||||
|
callback_action = DOCK_ALL;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
if (callback_action == DOCK_ALL)
|
if (callback_action == DOCK_ALL)
|
||||||
{
|
{
|
||||||
make_dock (DOCK_TOP);
|
make_dock (DOCK_TOP);
|
||||||
@ -672,9 +679,8 @@ dock_cb (gpointer callback_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
desktop_cb (gpointer callback_data,
|
desktop_cb (GtkAction *action,
|
||||||
guint callback_action,
|
gpointer callback_data)
|
||||||
GtkWidget *widget)
|
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
@ -700,40 +706,20 @@ desktop_cb (gpointer callback_data,
|
|||||||
gtk_widget_show_all (window);
|
gtk_widget_show_all (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkItemFactoryEntry menu_items[] =
|
|
||||||
{
|
|
||||||
{ "/_Windows", NULL, NULL, 0, "<Branch>" },
|
|
||||||
{ "/Windows/tearoff", NULL, NULL, 0, "<Tearoff>" },
|
|
||||||
{ "/Windows/_Dialog", "<control>d", dialog_cb, 0, NULL },
|
|
||||||
{ "/Windows/_Modal dialog", NULL, modal_dialog_cb, 0, NULL },
|
|
||||||
{ "/Windows/_Parentless dialog", NULL, no_parent_dialog_cb, 0, NULL },
|
|
||||||
{ "/Windows/_Utility", "<control>u", utility_cb, 0, NULL },
|
|
||||||
{ "/Windows/_Splashscreen", "<control>s", splashscreen_cb, 0, NULL },
|
|
||||||
{ "/Windows/_Top dock", NULL, dock_cb, DOCK_TOP, NULL },
|
|
||||||
{ "/Windows/_Bottom dock", NULL, dock_cb, DOCK_BOTTOM, NULL },
|
|
||||||
{ "/Windows/_Left dock", NULL, dock_cb, DOCK_LEFT, NULL },
|
|
||||||
{ "/Windows/_Right dock", NULL, dock_cb, DOCK_RIGHT, NULL },
|
|
||||||
{ "/Windows/_All docks", NULL, dock_cb, DOCK_ALL, NULL },
|
|
||||||
{ "/Windows/Des_ktop", NULL, desktop_cb, 0, NULL },
|
|
||||||
{ "/Windows/Me_nu", NULL, menu_cb, 0, NULL },
|
|
||||||
{ "/Windows/Tool_bar", NULL, toolbar_cb, 0, NULL },
|
|
||||||
{ "/Windows/Override Redirect", NULL, override_redirect_cb, 0, NULL },
|
|
||||||
{ "/Windows/Border Only", NULL, border_only_cb, 0, NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sleep_cb (GtkWidget *button,
|
sleep_cb (GtkAction *action,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
sleep (1000);
|
sleep (1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
toggle_aspect_ratio (GtkWidget *button,
|
toggle_aspect_ratio (GtkAction *action,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
GdkGeometry geom;
|
GdkGeometry geom;
|
||||||
|
GtkWidget *widget = GTK_WIDGET (data);
|
||||||
|
|
||||||
if (aspect_on)
|
if (aspect_on)
|
||||||
{
|
{
|
||||||
@ -748,10 +734,10 @@ toggle_aspect_ratio (GtkWidget *button,
|
|||||||
|
|
||||||
aspect_on = !aspect_on;
|
aspect_on = !aspect_on;
|
||||||
|
|
||||||
window = gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW);
|
window = gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW);
|
||||||
if (window)
|
if (window)
|
||||||
gtk_window_set_geometry_hints (GTK_WINDOW (window),
|
gtk_window_set_geometry_hints (GTK_WINDOW (window),
|
||||||
GTK_WIDGET (data),
|
widget,
|
||||||
&geom,
|
&geom,
|
||||||
GDK_HINT_ASPECT);
|
GDK_HINT_ASPECT);
|
||||||
|
|
||||||
@ -762,7 +748,7 @@ toggle_decorated_cb (GtkWidget *button,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
window = gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW);
|
window = gtk_widget_get_ancestor (data, GTK_TYPE_WINDOW);
|
||||||
if (window)
|
if (window)
|
||||||
gtk_window_set_decorated (GTK_WINDOW (window),
|
gtk_window_set_decorated (GTK_WINDOW (window),
|
||||||
!gtk_window_get_decorated (GTK_WINDOW (window)));
|
!gtk_window_get_decorated (GTK_WINDOW (window)));
|
||||||
@ -836,39 +822,102 @@ destroy_cb (GtkWidget *w, gpointer data)
|
|||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static const gchar *menu_item_string =
|
||||||
insert_stock_button (GtkWidget *toolbar,
|
"<ui>\n"
|
||||||
const gchar *stock_id,
|
"<menubar>\n"
|
||||||
const gchar *text,
|
"<menu name='Windows' action='Windows'>\n"
|
||||||
GCallback callback,
|
"<menuitem name='Dialog' action='Dialog'/>\n"
|
||||||
gpointer user_data)
|
"<menuitem name='Modal dialog' action='Modal dialog'/>\n"
|
||||||
{
|
"<menuitem name='Parentless dialog' action='Parentless dialog'/>\n"
|
||||||
GtkToolItem *button;
|
"<menuitem name='Utility' action='Utility'/>\n"
|
||||||
|
"<menuitem name='Splashscreen' action='Splashscreen'/>\n"
|
||||||
|
"<menuitem name='Top dock' action='Top dock'/>\n"
|
||||||
|
"<menuitem name='Bottom dock' action='Bottom dock'/>\n"
|
||||||
|
"<menuitem name='Left dock' action='Left dock'/>\n"
|
||||||
|
"<menuitem name='Right dock' action='Right dock'/>\n"
|
||||||
|
"<menuitem name='All docks' action='All docks'/>\n"
|
||||||
|
"<menuitem name='Desktop' action='Desktop'/>\n"
|
||||||
|
"<menuitem name='Menu' action='Menu'/>\n"
|
||||||
|
"<menuitem name='Toolbar' action='Toolbar'/>\n"
|
||||||
|
"<menuitem name='Override Redirect' action='Override Redirect'/>\n"
|
||||||
|
"<menuitem name='Border Only' action='Border Only'/>\n"
|
||||||
|
"</menu>\n"
|
||||||
|
"</menubar>\n"
|
||||||
|
"<toolbar>\n"
|
||||||
|
"<toolitem name='New' action='New'/>\n"
|
||||||
|
"<toolitem name='Lock' action='Lock'/>\n"
|
||||||
|
"<toolitem name='Decorations' action='Decorations'/>\n"
|
||||||
|
"<toolitem name='Ratio' action='Ratio'/>\n"
|
||||||
|
"<toolitem name='Quit' action='Quit'/>\n"
|
||||||
|
"</toolbar>\n"
|
||||||
|
"</ui>\n";
|
||||||
|
|
||||||
button = gtk_tool_button_new_from_stock (stock_id);
|
static const GtkActionEntry menu_items[] =
|
||||||
gtk_tool_item_set_tooltip_text (button, text);
|
{
|
||||||
g_signal_connect (G_OBJECT (button),
|
{ "Windows", NULL, "_Windows", NULL,
|
||||||
"clicked",
|
NULL, NULL },
|
||||||
callback,
|
{ "Dialog", NULL, "_Dialog", "<control>d",
|
||||||
user_data);
|
NULL, G_CALLBACK (dialog_cb) },
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar),
|
{ "Modal dialog", NULL, "_Modal dialog", NULL,
|
||||||
button,
|
NULL, G_CALLBACK (modal_dialog_cb) },
|
||||||
-1); /*-1 means append to end of toolbar*/
|
{ "Parentless dialog", NULL, "_Parentless dialog", NULL,
|
||||||
}
|
NULL, G_CALLBACK (no_parent_dialog_cb) },
|
||||||
|
{ "Utility", NULL, "_Utility", "<control>u",
|
||||||
|
NULL, G_CALLBACK (utility_cb) },
|
||||||
|
{ "Splashscreen", NULL, "_Splashscreen", "<control>s",
|
||||||
|
NULL, G_CALLBACK (splashscreen_cb) },
|
||||||
|
{ "Top dock", NULL, "_Top dock", NULL,
|
||||||
|
NULL, G_CALLBACK (dock_cb) },
|
||||||
|
{ "Bottom dock", NULL, "_Bottom dock", NULL,
|
||||||
|
NULL, G_CALLBACK (dock_cb) },
|
||||||
|
{ "Left dock", NULL, "_Left dock", NULL,
|
||||||
|
NULL, G_CALLBACK (dock_cb) },
|
||||||
|
{ "Right dock", NULL, "_Right dock", NULL,
|
||||||
|
NULL, G_CALLBACK (dock_cb) },
|
||||||
|
{ "All docks", NULL, "_All docks", NULL,
|
||||||
|
NULL, G_CALLBACK (dock_cb) },
|
||||||
|
{ "Desktop", NULL, "Des_ktop", NULL,
|
||||||
|
NULL, G_CALLBACK (desktop_cb) },
|
||||||
|
{ "Menu", NULL, "Me_nu", NULL,
|
||||||
|
NULL, G_CALLBACK (menu_cb) },
|
||||||
|
{ "Toolbar", NULL, "Tool_bar", NULL,
|
||||||
|
NULL, G_CALLBACK (toolbar_cb) },
|
||||||
|
{ "Override Redirect", NULL, "Override Redirect", NULL,
|
||||||
|
NULL, G_CALLBACK (override_redirect_cb) },
|
||||||
|
{ "Border Only", NULL, "Border Only", NULL,
|
||||||
|
NULL, G_CALLBACK (border_only_cb) }
|
||||||
|
};
|
||||||
|
|
||||||
|
static const GtkActionEntry tool_items[] =
|
||||||
|
{
|
||||||
|
{ "New", GTK_STOCK_NEW, NULL, NULL,
|
||||||
|
"Open another one of these windows", G_CALLBACK (do_appwindow) },
|
||||||
|
{ "Lock", GTK_STOCK_OPEN, NULL, NULL,
|
||||||
|
"This is a demo button that"
|
||||||
|
" locks up the demo", G_CALLBACK (sleep_cb) },
|
||||||
|
{ "Decorations", GTK_STOCK_OPEN, NULL, NULL,
|
||||||
|
"This is a demo button that "
|
||||||
|
"toggles window decorations", G_CALLBACK (toggle_decorated_cb) },
|
||||||
|
{ "Quit", GTK_STOCK_QUIT, NULL, NULL,
|
||||||
|
"This is a demo button with "
|
||||||
|
" a 'quit' icon", G_CALLBACK (clicked_toolbar_cb) },
|
||||||
|
{ "Ratio", GTK_STOCK_OPEN, NULL, NULL,
|
||||||
|
"This is a demo button that locks the aspect ratio "
|
||||||
|
"using a hint", G_CALLBACK (toggle_aspect_ratio) }
|
||||||
|
};
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
do_appwindow (void)
|
do_appwindow (void)
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
GtkWidget *table;
|
GtkWidget *table;
|
||||||
GtkWidget *toolbar;
|
|
||||||
GtkWidget *handlebox;
|
GtkWidget *handlebox;
|
||||||
GtkWidget *statusbar;
|
GtkWidget *statusbar;
|
||||||
GtkWidget *contents;
|
GtkWidget *contents;
|
||||||
GtkWidget *sw;
|
GtkWidget *sw;
|
||||||
GtkTextBuffer *buffer;
|
GtkTextBuffer *buffer;
|
||||||
GtkAccelGroup *accel_group;
|
GtkActionGroup *action_group;
|
||||||
GtkItemFactory *item_factory;
|
GtkUIManager *ui_manager;
|
||||||
|
|
||||||
/* Create the toplevel window
|
/* Create the toplevel window
|
||||||
*/
|
*/
|
||||||
@ -890,25 +939,28 @@ do_appwindow (void)
|
|||||||
/* Create the menubar
|
/* Create the menubar
|
||||||
*/
|
*/
|
||||||
|
|
||||||
accel_group = gtk_accel_group_new ();
|
contents = gtk_text_view_new ();
|
||||||
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
|
|
||||||
g_object_unref (accel_group);
|
|
||||||
|
|
||||||
item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group);
|
action_group = gtk_action_group_new ("mainmenu");
|
||||||
|
gtk_action_group_add_actions (action_group,
|
||||||
|
menu_items,
|
||||||
|
G_N_ELEMENTS (menu_items),
|
||||||
|
window);
|
||||||
|
gtk_action_group_add_actions (action_group,
|
||||||
|
tool_items,
|
||||||
|
G_N_ELEMENTS (tool_items),
|
||||||
|
window);
|
||||||
|
|
||||||
/* Set up item factory to go away with the window */
|
ui_manager = gtk_ui_manager_new ();
|
||||||
g_object_ref_sink (item_factory);
|
|
||||||
g_object_set_data_full (G_OBJECT (window),
|
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
|
||||||
"<main>",
|
|
||||||
item_factory,
|
|
||||||
(GDestroyNotify) g_object_unref);
|
|
||||||
|
|
||||||
/* create menu items */
|
/* create menu items */
|
||||||
gtk_item_factory_create_items (item_factory, G_N_ELEMENTS (menu_items),
|
|
||||||
menu_items, window);
|
gtk_ui_manager_add_ui_from_string (ui_manager, menu_item_string, -1, NULL);
|
||||||
|
|
||||||
gtk_table_attach (GTK_TABLE (table),
|
gtk_table_attach (GTK_TABLE (table),
|
||||||
gtk_item_factory_get_widget (item_factory, "<main>"),
|
gtk_ui_manager_get_widget (ui_manager, "/ui/menubar"),
|
||||||
/* X direction */ /* Y direction */
|
/* X direction */ /* Y direction */
|
||||||
0, 1, 0, 1,
|
0, 1, 0, 1,
|
||||||
GTK_EXPAND | GTK_FILL, 0,
|
GTK_EXPAND | GTK_FILL, 0,
|
||||||
@ -936,7 +988,6 @@ do_appwindow (void)
|
|||||||
gtk_window_set_default_size (GTK_WINDOW (window),
|
gtk_window_set_default_size (GTK_WINDOW (window),
|
||||||
200, 200);
|
200, 200);
|
||||||
|
|
||||||
contents = gtk_text_view_new ();
|
|
||||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (contents),
|
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (contents),
|
||||||
PANGO_WRAP_WORD);
|
PANGO_WRAP_WORD);
|
||||||
|
|
||||||
@ -945,31 +996,11 @@ do_appwindow (void)
|
|||||||
|
|
||||||
/* Create the toolbar
|
/* Create the toolbar
|
||||||
*/
|
*/
|
||||||
toolbar = gtk_toolbar_new ();
|
|
||||||
|
|
||||||
insert_stock_button (toolbar, GTK_STOCK_NEW,
|
|
||||||
"Open another one of these windows",
|
|
||||||
G_CALLBACK (do_appwindow), window);
|
|
||||||
|
|
||||||
insert_stock_button (toolbar, GTK_STOCK_OPEN,
|
|
||||||
"This is a demo button that locks up the demo",
|
|
||||||
G_CALLBACK (sleep_cb), window);
|
|
||||||
|
|
||||||
insert_stock_button (toolbar, GTK_STOCK_OPEN,
|
|
||||||
"This is a demo button that toggles window decorations",
|
|
||||||
G_CALLBACK (toggle_decorated_cb), window);
|
|
||||||
|
|
||||||
insert_stock_button (toolbar, GTK_STOCK_OPEN,
|
|
||||||
"This is a demo button that locks the aspect ratio using a hint",
|
|
||||||
G_CALLBACK (toggle_aspect_ratio), contents);
|
|
||||||
|
|
||||||
insert_stock_button (toolbar, GTK_STOCK_QUIT,
|
|
||||||
"This is a demo button with a 'quit' icon",
|
|
||||||
G_CALLBACK (clicked_toolbar_cb), window);
|
|
||||||
|
|
||||||
handlebox = gtk_handle_box_new ();
|
handlebox = gtk_handle_box_new ();
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (handlebox), toolbar);
|
gtk_container_add (GTK_CONTAINER (handlebox),
|
||||||
|
gtk_ui_manager_get_widget (ui_manager, "/ui/toolbar"));
|
||||||
|
|
||||||
gtk_table_attach (GTK_TABLE (table),
|
gtk_table_attach (GTK_TABLE (table),
|
||||||
handlebox,
|
handlebox,
|
||||||
@ -1014,6 +1045,8 @@ do_appwindow (void)
|
|||||||
|
|
||||||
gtk_widget_show_all (window);
|
gtk_widget_show_all (window);
|
||||||
|
|
||||||
|
g_object_unref (ui_manager);
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,93 +70,99 @@ static void run_position_expression_timings (void);
|
|||||||
static void run_theme_benchmark (void);
|
static void run_theme_benchmark (void);
|
||||||
|
|
||||||
|
|
||||||
static GtkItemFactoryEntry menu_items[] =
|
static const gchar *menu_item_string =
|
||||||
|
"<ui>\n"
|
||||||
|
"<menubar>\n"
|
||||||
|
"<menu name='Windows' action='Windows'>\n"
|
||||||
|
"<menuitem name='Dialog' action='Dialog'/>\n"
|
||||||
|
"<menuitem name='Modal dialog' action='Modal dialog'/>\n"
|
||||||
|
"<menuitem name='Utility' action='Utility'/>\n"
|
||||||
|
"<menuitem name='Splashscreen' action='Splashscreen'/>\n"
|
||||||
|
"<menuitem name='Top dock' action='Top dock'/>\n"
|
||||||
|
"<menuitem name='Bottom dock' action='Bottom dock'/>\n"
|
||||||
|
"<menuitem name='Left dock' action='Left dock'/>\n"
|
||||||
|
"<menuitem name='Right dock' action='Right dock'/>\n"
|
||||||
|
"<menuitem name='Desktop' action='Desktop'/>\n"
|
||||||
|
"</menu>\n"
|
||||||
|
"</menubar>\n"
|
||||||
|
"<toolbar>\n"
|
||||||
|
"<separator/>\n"
|
||||||
|
"<toolitem name='New' action='New'/>\n"
|
||||||
|
"<toolitem name='Open' action='Open'/>\n"
|
||||||
|
"<toolitem name='Quit' action='Quit'/>\n"
|
||||||
|
"<separator/>\n"
|
||||||
|
"</toolbar>\n"
|
||||||
|
"</ui>\n";
|
||||||
|
|
||||||
|
static GtkActionEntry menu_items[] =
|
||||||
{
|
{
|
||||||
{ N_("/_Windows"), NULL, NULL, 0, "<Branch>" },
|
{ "Windows", NULL, N_("_Windows"), NULL, NULL, NULL },
|
||||||
{ N_("/Windows/tearoff"), NULL, NULL, 0, "<Tearoff>" },
|
{ "Dialog", NULL, N_("_Dialog"), "<control>d", NULL, NULL },
|
||||||
{ N_("/Windows/_Dialog"), "<control>d", NULL, 0, NULL },
|
{ "Modal dialog", NULL, N_("_Modal dialog"), NULL, NULL, NULL },
|
||||||
{ N_("/Windows/_Modal dialog"), NULL, NULL, 0, NULL },
|
{ "Utility", NULL, N_("_Utility"), "<control>u", NULL, NULL },
|
||||||
{ N_("/Windows/_Utility"), "<control>u", NULL, 0, NULL },
|
{ "Splashscreen", NULL, N_("_Splashscreen"), "<control>s", NULL, NULL },
|
||||||
{ N_("/Windows/_Splashscreen"), "<control>s", NULL, 0, NULL },
|
{ "Top dock", NULL, N_("_Top dock"), NULL, NULL, NULL },
|
||||||
{ N_("/Windows/_Top dock"), NULL, NULL, 0, NULL },
|
{ "Bottom dock", NULL, N_("_Bottom dock"), NULL, NULL, NULL },
|
||||||
{ N_("/Windows/_Bottom dock"), NULL, NULL, 0, NULL },
|
{ "Left dock", NULL, N_("_Left dock"), NULL, NULL, NULL },
|
||||||
{ N_("/Windows/_Left dock"), NULL, NULL, 0, NULL },
|
{ "Right dock", NULL, N_("_Right dock"), NULL, NULL, NULL },
|
||||||
{ N_("/Windows/_Right dock"), NULL, NULL, 0, NULL },
|
{ "All docks", NULL, N_("_All docks"), NULL, NULL, NULL },
|
||||||
{ N_("/Windows/_All docks"), NULL, NULL, 0, NULL },
|
{ "Desktop", NULL, N_("Des_ktop"), NULL, NULL, NULL }
|
||||||
{ N_("/Windows/Des_ktop"), NULL, NULL, 0, NULL }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static GtkActionEntry tool_items[] =
|
||||||
insert_stock_button (GtkWidget *toolbar,
|
|
||||||
const gchar *stock_id,
|
|
||||||
const gchar *text)
|
|
||||||
{
|
{
|
||||||
GtkToolItem *button;
|
{ "New", GTK_STOCK_NEW, NULL, NULL,
|
||||||
|
N_("Open another one of these windows"), NULL },
|
||||||
button = gtk_tool_button_new_from_stock (stock_id);
|
{ "Open", GTK_STOCK_OPEN, NULL, NULL,
|
||||||
gtk_tool_item_set_tooltip_text (button, text);
|
N_("This is a demo button with an 'open' icon"), NULL },
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar),
|
{ "Quit", GTK_STOCK_QUIT, NULL, NULL,
|
||||||
button,
|
N_("This is a demo button with a 'quit' icon"), NULL }
|
||||||
-1); /*-1 means append to end of toolbar*/
|
};
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
normal_contents (void)
|
normal_contents (void)
|
||||||
{
|
{
|
||||||
GtkWidget *table;
|
GtkWidget *table;
|
||||||
GtkWidget *toolbar;
|
|
||||||
GtkWidget *handlebox;
|
GtkWidget *handlebox;
|
||||||
GtkWidget *statusbar;
|
GtkWidget *statusbar;
|
||||||
GtkWidget *contents;
|
GtkWidget *contents;
|
||||||
GtkWidget *sw;
|
GtkWidget *sw;
|
||||||
GtkItemFactory *item_factory;
|
GtkActionGroup *action_group;
|
||||||
|
GtkUIManager *ui_manager;
|
||||||
|
|
||||||
table = gtk_table_new (1, 4, FALSE);
|
table = gtk_table_new (1, 4, FALSE);
|
||||||
|
|
||||||
/* Create the menubar
|
/* Create the menubar
|
||||||
*/
|
*/
|
||||||
|
|
||||||
item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", NULL);
|
action_group = gtk_action_group_new ("mainmenu");
|
||||||
|
gtk_action_group_add_actions (action_group,
|
||||||
|
menu_items,
|
||||||
|
G_N_ELEMENTS (menu_items),
|
||||||
|
NULL);
|
||||||
|
gtk_action_group_add_actions (action_group,
|
||||||
|
tool_items,
|
||||||
|
G_N_ELEMENTS (tool_items),
|
||||||
|
NULL);
|
||||||
|
|
||||||
gtk_item_factory_set_translate_func(item_factory,
|
ui_manager = gtk_ui_manager_new ();
|
||||||
(GtkTranslateFunc)gettext, NULL, NULL);
|
|
||||||
|
|
||||||
/* Set up item factory to go away */
|
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
|
||||||
g_object_ref (item_factory);
|
|
||||||
g_object_ref_sink (item_factory);
|
|
||||||
g_object_unref (item_factory);
|
|
||||||
g_object_set_data_full (G_OBJECT (table),
|
|
||||||
"<main>",
|
|
||||||
item_factory,
|
|
||||||
(GDestroyNotify) g_object_unref);
|
|
||||||
|
|
||||||
/* create menu items */
|
/* create menu items */
|
||||||
gtk_item_factory_create_items (item_factory, G_N_ELEMENTS (menu_items),
|
gtk_ui_manager_add_ui_from_string (ui_manager, menu_item_string, -1, NULL);
|
||||||
menu_items, NULL);
|
|
||||||
|
|
||||||
gtk_table_attach (GTK_TABLE (table),
|
gtk_table_attach (GTK_TABLE (table),
|
||||||
gtk_item_factory_get_widget (item_factory, "<main>"),
|
gtk_ui_manager_get_widget (ui_manager, "/ui/menubar"),
|
||||||
/* X direction */ /* Y direction */
|
/* X direction */ /* Y direction */
|
||||||
0, 1, 0, 1,
|
0, 1, 0, 1,
|
||||||
GTK_EXPAND | GTK_FILL, 0,
|
GTK_EXPAND | GTK_FILL, 0,
|
||||||
0, 0);
|
0, 0);
|
||||||
|
|
||||||
/* Create the toolbar
|
|
||||||
*/
|
|
||||||
toolbar = gtk_toolbar_new ();
|
|
||||||
|
|
||||||
insert_stock_button (toolbar, GTK_STOCK_NEW,
|
|
||||||
_("Open another one of these windows"));
|
|
||||||
insert_stock_button (toolbar, GTK_STOCK_OPEN,
|
|
||||||
_("This is a demo button with an 'open' icon"));
|
|
||||||
insert_stock_button (toolbar, GTK_STOCK_QUIT,
|
|
||||||
_("This is a demo button with a 'quit' icon"));
|
|
||||||
|
|
||||||
handlebox = gtk_handle_box_new ();
|
handlebox = gtk_handle_box_new ();
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (handlebox), toolbar);
|
gtk_container_add (GTK_CONTAINER (handlebox),
|
||||||
|
gtk_ui_manager_get_widget (ui_manager, "/ui/toolbar"));
|
||||||
|
|
||||||
gtk_table_attach (GTK_TABLE (table),
|
gtk_table_attach (GTK_TABLE (table),
|
||||||
handlebox,
|
handlebox,
|
||||||
@ -203,6 +209,8 @@ normal_contents (void)
|
|||||||
|
|
||||||
gtk_widget_show_all (table);
|
gtk_widget_show_all (table);
|
||||||
|
|
||||||
|
g_object_unref (ui_manager);
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user