aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2002-02-22 10:18:05 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2002-02-22 10:18:05 +0800
commitea9489d8944c6c4a7095e92a47991df421140a4b (patch)
tree474af4ad21bc7bcd8684bd6151b6b16408e067dc
parent5416d54dcfb902d7c84e8d16585a68822f54db0f (diff)
downloadgsoc2013-evolution-ea9489d8944c6c4a7095e92a47991df421140a4b.tar.gz
gsoc2013-evolution-ea9489d8944c6c4a7095e92a47991df421140a4b.tar.zst
gsoc2013-evolution-ea9489d8944c6c4a7095e92a47991df421140a4b.zip
Set the icons for all the "New..." menu items from the specified one in
* e-shell-user-creatable-items-handler.c (ensure_menu_items): Set the icons for all the "New..." menu items from the specified one in the type definitions. * e-activity-handler.c (create_gdk_pixbuf_from_corba_icon): Removed. (impl_operationStarted): Just use `e_new_gdk_pixbuf_from_corba_icon()'. * e-shell-corba-icon-utils.c (e_new_gdk_pixbuf_from_corba_icon): New. svn path=/trunk/; revision=15786
-rw-r--r--shell/ChangeLog14
-rw-r--r--shell/e-activity-handler.c46
-rw-r--r--shell/e-shell-corba-icon-utils.c66
-rw-r--r--shell/e-shell-corba-icon-utils.h4
-rw-r--r--shell/e-shell-user-creatable-items-handler.c21
5 files changed, 97 insertions, 54 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 8449daf4ec..500a31dea3 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,17 @@
+2002-02-21 Ettore Perazzoli <ettore@ximian.com>
+
+ * e-shell-user-creatable-items-handler.c (ensure_menu_items): Set
+ the icons for all the "New..." menu items from the specified one
+ in the type definitions.
+
+ * e-activity-handler.c (create_gdk_pixbuf_from_corba_icon):
+ Removed.
+ (impl_operationStarted): Just use
+ `e_new_gdk_pixbuf_from_corba_icon()'.
+
+ * e-shell-corba-icon-utils.c (e_new_gdk_pixbuf_from_corba_icon):
+ New.
+
2002-02-20 Ettore Perazzoli <ettore@ximian.com>
[Fix #20311, new window from Shortcuts should not show the folder
diff --git a/shell/e-activity-handler.c b/shell/e-activity-handler.c
index 98f75619aa..9e85e44afb 100644
--- a/shell/e-activity-handler.c
+++ b/shell/e-activity-handler.c
@@ -26,6 +26,8 @@
#include "e-activity-handler.h"
+#include "e-shell-corba-icon-utils.h"
+
#include <gtk/gtksignal.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -64,48 +66,6 @@ struct _EActivityHandlerPrivate {
/* Utility functions. */
-static GdkPixbuf *
-create_gdk_pixbuf_from_corba_icon (const GNOME_Evolution_Icon *icon)
-{
- GdkPixbuf *pixbuf;
- GdkPixbuf *scaled_pixbuf;
- unsigned char *p;
- int src_offset;
- int i, j;
- int rowstride;
- int total_width;
-
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, icon->hasAlpha, 8, icon->width, icon->height);
-
- if (icon->hasAlpha)
- total_width = 4 * icon->width;
- else
- total_width = 3 * icon->width;
-
- rowstride = gdk_pixbuf_get_rowstride (pixbuf);
- src_offset = 0;
- p = gdk_pixbuf_get_pixels (pixbuf);
-
- for (i = 0; i < icon->height; i++) {
- for (j = 0; j < total_width; j++)
- p[j] = icon->rgbaData._buffer[src_offset ++];
- p += rowstride;
- }
-
- if (icon->width == ICON_SIZE && icon->height == ICON_SIZE)
- return pixbuf;
-
- scaled_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, icon->hasAlpha, 8, ICON_SIZE, ICON_SIZE);
- gdk_pixbuf_scale (pixbuf, scaled_pixbuf,
- 0, 0, ICON_SIZE, ICON_SIZE,
- 0, 0, (double) ICON_SIZE / icon->width, (double) ICON_SIZE / icon->height,
- GDK_INTERP_HYPER);
-
- gdk_pixbuf_unref (pixbuf);
-
- return scaled_pixbuf;
-}
-
static unsigned int
get_new_activity_id (EActivityHandler *activity_handler)
{
@@ -421,7 +381,7 @@ impl_operationStarted (PortableServer_Servant servant,
if (icon->_length > 1)
g_warning ("Animated icons are not supported for activities (yet).");
- icon_pixbuf = create_gdk_pixbuf_from_corba_icon (icon->_buffer);
+ icon_pixbuf = e_new_gdk_pixbuf_from_corba_icon (icon->_buffer, ICON_SIZE, ICON_SIZE);
activity_id = get_new_activity_id (activity_handler);
diff --git a/shell/e-shell-corba-icon-utils.c b/shell/e-shell-corba-icon-utils.c
index 53ce1ecc81..0174213ecc 100644
--- a/shell/e-shell-corba-icon-utils.c
+++ b/shell/e-shell-corba-icon-utils.c
@@ -140,3 +140,69 @@ e_new_corba_animated_icon_from_pixbuf_array (GdkPixbuf **pixbuf_array)
return animated_icon;
}
+
+
+/**
+ * e_new_gdk_pixbuf_from_corba_icon:
+ * @icon: A CORBA Evolution::Icon.
+ * @scaled_width: Width of the GdkPixbuf to obtain.
+ * @scaled_height: Width of the GdkPixbuf to obtain.
+ *
+ * If @scaled_width or @scaled_height is -1, do not scale.
+ *
+ * Create a GdkPixbuf for the specified CORBA @icon.
+ *
+ * Return value: The newly created GdkPixbuf.
+ **/
+GdkPixbuf *
+e_new_gdk_pixbuf_from_corba_icon (const GNOME_Evolution_Icon *icon,
+ int scaled_width,
+ int scaled_height)
+{
+ GdkPixbuf *pixbuf;
+ GdkPixbuf *scaled_pixbuf;
+ unsigned char *p;
+ int src_offset;
+ int i, j;
+ int rowstride;
+ int total_width;
+
+ g_return_val_if_fail (icon != NULL, NULL);
+
+ if (scaled_width == -1)
+ scaled_width = icon->width;
+
+ if (scaled_height == -1)
+ scaled_height = icon->height;
+
+ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, icon->hasAlpha, 8, icon->width, icon->height);
+
+ if (icon->hasAlpha)
+ total_width = 4 * icon->width;
+ else
+ total_width = 3 * icon->width;
+
+ rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+ src_offset = 0;
+ p = gdk_pixbuf_get_pixels (pixbuf);
+
+ for (i = 0; i < icon->height; i++) {
+ for (j = 0; j < total_width; j++)
+ p[j] = icon->rgbaData._buffer[src_offset ++];
+ p += rowstride;
+ }
+
+ if (icon->width == scaled_width && icon->height == scaled_height)
+ return pixbuf;
+
+ scaled_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, icon->hasAlpha, 8, scaled_width, scaled_height);
+ gdk_pixbuf_scale (pixbuf, scaled_pixbuf,
+ 0, 0, scaled_width, scaled_height,
+ 0, 0, (double) scaled_width / icon->width, (double) scaled_height / icon->height,
+ GDK_INTERP_HYPER);
+
+ gdk_pixbuf_unref (pixbuf);
+
+ return scaled_pixbuf;
+}
+
diff --git a/shell/e-shell-corba-icon-utils.h b/shell/e-shell-corba-icon-utils.h
index ddc68f086c..cc9da3c24b 100644
--- a/shell/e-shell-corba-icon-utils.h
+++ b/shell/e-shell-corba-icon-utils.h
@@ -33,4 +33,8 @@ void e_store_corba_icon_from_pixbuf (GdkP
GNOME_Evolution_Icon *e_new_corba_icon_from_pixbuf (GdkPixbuf *pixbuf);
GNOME_Evolution_AnimatedIcon *e_new_corba_animated_icon_from_pixbuf_array (GdkPixbuf **pixbuf_array);
+GdkPixbuf *e_new_gdk_pixbuf_from_corba_icon (const GNOME_Evolution_Icon *icon,
+ int scaled_width,
+ int scaled_height);
+
#endif
diff --git a/shell/e-shell-user-creatable-items-handler.c b/shell/e-shell-user-creatable-items-handler.c
index cafd074605..8ce99341ec 100644
--- a/shell/e-shell-user-creatable-items-handler.c
+++ b/shell/e-shell-user-creatable-items-handler.c
@@ -26,6 +26,8 @@
#include "e-shell-user-creatable-items-handler.h"
+#include "e-shell-corba-icon-utils.h"
+
#include "widgets/misc/e-combo-button.h"
#include "e-util/e-corba-utils.h"
@@ -200,7 +202,11 @@ ensure_menu_items (EShellUserCreatableItemsHandler *handler)
item->label = type->menuDescription;
item->shortcut = type->menuShortcut;
item->verb = create_verb_from_component_number_and_type_id (component_num, type->id);
- item->icon = NULL;
+
+ if (type->icon.width == 0 || type->icon.height == 0)
+ item->icon = NULL;
+ else
+ item->icon = e_new_gdk_pixbuf_from_corba_icon (& type->icon, 16, 16);
menu_items = g_slist_prepend (menu_items, item);
}
@@ -544,10 +550,6 @@ shell_view_view_changed_callback (EShellView *shell_view,
gtk_widget_set_sensitive (combo_button_widget, TRUE);
- /* FIXME: This is temporary. We should just always say "New" once we
- have the icons for all the actions. */
- e_combo_button_set_label (E_COMBO_BUTTON (combo_button_widget), default_menu_item->label);
-
e_combo_button_set_icon (E_COMBO_BUTTON (combo_button_widget), default_menu_item->icon);
}
@@ -653,12 +655,9 @@ e_shell_user_creatable_items_handler_attach_menus (EShellUserCreatableItemsHandl
priv = handler->priv;
- /* FIXME: Re-enable this. */
- if (0) {
- setup_toolbar_button (handler, shell_view);
- gtk_signal_connect (GTK_OBJECT (shell_view), "view_changed",
- GTK_SIGNAL_FUNC (shell_view_view_changed_callback), handler);
- }
+ setup_toolbar_button (handler, shell_view);
+ gtk_signal_connect (GTK_OBJECT (shell_view), "view_changed",
+ GTK_SIGNAL_FUNC (shell_view_view_changed_callback), handler);
ensure_menu_xml (handler);