summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tvb@cvs.gnome.org>2005-01-03 08:51:30 +0000
committerTristan Van Berkom <tvb@src.gnome.org>2005-01-03 08:51:30 +0000
commit9a8db8e33a901e906355ae0dc2924f3f667dab34 (patch)
tree62db00e529d2063a9de7e8a90a9dbec2dbf73c33
parent00bf8f095d217c3f0c2a2e5736c5d2df04c0ba6d (diff)
downloadglade-9a8db8e33a901e906355ae0dc2924f3f667dab34.tar.gz
- Changed GladeWidgetClass (class)->icon from GtkImage --> GdkPixbuf - Nowimendio-0501IMENDIO_0501_BRANCHPOINT
2005-01-02 Tristan Van Berkom <tvb@cvs.gnome.org> * src/glade-clipboard-view.c, src/glade-palette.c, src/glade-project-view.c, src/glade-widget-class.[ch], src/main.c: - Changed GladeWidgetClass (class)->icon from GtkImage --> GdkPixbuf - Now unavailable images showup properly on the project-view and the clipboard. - Needed to implement a little hack to provoke gtk+ to work properly (See main.c `gtk_icon_factory_lookup_default ("");') * src/glade-placeholder.c, src/glade-utils.c: Fixed flicker on button-click (No need to clear the project and the selection and then reselect if you are already selected).
-rw-r--r--ChangeLog14
-rw-r--r--src/glade-clipboard-view.c2
-rw-r--r--src/glade-palette.c14
-rw-r--r--src/glade-placeholder.c3
-rw-r--r--src/glade-project-view.c13
-rw-r--r--src/glade-utils.c11
-rw-r--r--src/glade-utils.h1
-rw-r--r--src/glade-widget-class.c40
-rw-r--r--src/glade-widget-class.h2
-rw-r--r--src/main.c7
10 files changed, 84 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 07ceceb6..c4152cd1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2005-01-02 Tristan Van Berkom <tvb@cvs.gnome.org>
+
+ * src/glade-clipboard-view.c, src/glade-palette.c,
+ src/glade-project-view.c, src/glade-widget-class.[ch], src/main.c:
+ - Changed GladeWidgetClass (class)->icon from GtkImage --> GdkPixbuf
+ - Now unavailable images showup properly on the project-view and the
+ clipboard.
+ - Needed to implement a little hack to provoke gtk+ to work properly
+ (See main.c `gtk_icon_factory_lookup_default ("");')
+
+ * src/glade-placeholder.c, src/glade-utils.c:
+ Fixed flicker on button-click (No need to clear the project and the
+ selection and then reselect if you are already selected).
+
2005-01-01 Tristan Van Berkom <tvb@cvs.gnome.org>
* src/glade-command.c: g_list_prepend in loops and
diff --git a/src/glade-clipboard-view.c b/src/glade-clipboard-view.c
index 0f6148c7..2822b7e7 100644
--- a/src/glade-clipboard-view.c
+++ b/src/glade-clipboard-view.c
@@ -143,7 +143,7 @@ glade_clipboard_view_cell_function (GtkTreeViewColumn *tree_column,
if (is_icon)
g_object_set (G_OBJECT (cell),
- "pixbuf", gtk_image_get_pixbuf (GTK_IMAGE (widget->widget_class->icon)),
+ "pixbuf", widget->widget_class->icon,
NULL);
else
g_object_set (G_OBJECT (cell),
diff --git a/src/glade-palette.c b/src/glade-palette.c
index 3942765c..438092df 100644
--- a/src/glade-palette.c
+++ b/src/glade-palette.c
@@ -183,9 +183,11 @@ glade_palette_create_widget_class_button (GladePalette *palette,
GtkWidget *label;
GtkWidget *radio;
GtkWidget *hbox;
+ GtkWidget *image;
label = gtk_label_new (widget_class->palette_name);
radio = gtk_radio_button_new (palette->widgets_button_group);
+ image = gtk_image_new_from_pixbuf (widget_class->icon);
g_object_set_data (G_OBJECT (radio), GLADE_PALETTE_BUTTON_CLASS_DATA,
widget_class);
@@ -194,9 +196,8 @@ glade_palette_create_widget_class_button (GladePalette *palette,
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
hbox = gtk_hbox_new (FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), widget_class->icon,
- FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 1);
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 1);
gtk_button_set_relief (GTK_BUTTON (radio), GTK_RELIEF_NONE);
gtk_container_add (GTK_CONTAINER (radio), hbox);
@@ -220,7 +221,8 @@ glade_palette_widget_table_create (GladePalette *palette, GladeCatalog *catalog)
/* Go through all the widget classes in this catalog. */
for (; list; list = list->next)
{
- GladeWidgetClass *gwidget_class = GLADE_WIDGET_CLASS (list->data);
+ GladeWidgetClass *gwidget_class =
+ GLADE_WIDGET_CLASS (list->data);
/*
* If the widget class wants to be in the palette (I don't
@@ -228,7 +230,9 @@ glade_palette_widget_table_create (GladePalette *palette, GladeCatalog *catalog)
*/
if (gwidget_class->in_palette)
{
- GtkWidget *button = glade_palette_create_widget_class_button (palette, gwidget_class);
+ GtkWidget *button =
+ glade_palette_create_widget_class_button
+ (palette, gwidget_class);
gtk_box_pack_start (GTK_BOX (vbox), button,
FALSE, FALSE, 0);
}
diff --git a/src/glade-placeholder.c b/src/glade-placeholder.c
index 64a64a75..d877fa99 100644
--- a/src/glade-placeholder.c
+++ b/src/glade-placeholder.c
@@ -333,7 +333,8 @@ glade_placeholder_button_press (GtkWidget *widget, GdkEventButton *event)
/* reset the palette */
glade_palette_unselect_widget (gpw->palette);
}
- else
+ else if (glade_util_has_selection (widget) == FALSE ||
+ g_list_length (glade_util_get_selection ()) != 1)
{
glade_project_selection_clear
(glade_project_window_get_active_project
diff --git a/src/glade-project-view.c b/src/glade-project-view.c
index 5d008cde..407af947 100644
--- a/src/glade-project-view.c
+++ b/src/glade-project-view.c
@@ -522,7 +522,7 @@ glade_project_view_cell_function (GtkTreeViewColumn *tree_column,
GtkTreeIter *iter,
gpointer data)
{
- gboolean is_icon = GPOINTER_TO_INT (data);
+ gboolean is_icon = GPOINTER_TO_INT (data);
GladeWidget *widget;
gtk_tree_model_get (tree_model, iter, WIDGET_COLUMN, &widget, -1);
@@ -533,19 +533,14 @@ glade_project_view_cell_function (GtkTreeViewColumn *tree_column,
g_return_if_fail (widget->name != NULL);
g_return_if_fail (widget->widget_class != NULL);
- g_return_if_fail (GPOINTER_TO_INT (widget->widget_class) > 5000);
g_return_if_fail (widget->widget_class->name != NULL);
g_return_if_fail (widget->widget_class->icon != NULL);
if (is_icon)
{
- if (gtk_image_get_storage_type
- (GTK_IMAGE (widget->widget_class->icon)) != GTK_IMAGE_PIXBUF)
- return;
-
- g_object_set (G_OBJECT (cell), "pixbuf",
- gtk_image_get_pixbuf
- (GTK_IMAGE (widget->widget_class->icon)), NULL);
+ g_object_set (G_OBJECT (cell),
+ "pixbuf", widget->widget_class->icon,
+ NULL);
}
else
{
diff --git a/src/glade-utils.c b/src/glade-utils.c
index 05d8a547..3cb3d64b 100644
--- a/src/glade-utils.c
+++ b/src/glade-utils.c
@@ -857,6 +857,17 @@ glade_util_has_selection (GtkWidget *widget)
return g_list_find (glade_util_selection, widget) != NULL;
}
+/**
+ * glade_util_get_selectoin:
+ *
+ * Returns: The list of selected #GtkWidgets
+ */
+GList *
+glade_util_get_selection ()
+{
+ return glade_util_selection;
+}
+
/*
* taken from gtk... maybe someday we can convince them to
* expose gtk_container_get_all_children
diff --git a/src/glade-utils.h b/src/glade-utils.h
index 6a0229f0..59a02470 100644
--- a/src/glade-utils.h
+++ b/src/glade-utils.h
@@ -45,6 +45,7 @@ void glade_util_add_selection (GtkWidget *widget);
void glade_util_remove_selection (GtkWidget *widget);
gboolean glade_util_has_selection (GtkWidget *widget);
void glade_util_clear_selection (void);
+GList *glade_util_get_selection (void);
void glade_util_queue_draw_nodes (GdkWindow *window);
GladeWidget *glade_util_get_parent (GtkWidget *w);
diff --git a/src/glade-widget-class.c b/src/glade-widget-class.c
index 7fd6293f..3353718a 100644
--- a/src/glade-widget-class.c
+++ b/src/glade-widget-class.c
@@ -47,6 +47,7 @@
/* hash table that will contain all the GtkWidgetClass'es created, indexed by its name */
static GHashTable *widget_classes = NULL;
+#define GLADE_ICON_SIZE 24
static void
glade_widget_class_free_child (GladeSupportedChild *child)
@@ -79,6 +80,9 @@ glade_widget_class_free (GladeWidgetClass *widget_class)
g_list_foreach (widget_class->signals, (GFunc) glade_signal_free, NULL);
g_list_free (widget_class->signals);
+
+ if (widget_class->icon)
+ g_object_unref (G_OBJECT (widget_class->icon));
}
static GList *
@@ -267,19 +271,43 @@ glade_widget_class_list_signals (GladeWidgetClass *class)
return signals;
}
-static GtkWidget *
+static GdkPixbuf *
glade_widget_class_create_icon (GladeWidgetClass *class)
{
- GtkWidget *icon = NULL;
- gchar *icon_path;
+ GdkPixbuf *icon = NULL;
+ GError *error = NULL;
+ gchar *icon_path;
if (class->generic_name)
{
- icon_path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s.png", glade_pixmaps_dir, class->generic_name);
- icon = gtk_image_new_from_file (icon_path);
+ icon_path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s.png",
+ glade_pixmaps_dir,
+
+ class->generic_name);
+ if ((icon =
+ gdk_pixbuf_new_from_file (icon_path, &error)) == NULL)
+ {
+ g_warning ("Unable to load icon %s (%s)",
+ class->name, error->message);
+ error = (g_error_free (error), NULL);
+
+ /* Load missing image to the stock
+ */
+ if ((icon = gtk_icon_theme_load_icon
+ (gtk_icon_theme_get_default (),
+ GTK_STOCK_MISSING_IMAGE,
+ GLADE_ICON_SIZE,
+ GTK_ICON_LOOKUP_USE_BUILTIN, &error)) == NULL)
+ {
+ g_critical ("Unable to load an icon for "
+ "%s from stock (%s)",
+ class->name,
+ error->message);
+ error = (g_error_free (error), NULL);
+ }
+ }
g_free (icon_path);
}
-
return icon;
}
diff --git a/src/glade-widget-class.h b/src/glade-widget-class.h
index 38d0c7f6..4bd4143f 100644
--- a/src/glade-widget-class.h
+++ b/src/glade-widget-class.h
@@ -44,7 +44,7 @@ struct _GladeWidgetClass
gchar *name; /* Name of the widget, for example GtkButton */
- GtkWidget *icon; /* The GtkImage icon for the widget */
+ GdkPixbuf *icon; /* The GdkPixbuf icon for the widget */
gchar *generic_name; /* Use to generate names of new widgets, for
* example "button" so that we generate button1,
diff --git a/src/main.c b/src/main.c
index 42a948ef..a8eaa681 100644
--- a/src/main.c
+++ b/src/main.c
@@ -173,6 +173,13 @@ main (int argc, char *argv[])
gtk_init (&argc, &argv);
+ /* XXX This is a hack to make up for a bug in GTK+;
+ * gtk_icon_theme_get_default() wont return anything
+ * untill an `ensure_default_icons ();' is provoked
+ * (gtk_icon_factory_lookup_default does this).
+ */
+ gtk_icon_factory_lookup_default ("");
+
glade_setup_log_handlers ();
if (!glade_init ())