gnome-utils r8543 - in trunk: . baobab baobab/data baobab/src



Author: cosimoc
Date: Tue Apr  7 17:34:09 2009
New Revision: 8543
URL: http://svn.gnome.org/viewvc/gnome-utils?rev=8543&view=rev

Log:
2009-04-07  Cosimo Cecchi  <cosimoc gnome org>

	* data/Makefile.am:
	* data/baobab.glade:
	* src/Makefile.am:
	* src/baobab-prefs.c (create_props), (create_tree_props):
	* src/baobab-treeview.c (create_directory_treeview):
	* src/baobab-utils.c (set_ui_action_sens), (set_ui_widget_sens),
	(show_label):
	* src/baobab-utils.h:
	* src/baobab.c (check_menu_sens), (baobab_scan_location),
	(set_toolbar_visible), (set_statusbar_visible),
	(baobab_create_toolbar), (baobab_create_statusbar), (baobab_init),
	(initialize_ringschart), (main):
	* src/baobab.h:
	* src/callbacks.c (on_view_sb_activate):
	* src/callbacks.h:
	Port to GtkBuilder (#577940).


Removed:
   trunk/baobab/data/baobab.glade
Modified:
   trunk/ChangeLog
   trunk/baobab/ChangeLog
   trunk/baobab/data/Makefile.am
   trunk/baobab/src/Makefile.am
   trunk/baobab/src/baobab-prefs.c
   trunk/baobab/src/baobab-treeview.c
   trunk/baobab/src/baobab-utils.c
   trunk/baobab/src/baobab-utils.h
   trunk/baobab/src/baobab.c
   trunk/baobab/src/baobab.h
   trunk/baobab/src/callbacks.c
   trunk/baobab/src/callbacks.h
   trunk/configure.ac

Modified: trunk/baobab/data/Makefile.am
==============================================================================
--- trunk/baobab/data/Makefile.am	(original)
+++ trunk/baobab/data/Makefile.am	Tue Apr  7 17:34:09 2009
@@ -1,6 +1,6 @@
-# FIXME - this is an evil hack, but glade doesn't find the pixmaps otherwise
-gladedir         = $(datadir)/baobab/pixmaps
-glade_DATA       = baobab.glade
+uidir   = $(datadir)/baobab
+ui_DATA = baobab-main-window.ui \
+	  baobab-dialog-scan-props.ui
 
 baobabappdir	   = $(datadir)/applications
 baobabapp_in_files = baobab.desktop.in
@@ -28,7 +28,7 @@
 endif
 
 EXTRA_DIST = 				\
-	$(glade_DATA)			\
+	$(ui_DATA)			\
 	baobab.desktop.in.in		\
 	$(schemas_in_files)		\
 	$(man_MANS)

Modified: trunk/baobab/src/Makefile.am
==============================================================================
--- trunk/baobab/src/Makefile.am	(original)
+++ trunk/baobab/src/Makefile.am	Tue Apr  7 17:34:09 2009
@@ -8,8 +8,6 @@
 	-DLIBDIR=\""$(libdir)"\"				\
 	-DDATADIR=\""$(datadir)"\"				\
 	-DPKGDATADIR=\""$(datadir)/baobab"\"			\
-	-DUIDATADIR=\""$(datadir)/gnome-2.0/ui"\"		\
-	-DBAOBAB_DATA_DIR=\""$(datadir)"\" 			\
 	-DBAOBAB_PIX_DIR=\""$(datadir)/baobab/pixmaps/"\" 	\
 	-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" 	\
 	$(NULL)
@@ -44,13 +42,11 @@
 
 baobab_CFLAGS = 			\
 	$(GNOME_UTILS_CFLAGS)		\
-	$(LIBGLADE_CFLAGS)		\
 	$(LIBGTOP_CFLAGS)		\
 	$(NULL)
 
 baobab_LDFLAGS = -export-dynamic
 baobab_LDADD = 				\
 	$(GNOME_UTILS_LIBS)		\
-	$(LIBGLADE_LIBS)		\
 	$(LIBGTOP_LIBS)			\
 	$(NULL)

Modified: trunk/baobab/src/baobab-prefs.c
==============================================================================
--- trunk/baobab/src/baobab-prefs.c	(original)
+++ trunk/baobab/src/baobab-prefs.c	Tue Apr  7 17:34:09 2009
@@ -40,7 +40,7 @@
 static GtkTreeView *tree_props;
 static GtkListStore *model_props;
 static GtkListStore *create_props_model (void);
-static GtkWidget *create_tree_props (GladeXML *);
+static GtkWidget *create_tree_props (GtkBuilder *builder);
 static void fill_props_model (GtkWidget *);
 static void check_toggled (GtkCellRendererToggle * cell,
 			   gchar * path_str, gpointer data);
@@ -104,24 +104,34 @@
 create_props (void)
 {
 	GtkWidget *dlg, *check_enablehome;
-	GladeXML *dlg_xml;
+	GtkBuilder *builder;
+	GError *error = NULL;
 
 	props_changed = FALSE;
 
-	/* Glade stuff */
-	dlg_xml = glade_xml_new (BAOBAB_GLADE_FILE,
-				 "dialog_scan_props", NULL);
-	glade_xml_signal_autoconnect (dlg_xml);
-	dlg = glade_xml_get_widget (dlg_xml, "dialog_scan_props");
+	/* UI stuff */
+	builder = gtk_builder_new ();
+	gtk_builder_add_from_file (builder, BAOBAB_DIALOG_SCAN_UI_FILE, &error);
+
+	if (error) {
+		g_critical ("Can't load user interface file for the scan properties dialog: %s",
+			    error->message);
+		g_object_unref (builder);
+		g_error_free (error);
+
+		return;
+	}
+
+	dlg = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_scan_props"));
 
 	gtk_window_set_transient_for (GTK_WINDOW (dlg),
 				      GTK_WINDOW (baobab.window));
 
-	tree_props = (GtkTreeView *) create_tree_props (dlg_xml);
+	tree_props = (GtkTreeView *) create_tree_props (builder);
 	fill_props_model (dlg);
 	read_gconf ();
 
-	check_enablehome = glade_xml_get_widget (dlg_xml, "check_enable_home");
+	check_enablehome = GTK_WIDGET (gtk_builder_get_object (builder, "check_enable_home"));
 	gtk_toggle_button_set_active ((GtkToggleButton *) check_enablehome,
 				      baobab.bbEnableHomeMonitor);
 
@@ -134,7 +144,6 @@
 		    	  NULL);
 
   	gtk_widget_show_all (dlg);
-	g_object_unref (dlg_xml);
 }
 
 GtkListStore *
@@ -156,13 +165,13 @@
 }
 
 GtkWidget *
-create_tree_props (GladeXML *dlg_xml)
+create_tree_props (GtkBuilder *builder)
 {
 	GtkCellRenderer *cell;
 	GtkTreeViewColumn *col;
 	GtkWidget *tvw;
 
-	tvw = glade_xml_get_widget (dlg_xml, "tree_view_props");
+	tvw = GTK_WIDGET (gtk_builder_get_object (builder , "tree_view_props"));
 
 	/* checkbox column */
 	cell = gtk_cell_renderer_toggle_new ();

Modified: trunk/baobab/src/baobab-treeview.c
==============================================================================
--- trunk/baobab/src/baobab-treeview.c	(original)
+++ trunk/baobab/src/baobab-treeview.c	Tue Apr  7 17:34:09 2009
@@ -188,7 +188,7 @@
 	GtkTreeViewColumn *col;
 	GtkWidget *scrolled;
 
-	GtkWidget *tvw = glade_xml_get_widget (baobab.main_xml, "treeview1");
+	GtkWidget *tvw = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, "treeview1"));
 
 	g_signal_connect (tvw, "row-expanded",
 			  G_CALLBACK (on_tv_row_expanded), NULL);
@@ -272,7 +272,7 @@
 
 	gtk_tree_view_collapse_all (GTK_TREE_VIEW (tvw));
 	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tvw), FALSE);
-	scrolled = glade_xml_get_widget (baobab.main_xml, "scrolledwindow1");
+	scrolled = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, "scrolledwindow1"));
 	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
 					GTK_POLICY_AUTOMATIC,
 					GTK_POLICY_AUTOMATIC);

Modified: trunk/baobab/src/baobab-utils.c
==============================================================================
--- trunk/baobab/src/baobab-utils.c	(original)
+++ trunk/baobab/src/baobab-utils.c	Tue Apr  7 17:34:09 2009
@@ -150,11 +150,20 @@
 }
 
 void
-set_glade_widget_sens (const gchar *name, gboolean sens)
+set_ui_action_sens (const gchar *name, gboolean sens)
+{
+	GtkAction *a;
+
+	a = GTK_ACTION (gtk_builder_get_object (baobab.main_ui, name));
+	gtk_action_set_sensitive (a, sens);
+}
+
+void
+set_ui_widget_sens (const gchar *name, gboolean sens)
 {
 	GtkWidget *w;
 
-	w = glade_xml_get_widget (baobab.main_xml, name);
+	w = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, name));
 	gtk_widget_set_sensitive (w, sens);
 }
 
@@ -393,7 +402,7 @@
 {
 	GtkWidget *label;
 
-	label = glade_xml_get_widget (baobab.main_xml, "label1");
+	label = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, "label1"));
 
 	gtk_label_set_markup (GTK_LABEL (label),
 			      baobab.label_scan);

Modified: trunk/baobab/src/baobab-utils.h
==============================================================================
--- trunk/baobab/src/baobab-utils.h	(original)
+++ trunk/baobab/src/baobab-utils.h	Tue Apr  7 17:34:09 2009
@@ -44,7 +44,8 @@
 gboolean can_trash_file (GFile *file);
 gboolean trash_file (GFile *file);
 void contents_changed (void);
-void set_glade_widget_sens (const gchar *name, gboolean sens);
+void set_ui_action_sens (const gchar *name, gboolean sens);
+void set_ui_widget_sens (const gchar *name, gboolean sens);
 gchar *baobab_gconf_get_string_with_default (GConfClient *client, const gchar *key, const gchar *def);
 gboolean baobab_help_display (GtkWindow *parent, const gchar *file_name, const gchar *link_id);
 gboolean is_virtual_filesystem (GFile *file);

Modified: trunk/baobab/src/baobab.c
==============================================================================
--- trunk/baobab/src/baobab.c	(original)
+++ trunk/baobab/src/baobab.c	Tue Apr  7 17:34:09 2009
@@ -119,32 +119,33 @@
 			gtk_main_iteration ();
 
 		set_statusbar (_("Scanning..."));
-		set_glade_widget_sens ("expand_all", TRUE);
-		set_glade_widget_sens ("collapse_all", TRUE);
+		set_ui_action_sens ("expand_all", TRUE);
+		set_ui_action_sens ("collapse_all", TRUE);
 	}
 
-	set_glade_widget_sens ("tbscanhome", !scanning);
-	set_glade_widget_sens ("tbscanall", !scanning);
-	set_glade_widget_sens ("tbscandir", !scanning);
-	set_glade_widget_sens ("menuscanhome", !scanning);
-	set_glade_widget_sens ("menuallfs", !scanning);
-	set_glade_widget_sens ("menuscandir", !scanning);
-	set_glade_widget_sens ("tbstop", scanning);
-	set_glade_widget_sens ("tbrescan", !scanning && current_location != NULL);
-	set_glade_widget_sens ("menustop", scanning);
-	set_glade_widget_sens ("menurescan", !scanning && current_location != NULL);
-	set_glade_widget_sens ("preferenze1", !scanning);
-	set_glade_widget_sens ("menu_scan_rem", !scanning);
-	set_glade_widget_sens ("tb_scan_remote", !scanning);
-	set_glade_widget_sens ("ck_allocated",
-			       !scanning &&
-			       baobab.is_local && !g_noactivescans);
+	set_ui_action_sens ("menuscanhome", !scanning);
+	set_ui_action_sens ("menuallfs", !scanning);
+	set_ui_action_sens ("menuscandir", !scanning);
+	set_ui_action_sens ("menustop", scanning);
+	set_ui_action_sens ("menurescan", !scanning && current_location != NULL);
+	set_ui_action_sens ("preferenze1", !scanning);
+	set_ui_action_sens ("menu_scan_rem", !scanning);
+	set_ui_action_sens ("ck_allocated",
+			    !scanning &&
+			    baobab.is_local && !g_noactivescans);
+
+	set_ui_widget_sens ("tbscanhome", !scanning);
+	set_ui_widget_sens ("tbscanall", !scanning);
+	set_ui_widget_sens ("tbscandir", !scanning);
+	set_ui_widget_sens ("tbstop", scanning);
+	set_ui_widget_sens ("tbrescan", !scanning && current_location != NULL);
+	set_ui_widget_sens ("tb_scan_remote", !scanning);
 }
 
 void
 baobab_scan_location (GFile *file)
 {
-	GtkWidget *ck_allocated;
+	GtkToggleAction *ck_allocated;
 
 	if (!baobab_check_dir (file))
 		return;
@@ -166,15 +167,14 @@
 
 	/* check if the file system is local or remote */
 	baobab.is_local = scan_is_local (file);
-	ck_allocated = glade_xml_get_widget (baobab.main_xml, "ck_allocated");
+	ck_allocated = GTK_TOGGLE_ACTION (gtk_builder_get_object (baobab.main_ui, "ck_allocated"));
 	if (!baobab.is_local) {
-		gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (ck_allocated),
-						FALSE);
-		gtk_widget_set_sensitive (ck_allocated, FALSE);
+		gtk_toggle_action_set_active (ck_allocated, FALSE);
+		gtk_action_set_sensitive (GTK_ACTION (ck_allocated), FALSE);
 		baobab.show_allocated = FALSE;
 	}
 	else {
-		gtk_widget_set_sensitive (ck_allocated, TRUE);
+		gtk_action_set_sensitive (GTK_ACTION (ck_allocated), TRUE);
 	}
 
 	baobab_scan_execute (file);
@@ -470,7 +470,7 @@
 void
 set_toolbar_visible (gboolean visible)
 {
-	GtkWidget *menu;
+	GtkToggleAction *action;
 
 	if (visible)
 		gtk_widget_show (baobab.toolbar);
@@ -478,14 +478,14 @@
 		gtk_widget_hide (baobab.toolbar);
 
 	/* make sure the check menu item is consistent */
-	menu = glade_xml_get_widget (baobab.main_xml, "view_tb");
-	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu), visible);
+	action = GTK_TOGGLE_ACTION (gtk_builder_get_object (baobab.main_ui, "view_tb"));
+	gtk_toggle_action_set_active (action, visible);
 }
 
 void
 set_statusbar_visible (gboolean visible)
 {
-	GtkWidget *menu;
+	GtkToggleAction *action;
 
 	if (visible)
 		gtk_widget_show (baobab.statusbar);
@@ -493,8 +493,8 @@
 		gtk_widget_hide (baobab.statusbar);
 
 	/* make sure the check menu item is consistent */
-	menu = glade_xml_get_widget (baobab.main_xml, "view_sb");
-	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu), visible);
+	action = GTK_TOGGLE_ACTION (gtk_builder_get_object (baobab.main_ui, "view_sb"));
+	gtk_toggle_action_set_active (action, visible);
 }
 
 void
@@ -568,7 +568,7 @@
 	GtkToolItem *separator;
 	gboolean visible;
 
-	toolbar = glade_xml_get_widget (baobab.main_xml, "toolbar1");
+	toolbar = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, "toolbar1"));
 	if (toolbar == NULL) {
 		g_printerr ("Could not build toolbar\n");
 		return;
@@ -606,8 +606,8 @@
 {
 	gboolean visible;
 
-	baobab.statusbar = glade_xml_get_widget (baobab.main_xml,
-						 "statusbar1");
+	baobab.statusbar = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui,
+							       "statusbar1"));
 	if (baobab.statusbar == NULL) {
 		g_printerr ("Could not build statusbar\n");
 		return;
@@ -681,10 +681,18 @@
 	GError *error = NULL;
 	monitor_home = NULL;
 
-	/* Load Glade */
-	baobab.main_xml = glade_xml_new (BAOBAB_GLADE_FILE,
-					 "baobab_window", NULL);
-	glade_xml_signal_autoconnect (baobab.main_xml);
+	/* Load the UI */
+	baobab.main_ui = gtk_builder_new ();
+	gtk_builder_add_from_file (baobab.main_ui, BAOBAB_UI_FILE, &error);
+
+	if (error) {
+		g_object_unref (baobab.main_ui);
+		g_critical ("Unable to load the user interface file: %s", error->message);
+		g_error_free (error);
+		exit (1);
+	}
+
+	gtk_builder_connect_signals (baobab.main_ui, NULL);
 
 	/* Misc */
 	baobab.label_scan = NULL;
@@ -833,7 +841,7 @@
 	gtk_frame_set_label_align (GTK_FRAME (chart_frame), 0.0, 0.0);
 	gtk_frame_set_shadow_type (GTK_FRAME (chart_frame), GTK_SHADOW_IN);
 
-	hpaned_main = glade_xml_get_widget (baobab.main_xml, "hpaned_main");
+	hpaned_main = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, "hpaned_main"));
 	gtk_paned_pack2 (GTK_PANED (hpaned_main),
 			 chart_frame, TRUE, TRUE);
 	gtk_paned_set_position (GTK_PANED (hpaned_main), 480);
@@ -849,7 +857,7 @@
 			  "changed",
 			  G_CALLBACK (on_chart_type_change), NULL);
 
-	hbox1 = glade_xml_get_widget (baobab.main_xml, "hbox1");
+	hbox1 = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, "hbox1"));
 	gtk_container_add (GTK_CONTAINER (hbox1), baobab.chart_type_combo);
 	gtk_box_set_spacing (GTK_BOX (hbox1), 50);
 	gtk_box_set_child_packing (GTK_BOX (hbox1),
@@ -977,19 +985,17 @@
 	set_label_scan (&g_fs);
 	show_label ();
 
-	baobab.window = glade_xml_get_widget (baobab.main_xml, "baobab_window");
+	baobab.window = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, "baobab_window"));
 	gtk_window_set_position (GTK_WINDOW (baobab.window),
 				 GTK_WIN_POS_CENTER);
 
 	baobab.tree_view = create_directory_treeview ();
 
-	set_glade_widget_sens ("menurescan",FALSE);
+	set_ui_action_sens ("menurescan", FALSE);
 
 	/* set allocated space checkbox */
-	gtk_check_menu_item_set_active ((GtkCheckMenuItem *)
-				      glade_xml_get_widget (baobab.
-							    main_xml,
-							    "ck_allocated"),
+	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (gtk_builder_get_object (baobab.main_ui,
+							 "ck_allocated")),
 				      baobab.show_allocated);
 
 	gtk_widget_show (baobab.window);

Modified: trunk/baobab/src/baobab.h
==============================================================================
--- trunk/baobab/src/baobab.h	(original)
+++ trunk/baobab/src/baobab.h	Tue Apr  7 17:34:09 2009
@@ -30,14 +30,14 @@
 #include <glib.h>
 #include <gtk/gtk.h>
 #include <gio/gio.h>
-#include <glade/glade-xml.h>
 #include <gconf/gconf-client.h>
 
 typedef struct _baobab_application baobab_application;
 typedef struct _baobab_fs baobab_fs;
 struct BaobabSearchOpt;
 
-#define BAOBAB_GLADE_FILE BAOBAB_PIX_DIR "baobab.glade"
+#define BAOBAB_UI_FILE PKGDATADIR "/baobab-main-window.ui"
+#define BAOBAB_DIALOG_SCAN_UI_FILE PKGDATADIR "/baobab-dialog-scan-props.ui"
 
 #define BAOBAB_KEY_DIR "/apps/baobab"
 #define BAOBAB_TOOLBAR_VISIBLE_KEY	BAOBAB_KEY_DIR "/ui/toolbar_visible"
@@ -60,7 +60,7 @@
 };
 
 struct _baobab_application {
-	GladeXML *main_xml;
+	GtkBuilder *main_ui;
   	GtkWidget *window;
   	GtkWidget *tree_view;
 	GtkWidget *rings_chart;

Modified: trunk/baobab/src/callbacks.c
==============================================================================
--- trunk/baobab/src/callbacks.c	(original)
+++ trunk/baobab/src/callbacks.c	Tue Apr  7 17:34:09 2009
@@ -328,12 +328,12 @@
 }
 
 void
-on_view_sb_activate (GtkCheckMenuItem *checkmenuitem,
-                     gpointer          user_data) 
+on_view_sb_activate (GtkToggleAction *action,
+                     gpointer         user_data) 
 {
 	gboolean visible;
 
-	visible = gtk_check_menu_item_get_active (checkmenuitem);
+	visible = gtk_toggle_action_get_active (action);
 	set_statusbar_visible (visible);
 
 	gconf_client_set_bool (baobab.gconf_client,

Modified: trunk/baobab/src/callbacks.h
==============================================================================
--- trunk/baobab/src/callbacks.h	(original)
+++ trunk/baobab/src/callbacks.h	Tue Apr  7 17:34:09 2009
@@ -57,7 +57,7 @@
 void on_tb_scan_remote_clicked (GtkToolButton *toolbutton, gpointer user_data);
 void on_menu_scan_rem_activate (GtkMenuItem *menuitem, gpointer user_data);
 void on_view_tb_activate (GtkCheckMenuItem *checkmenuitem, gpointer user_data); 
-void on_view_sb_activate (GtkCheckMenuItem *checkmenuitem, gpointer user_data); 
+void on_view_sb_activate (GtkToggleAction *action, gpointer         user_data);
 void on_ck_allocated_activate (GtkCheckMenuItem *checkmenuitem, gpointer user_data);
 void on_helpcontents_activate (GtkMenuItem *menuitem, gpointer user_data);
 void on_tv_selection_changed (GtkTreeSelection *selection, gpointer user_data);

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Tue Apr  7 17:34:09 2009
@@ -72,7 +72,7 @@
 
 GLIB_REQUIRED=2.20.0
 GIO_REQUIRED=2.16.0
-GTK_REQUIRED=2.14.0
+GTK_REQUIRED=2.16.0
 LIBGNOME_DESKTOP_REQUIRED=2.9.91
 LIBGNOME_REQUIRED=2.13.2
 LIBGNOMEUI_REQUIRED=2.13.7



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]