[libslab/gnome-3] more cleanup



commit 6d68ad8a69a1c43242d0db42a8796700c45d6596
Author: Michael Meeks <michael meeks novell com>
Date:   Tue Sep 13 20:06:43 2011 +0200

    more cleanup

 libslab/app-shell.c             |    4 ++
 libslab/application-tile.c      |    8 ++---
 libslab/bookmark-agent.c        |    2 +-
 libslab/libslab-utils.c         |   36 ++++++++++++----------
 libslab/libslab-utils.h         |    2 +-
 libslab/search-context-picker.c |    2 +-
 libslab/shell-window.c          |    2 +
 libslab/slab-gnome-util.c       |   63 +-------------------------------------
 libslab/slab-section.c          |    3 ++
 libslab/system-tile.c           |    4 +-
 10 files changed, 39 insertions(+), 87 deletions(-)
---
diff --git a/libslab/app-shell.c b/libslab/app-shell.c
index 6cd2b27..ea6f50c 100644
--- a/libslab/app-shell.c
+++ b/libslab/app-shell.c
@@ -603,6 +603,8 @@ generate_filtered_lists (gpointer catdata, gpointer user_data)
 	gchar *temp1, *temp2;
 	GList *launcher_list = data->launcher_list;
 
+	g_return_if_fail (launcher_list != NULL);
+
 	g_list_free (data->filtered_launcher_list);
 	data->filtered_launcher_list = NULL;
 
@@ -1265,6 +1267,8 @@ insert_launcher_into_category (CategoryData * cat_data, GKeyFile * desktop_item,
 	launcher =
 	  application_tile_new_full (libslab_keyfile_get_location (desktop_item),
 		app_data->icon_size, app_data->show_tile_generic_name, app_data->gconf_prefix);
+	g_return_if_fail (launcher != NULL);
+
 	gtk_widget_set_size_request (launcher, SIZING_TILE_WIDTH, -1);
 
 	filepath = libslab_keyfile_get (desktop_item, G_KEY_FILE_DESKTOP_KEY_EXEC);
diff --git a/libslab/application-tile.c b/libslab/application-tile.c
index 2d54e5b..e20eb93 100644
--- a/libslab/application-tile.c
+++ b/libslab/application-tile.c
@@ -147,7 +147,7 @@ application_tile_new_full (const gchar *desktop_item_id,
 
 	GKeyFile *desktop_item;
 
-	desktop_item = load_desktop_item_from_unknown (desktop_item_id);
+	desktop_item = libslab_gnome_desktop_item_new_from_unknown_id (desktop_item_id);
 
 	gchar *type = NULL;
 	if (
@@ -156,8 +156,7 @@ application_tile_new_full (const gchar *desktop_item_id,
 								  G_KEY_FILE_DESKTOP_KEY_TYPE)),
 				     G_KEY_FILE_DESKTOP_TYPE_APPLICATION))
 	{
-	  uri = libslab_keyfile_get (desktop_item,
-				      G_KEY_FILE_DESKTOP_KEY_URL);
+	  uri = libslab_keyfile_get_location (desktop_item);
         }
 	g_free (type);
 
@@ -315,8 +314,7 @@ application_tile_setup (ApplicationTile *this, const gchar *gconf_prefix)
 
 
 	if (! priv->desktop_item) {
-		priv->desktop_item = load_desktop_item_from_unknown (TILE (this)->uri);
-
+		priv->desktop_item = libslab_gnome_desktop_item_new_from_unknown_id (TILE (this)->uri);
 		if (! priv->desktop_item)
 			return;
 	}
diff --git a/libslab/bookmark-agent.c b/libslab/bookmark-agent.c
index e6ca1ba..87f03cb 100644
--- a/libslab/bookmark-agent.c
+++ b/libslab/bookmark-agent.c
@@ -1073,7 +1073,7 @@ create_app_item (BookmarkAgent *this, const gchar *uri)
 	ditem = libslab_gnome_desktop_item_new_from_unknown_id (uri);
 
 	if (ditem) {
-		uri_new = libslab_keyfile_get_location (ditem);
+		uri_new = g_strdup (libslab_keyfile_get_location (ditem));
 		g_object_unref (ditem);
 	}
 
diff --git a/libslab/libslab-utils.c b/libslab/libslab-utils.c
index 2c8e39d..c0024b2 100644
--- a/libslab/libslab-utils.c
+++ b/libslab/libslab-utils.c
@@ -101,6 +101,8 @@ libslab_gnome_desktop_item_new_from_unknown_id (const gchar *id)
 		return NULL;
 
 	item = g_key_file_new();
+	g_object_set_data_full (G_OBJECT (item), "file", g_strdup (id), g_free);
+
 	g_key_file_load_from_file (item, id, 0, &error);
 
 	if (! error)
@@ -110,6 +112,22 @@ libslab_gnome_desktop_item_new_from_unknown_id (const gchar *id)
 		error = NULL;
 	}
 
+	basename = g_strrstr (id, "/");
+
+	if (basename) {
+		basename++;
+
+		g_key_file_load_from_file (item, basename, 0, &error);
+
+		if (! error)
+			return item;
+		else {
+			g_error_free (error);
+			error = NULL;
+		}
+	}
+	g_object_unref (item);
+
 #ifdef FIXME_MORE_PORTING
 	item = gnme_desktop_item_new_from_file (id, 0, & error);
 
@@ -129,20 +147,6 @@ libslab_gnome_desktop_item_new_from_unknown_id (const gchar *id)
 		error = NULL;
 	}
 
-	basename = g_strrstr (id, "/");
-
-	if (basename) {
-		basename++;
-
-		item = gnme_desktop_item_new_from_basename (basename, 0, &error);
-
-		if (! error)
-			return item;
-		else {
-			g_error_free (error);
-			error = NULL;
-		}
-	}
 #endif
 
 	return NULL;
@@ -731,7 +735,7 @@ libslab_keyfile_get_locale (GKeyFile *keyfile, const char *key)
   return g_key_file_get_locale_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, key, NULL, NULL);
 }
 
-char *libslab_keyfile_get_location (GKeyFile *keyfile)
+const char *libslab_keyfile_get_location (GKeyFile *keyfile)
 {
-  return libslab_keyfile_get (keyfile, G_KEY_FILE_DESKTOP_KEY_URL);
+  return g_object_get_data (keyfile, "file");
 }
diff --git a/libslab/libslab-utils.h b/libslab/libslab-utils.h
index afa37bd..70a6b34 100644
--- a/libslab/libslab-utils.h
+++ b/libslab/libslab-utils.h
@@ -10,7 +10,7 @@
 G_BEGIN_DECLS
 
 char             *libslab_keyfile_get (GKeyFile *keyfile, const char *key);
-char             *libslab_keyfile_get_location (GKeyFile *keyfile);
+const char       *libslab_keyfile_get_location (GKeyFile *keyfile);
 char             *libslab_keyfile_get_locale (GKeyFile *keyfile, const char *key);
 
 gboolean          libslab_gtk_image_set_by_id (GtkImage *image, const gchar *id);
diff --git a/libslab/search-context-picker.c b/libslab/search-context-picker.c
index b35781b..ef419c7 100644
--- a/libslab/search-context-picker.c
+++ b/libslab/search-context-picker.c
@@ -105,7 +105,7 @@ menu_position_func (GtkMenu * menu, int *x, int *y, gboolean * push_in, gpointer
 	if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
 	{
 		GtkRequisition req;
-		gtk_widget_size_request (GTK_WIDGET (menu), &req);
+		gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
 		*x += allocation.width - req.width;
 	}
 
diff --git a/libslab/shell-window.c b/libslab/shell-window.c
index 33a0ce6..d52e538 100644
--- a/libslab/shell-window.c
+++ b/libslab/shell-window.c
@@ -141,6 +141,7 @@ shell_window_paint_window (GtkWidget * widget, GdkEventExpose * event, gpointer
 
 	gtk_widget_get_allocation (left_pane, &allocation);
 
+#ifdef PORTING_MORE
 	/* draw left pane background */
 	gtk_paint_flat_box (gtk_widget_get_style (widget),
 	                    gtk_widget_get_window (widget),
@@ -148,6 +149,7 @@ shell_window_paint_window (GtkWidget * widget, GdkEventExpose * event, gpointer
 	                    GTK_SHADOW_NONE, NULL, widget, "",
 	                    allocation.x, allocation.y,
 	                    allocation.width, allocation.height);
+#endif
 
 	return FALSE;
 }
diff --git a/libslab/slab-gnome-util.c b/libslab/slab-gnome-util.c
index 0f81076..7e07e27 100644
--- a/libslab/slab-gnome-util.c
+++ b/libslab/slab-gnome-util.c
@@ -144,67 +144,11 @@ load_desktop_item_from_gconf_key (const gchar * key)
 	if (!id)
 		return NULL;
 
-	item = load_desktop_item_from_unknown (id);
+	item = libslab_gnome_desktop_item_new_from_unknown_id (id);
 	g_free (id);
 	return item;
 }
 
-GKeyFile *
-load_desktop_item_from_unknown (const gchar *id)
-{
-	GKeyFile *item;
-	gchar            *basename;
-
-	GError *error = NULL;
-
-	g_warning ("more cut and paste crap");
-#ifdef FIXME_MORE_PORTING
-
-	item = gnome_desktop_item_new_from_uri (id, 0, &error);
-
-	if (! error)
-		return item;
-	else {
-		g_error_free (error);
-		error = NULL;
-	}
-
-	item = gnme_desktop_item_new_from_file (id, 0, &error);
-
-	if (! error)
-		return item;
-	else {
-		g_error_free (error);
-		error = NULL;
-	}
-
-	item = gnme_desktop_item_new_from_basename (id, 0, &error);
-
-	if (! error)
-		return item;
-	else {
-		g_error_free (error);
-		error = NULL;
-	}
-
-	basename = g_strrstr (id, "/");
-
-	if (basename) {
-		basename++;
-
-		item = gnme_desktop_item_new_from_basename (basename, 0, &error);
-
-		if (! error)
-			return item;
-		else {
-			g_error_free (error);
-			error = NULL;
-		}
-	}
-#endif
-	return NULL;
-}
-
 gchar *
 get_package_name_from_desktop_item (GKeyFile * desktop_item)
 {
@@ -307,10 +251,7 @@ open_desktop_item_help (GKeyFile * desktop_item)
 gboolean
 desktop_item_is_in_main_menu (GKeyFile * desktop_item)
 {
-	char *url = libslab_keyfile_get_location (desktop_item);
-	gboolean ret = desktop_uri_is_in_main_menu (url);
-	g_free (url);
-	return ret;
+	return desktop_uri_is_in_main_menu (libslab_keyfile_get_location (desktop_item));
 }
 
 gboolean
diff --git a/libslab/slab-section.c b/libslab/slab-section.c
index b05921f..b0b8d9b 100644
--- a/libslab/slab-section.c
+++ b/libslab/slab-section.c
@@ -50,6 +50,8 @@ slab_section_set_title_color (GtkWidget * widget)
 {
 	GtkStyle *style;
 
+	g_warning ("set_title_color");
+#ifdef PORTING_MORE
 	style = gtk_widget_get_style (widget);
 
 	switch (SLAB_SECTION (widget)->style)
@@ -69,6 +71,7 @@ slab_section_set_title_color (GtkWidget * widget)
 	default:
 		g_assert_not_reached ();
 	}
+#endif
 }
 
 static void
diff --git a/libslab/system-tile.c b/libslab/system-tile.c
index ae99404..34f5b92 100644
--- a/libslab/system-tile.c
+++ b/libslab/system-tile.c
@@ -61,7 +61,7 @@ system_tile_new (const gchar *desktop_item_id, const gchar *title)
 	SystemTile        *this;
 	SystemTilePrivate *priv;
 
-	gchar     *uri    = NULL;
+	gchar *uri        = NULL;
 	GtkWidget *header = NULL;
 
 	GtkMenu *context_menu;
@@ -84,7 +84,7 @@ system_tile_new (const gchar *desktop_item_id, const gchar *title)
 
 	if (desktop_item) {
 		image_id = libslab_keyfile_get_locale (desktop_item, "Icon");
-		uri      = libslab_keyfile_get (desktop_item, G_KEY_FILE_DESKTOP_KEY_URL);
+		uri      = g_strdup (libslab_keyfile_get_location (desktop_item));
 
 		if (title)
 			header_txt = g_strdup (title);



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