diff options
author | Simon Steinbeiss <simon.steinbeiss@elfenbeinturm.at> | 2016-03-26 21:47:24 +0300 |
---|---|---|
committer | Eric Koegel <eric.koegel@gmail.com> | 2016-03-26 21:47:24 +0300 |
commit | 2d0b0a81825331b8ef6889394f62a461dffe7a34 (patch) | |
tree | c37508566f3a21dbf2dddd2606235aefd58fa108 /settings | |
parent | 2ce3439456d645cefcb2163a66f22858aebfb2f5 (diff) | |
download | xfce4-session-2d0b0a81825331b8ef6889394f62a461dffe7a34.tar.gz |
Start porting to Gtk3
Diffstat (limited to 'settings')
-rw-r--r-- | settings/Makefile.am | 2 | ||||
-rw-r--r-- | settings/main.c | 47 | ||||
-rw-r--r-- | settings/xfae-dialog.c | 46 | ||||
-rw-r--r-- | settings/xfae-window.c | 29 | ||||
-rw-r--r-- | settings/xfce4-session-settings.ui (renamed from settings/xfce4-session-settings.glade) | 52 |
5 files changed, 96 insertions, 80 deletions
diff --git a/settings/Makefile.am b/settings/Makefile.am index 203a3ed5..4ca79ad0 100644 --- a/settings/Makefile.am +++ b/settings/Makefile.am @@ -69,7 +69,7 @@ xfce4-session-marshal.c: xfce4-session-marshal.list Makefile $(AM_V_GEN) echo '#include "xfce4-session-marshal.h"' > $@ glib-genmarshal --prefix=xfce4_session_marshal xfce4-session-marshal.list --body >> xfce4-session-marshal.c -xfce4-session-settings_ui.h: xfce4-session-settings.glade +xfce4-session-settings_ui.h: xfce4-session-settings.ui $(AM_V_GEN) exo-csource --static --strip-comments --strip-content --name=xfce4_session_settings_ui $< >$@ xfsm-client-dbus-client.h: $(top_srcdir)/xfce4-session/xfsm-client-dbus.xml Makefile diff --git a/settings/main.c b/settings/main.c index 4e6f9c4e..8786706b 100644 --- a/settings/main.c +++ b/settings/main.c @@ -27,6 +27,8 @@ #include <xfconf/xfconf.h> #include <gtk/gtk.h> +#include <gtk/gtkx.h> +#include <gdk/gdkx.h> #include <libxfce4util/libxfce4util.h> #include <libxfce4ui/libxfce4ui.h> @@ -36,15 +38,6 @@ #include "xfce4-session-settings_ui.h" -static GdkNativeWindow opt_socket_id = 0; -static gboolean opt_version = FALSE; -static GOptionEntry option_entries[] = -{ - { "socket-id", 's', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_INT, &opt_socket_id, N_("Settings manager socket"), N_("SOCKET ID") }, - { "version", 'V', 0, G_OPTION_ARG_NONE, &opt_version, N_("Version information"), NULL }, - { NULL } -}; - static void xfce4_session_settings_dialog_response (GtkDialog *dialog, gint response, gpointer userdata) { if (response == GTK_RESPONSE_HELP) { @@ -61,10 +54,22 @@ main(int argc, char **argv) { GtkBuilder *builder; - GtkWidget *notebook, *xfae_page, *lbl; + GtkWidget *notebook; + GtkWidget *xfae_page; + GtkWidget *lbl; GError *error = NULL; XfconfChannel *channel; + Window opt_socket_id = 0; + gboolean opt_version = FALSE; + + GOptionEntry option_entries[] = + { + { "socket-id", 's', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_INT, &opt_socket_id, N_("Settings manager socket"), N_("SOCKET ID") }, + { "version", 'V', 0, G_OPTION_ARG_NONE, &opt_version, N_("Version information"), NULL }, + { NULL } + }; + xfce_textdomain(GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); if(!gtk_init_with_args (&argc, &argv, "", option_entries, @@ -163,21 +168,29 @@ main(int argc, gtk_widget_show(dialog); /* To prevent the settings dialog to be saved in the session */ - gdk_set_sm_client_id ("FAKE ID"); + gdk_x11_set_sm_client_id ("FAKE ID"); gtk_main(); } else { - GtkWidget *plug, *plug_child; + GtkWidget *plug; + GtkWidget *plug_child; + GtkWidget *parent; + plug_child = GTK_WIDGET(gtk_builder_get_object(builder, "plug-child")); plug = gtk_plug_new(opt_socket_id); - gtk_widget_show(plug); + gtk_widget_show (plug); + + parent = gtk_widget_get_parent (plug_child); + if (parent) + { + g_object_ref (plug_child); + gtk_container_remove (GTK_CONTAINER (parent), plug_child); + gtk_container_add (GTK_CONTAINER (plug), plug_child); + g_object_unref (plug_child); + } g_signal_connect(plug, "delete-event", G_CALLBACK(gtk_main_quit), NULL); - plug_child = GTK_WIDGET(gtk_builder_get_object(builder, "plug-child")); - gtk_widget_reparent(plug_child, plug); - gtk_widget_show(plug_child); - /* Stop startup notification */ gdk_notify_startup_complete(); diff --git a/settings/xfae-dialog.c b/settings/xfae-dialog.c index e7989850..af860b95 100644 --- a/settings/xfae-dialog.c +++ b/settings/xfae-dialog.c @@ -62,38 +62,37 @@ xfae_dialog_class_init (XfaeDialogClass *klass) static void xfae_dialog_init (XfaeDialog *dialog) { - GtkWidget *table; + GtkWidget *content_area; + GtkWidget *grid; GtkWidget *label; GtkWidget *hbox; GtkWidget *button; GtkWidget *image; gtk_dialog_add_buttons (GTK_DIALOG (dialog), - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, + _("Cancel"), GTK_RESPONSE_CANCEL, + _("OK"), GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE); gtk_window_set_title (GTK_WINDOW (dialog), _("Add application")); - table = g_object_new (GTK_TYPE_TABLE, - "border-width", 12, + content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); + + grid = g_object_new (GTK_TYPE_GRID, + "width", 12, "row-spacing", 6, "column-spacing", 12, - "n-rows", 3, - "n-columns", 2, "homogeneous", FALSE, NULL); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), table, TRUE, TRUE, 0); - gtk_widget_show (table); + gtk_container_add (GTK_CONTAINER (content_area), grid); + gtk_widget_show (grid); label = g_object_new (GTK_TYPE_LABEL, "label", _("Name:"), "xalign", 0.0f, NULL); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, - GTK_FILL, GTK_FILL, 0, 0); + gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); gtk_widget_show (label); dialog->name_entry = g_object_new (GTK_TYPE_ENTRY, @@ -101,38 +100,33 @@ xfae_dialog_init (XfaeDialog *dialog) NULL); g_signal_connect_swapped (G_OBJECT (dialog->name_entry), "notify::text", G_CALLBACK (xfae_dialog_update), dialog); - gtk_table_attach (GTK_TABLE (table), dialog->name_entry, 1, 2, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); + gtk_grid_attach (GTK_GRID (grid), dialog->name_entry, 1, 0, 1, 1); gtk_widget_show (dialog->name_entry); label = g_object_new (GTK_TYPE_LABEL, "label", _("Description:"), "xalign", 0.0f, NULL); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, - GTK_FILL, GTK_FILL, 0, 0); + gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1); gtk_widget_show (label); dialog->descr_entry = g_object_new (GTK_TYPE_ENTRY, "activates-default", TRUE, NULL); - gtk_table_attach (GTK_TABLE (table), dialog->descr_entry, 1, 2, 1, 2, - GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); + gtk_grid_attach (GTK_GRID (grid), dialog->descr_entry, 1, 1, 1, 1); gtk_widget_show (dialog->descr_entry); label = g_object_new (GTK_TYPE_LABEL, "label", _("Command:"), "xalign", 0.0f, NULL); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, - GTK_FILL, GTK_FILL, 0, 0); + gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1); gtk_widget_show (label); - hbox = g_object_new (GTK_TYPE_HBOX, + hbox = g_object_new (GTK_TYPE_BOX, "spacing", 6, NULL); - gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 2, 3, - GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); + gtk_grid_attach (GTK_GRID (grid), hbox, 1, 2, 1, 1); gtk_widget_show (hbox); dialog->command_entry = g_object_new (GTK_TYPE_ENTRY, @@ -151,7 +145,7 @@ xfae_dialog_init (XfaeDialog *dialog) gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); - image = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON); + image = gtk_image_new_from_icon_name ("document-open", GTK_ICON_SIZE_BUTTON); gtk_container_add (GTK_CONTAINER (button), image); gtk_widget_show (image); } @@ -184,8 +178,8 @@ xfae_dialog_browse (XfaeDialog *dialog) chooser = gtk_file_chooser_dialog_new (_("Select a command"), GTK_WINDOW (dialog), GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, + _("Cancel"), GTK_RESPONSE_CANCEL, + _("OK"), GTK_RESPONSE_ACCEPT, NULL); gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), TRUE); diff --git a/settings/xfae-window.c b/settings/xfae-window.c index 5488db19..f799f6a8 100644 --- a/settings/xfae-window.c +++ b/settings/xfae-window.c @@ -59,7 +59,7 @@ struct _XfaeWindow -G_DEFINE_TYPE (XfaeWindow, xfae_window, GTK_TYPE_VBOX); +G_DEFINE_TYPE (XfaeWindow, xfae_window, GTK_TYPE_BOX); @@ -88,13 +88,14 @@ xfae_window_init (XfaeWindow *window) gtk_box_set_spacing (GTK_BOX (vbox), 6); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); - hbox = gtk_hbox_new (FALSE, 12); + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0); gtk_widget_show (hbox); - img = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG); + img = gtk_image_new_from_icon_name ("dialog-information", GTK_ICON_SIZE_DIALOG); gtk_box_pack_start (GTK_BOX (hbox), img, FALSE, FALSE, 0); - gtk_misc_set_alignment (GTK_MISC (img), 0.50, 0.00); + gtk_widget_set_halign (GTK_WIDGET (img), GTK_ALIGN_CENTER); + gtk_widget_set_valign (GTK_WIDGET (img), GTK_ALIGN_END); gtk_widget_show (img); label = g_object_new (GTK_TYPE_LABEL, @@ -169,17 +170,17 @@ xfae_window_init (XfaeWindow *window) gtk_tree_view_append_column (GTK_TREE_VIEW (window->treeview), column); - bbox = gtk_hbox_new (FALSE, 6); + bbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, TRUE, 0); gtk_widget_show (bbox); - button = gtk_button_new_from_stock (GTK_STOCK_ADD); + button = gtk_button_new_with_label (_("Add")); g_signal_connect_swapped (G_OBJECT (button), "clicked", G_CALLBACK (xfae_window_add), window); gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); gtk_widget_show (button); - button = gtk_button_new_from_stock (GTK_STOCK_REMOVE); + button = gtk_button_new_with_label (_("Remove")); g_signal_connect_swapped (G_OBJECT (button), "clicked", G_CALLBACK (xfae_window_remove), window); gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); @@ -189,7 +190,7 @@ xfae_window_init (XfaeWindow *window) G_CALLBACK (xfae_window_selection_changed), button); xfae_window_selection_changed (window->selection, button); - button = gtk_button_new_from_stock (GTK_STOCK_EDIT); + button = gtk_button_new_with_label (_("Edit")); g_signal_connect_swapped (G_OBJECT (button), "clicked", G_CALLBACK (xfae_window_edit), window); gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); @@ -231,13 +232,13 @@ xfae_window_button_press_event (GtkWidget *treeview, menu = gtk_menu_new (); - item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ADD, NULL); + item = gtk_menu_item_new_with_label (_("Add")); g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfae_window_add), window); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); - item = gtk_image_menu_item_new_from_stock (GTK_STOCK_REMOVE, NULL); + item = gtk_menu_item_new_with_label (_("Remove")); g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfae_window_remove), window); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); @@ -256,7 +257,7 @@ xfae_window_button_press_event (GtkWidget *treeview, g_main_loop_unref (loop); gtk_grab_remove (menu); - gtk_object_sink (GTK_OBJECT (menu)); + g_object_ref_sink (menu); return TRUE; } @@ -325,12 +326,12 @@ xfae_window_remove (XfaeWindow *window) g_error_free (error); return; } - - remove_item = xfce_dialog_confirm (GTK_WINDOW (parent), GTK_STOCK_REMOVE, NULL, + remove_item = TRUE; +/* remove_item = xfce_dialog_confirm (GTK_WINDOW (parent), GTK_STOCK_REMOVE, NULL, _("This will permanently remove the application " "from the list of automatically started applications"), _("Are you sure you want to remove \"%s\""), name); - +*/ g_free (name); if (remove_item && !xfae_model_remove (XFAE_MODEL (model), &iter, &error)) diff --git a/settings/xfce4-session-settings.glade b/settings/xfce4-session-settings.ui index b8e22474..980af747 100644 --- a/settings/xfce4-session-settings.glade +++ b/settings/xfce4-session-settings.ui @@ -1,8 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="2.20"/> - <!-- interface-requires libxfce4ui 4.5 --> - <!-- interface-naming-policy toplevel-contextual --> + <requires lib="gtk+" version="3.10"/> + <requires lib="libxfce4ui" version="4.5"/> <object class="GtkDialog" id="dialog_saving"> <property name="can_focus">False</property> <property name="border_width">5</property> @@ -49,13 +48,14 @@ </packing> </child> <child> - <object class="GtkVBox" id="vbox5"> + <object class="GtkBox" id="vbox5"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="spacing">6</property> + <property name="orientation">vertical</property> <child> - <object class="GtkHBox" id="hbox8"> + <object class="GtkBox" id="hbox8"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">12</property> @@ -127,12 +127,13 @@ <property name="type_hint">dialog</property> <property name="subtitle" translatable="yes">Customize desktop startup and splash screen</property> <child internal-child="vbox"> - <object class="GtkVBox" id="dialog-vbox1"> + <object class="GtkBox" id="dialog-vbox1"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">2</property> + <property name="orientation">vertical</property> <child internal-child="action_area"> - <object class="GtkHButtonBox" id="dialog-action_area1"> + <object class="GtkButtonBox" id="dialog-action_area1"> <property name="visible">True</property> <property name="can_focus">False</property> <child> @@ -179,11 +180,12 @@ <property name="can_focus">True</property> <property name="border_width">6</property> <child> - <object class="GtkVBox" id="vbox1"> + <object class="GtkBox" id="vbox1"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="border_width">12</property> <property name="spacing">6</property> + <property name="orientation">vertical</property> <child> <object class="GtkFrame" id="frame1"> <property name="visible">True</property> @@ -240,10 +242,11 @@ <property name="bottom_padding">6</property> <property name="left_padding">12</property> <child> - <object class="GtkVBox" id="vbox2"> + <object class="GtkBox" id="vbox2"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">6</property> + <property name="orientation">vertical</property> <child> <object class="GtkCheckButton" id="chk_session_autosave"> <property name="label" translatable="yes">Automatically save session on logo_ut</property> @@ -312,16 +315,17 @@ </packing> </child> <child> - <object class="GtkHBox" id="hbox2"> + <object class="GtkBox" id="hbox2"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="border_width">12</property> <property name="spacing">12</property> <child> - <object class="GtkVBox" id="vbox6"> + <object class="GtkBox" id="vbox6"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">6</property> + <property name="orientation">vertical</property> <child> <object class="GtkScrolledWindow" id="scrolledwindow2"> <property name="visible">True</property> @@ -352,7 +356,7 @@ <property name="receives_default">True</property> <property name="tooltip_text" translatable="yes">Opens the configuration panel for the selected splash screen</property> <child> - <object class="GtkHBox" id="hbox3"> + <object class="GtkBox" id="hbox3"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">4</property> @@ -402,7 +406,7 @@ <property name="receives_default">True</property> <property name="tooltip_text" translatable="yes">Demonstrates the selected splash screen</property> <child> - <object class="GtkHBox" id="hbox4"> + <object class="GtkBox" id="hbox4"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">4</property> @@ -451,10 +455,11 @@ </packing> </child> <child> - <object class="GtkVBox" id="vbox7"> + <object class="GtkBox" id="vbox7"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">6</property> + <property name="orientation">vertical</property> <child> <object class="GtkImage" id="img_splash_preview"> <property name="visible">True</property> @@ -642,13 +647,14 @@ </packing> </child> <child> - <object class="GtkVBox" id="vbox8"> + <object class="GtkBox" id="vbox8"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="border_width">12</property> <property name="spacing">6</property> + <property name="orientation">vertical</property> <child> - <object class="GtkHBox" id="hbox10"> + <object class="GtkBox" id="hbox10"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">12</property> @@ -708,7 +714,7 @@ </packing> </child> <child> - <object class="GtkHBox" id="hbox7"> + <object class="GtkBox" id="hbox7"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">6</property> @@ -719,7 +725,7 @@ <property name="can_focus">True</property> <property name="receives_default">True</property> <child> - <object class="GtkHBox" id="hbox5"> + <object class="GtkBox" id="hbox5"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">4</property> @@ -767,7 +773,7 @@ <property name="receives_default">True</property> <property name="tooltip_text" translatable="yes">Empty the session cache</property> <child> - <object class="GtkHBox" id="hbox9"> + <object class="GtkBox" id="hbox9"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">4</property> @@ -816,7 +822,7 @@ <property name="receives_default">True</property> <property name="tooltip_text" translatable="yes">Quit the program, and remove it from the session</property> <child> - <object class="GtkHBox" id="hbox6"> + <object class="GtkBox" id="hbox6"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">4</property> @@ -882,11 +888,12 @@ </packing> </child> <child> - <object class="GtkVBox" id="vbox3"> + <object class="GtkBox" id="vbox3"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="border_width">12</property> <property name="spacing">6</property> + <property name="orientation">vertical</property> <child> <object class="GtkFrame" id="frame3"> <property name="visible">True</property> @@ -901,10 +908,11 @@ <property name="bottom_padding">6</property> <property name="left_padding">12</property> <child> - <object class="GtkVBox" id="vbox4"> + <object class="GtkBox" id="vbox4"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">6</property> + <property name="orientation">vertical</property> <child> <object class="GtkCheckButton" id="chk_compat_gnome"> <property name="label" translatable="yes">Launch GN_OME services on startup</property> |