aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2003-09-27 18:17:12 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2003-09-27 18:17:12 +0800
commiteed2331e611eb281440c1bcb5f76b2e547f1e0a7 (patch)
tree5b19372449ec82830ffb679293de05d498e6232f
parent66a44625b35868a79da71ec78de700d9b8ff7619 (diff)
downloadgsoc2013-epiphany-eed2331e611eb281440c1bcb5f76b2e547f1e0a7.tar
gsoc2013-epiphany-eed2331e611eb281440c1bcb5f76b2e547f1e0a7.tar.gz
gsoc2013-epiphany-eed2331e611eb281440c1bcb5f76b2e547f1e0a7.tar.bz2
gsoc2013-epiphany-eed2331e611eb281440c1bcb5f76b2e547f1e0a7.tar.lz
gsoc2013-epiphany-eed2331e611eb281440c1bcb5f76b2e547f1e0a7.tar.xz
gsoc2013-epiphany-eed2331e611eb281440c1bcb5f76b2e547f1e0a7.tar.zst
gsoc2013-epiphany-eed2331e611eb281440c1bcb5f76b2e547f1e0a7.zip
Use gtkicontheme, and use it also for mime icons.
2003-09-27 Marco Pesenti Gritti <marco@gnome.org> * embed/mozilla/ContentHandler.cpp: * lib/ephy-gui.c: (make_mime_name), (ephy_gui_get_pixbuf_from_mime_type): * lib/ephy-gui.h: * lib/widgets/ephy-spinner.c: (ephy_spinner_init), (ephy_spinner_theme_changed), (ephy_spinner_load_images), (ephy_spinner_finalize): * src/ephy-shell.c: (ephy_shell_init): Use gtkicontheme, and use it also for mime icons.
-rw-r--r--ChangeLog13
-rw-r--r--embed/mozilla/ContentHandler.cpp6
-rw-r--r--lib/ephy-gui.c72
-rw-r--r--lib/ephy-gui.h3
-rw-r--r--lib/widgets/ephy-spinner.c35
-rw-r--r--src/ephy-shell.c25
6 files changed, 127 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index d08de16b4..cb3bfda04 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2003-09-27 Marco Pesenti Gritti <marco@gnome.org>
+
+ * embed/mozilla/ContentHandler.cpp:
+ * lib/ephy-gui.c: (make_mime_name),
+ (ephy_gui_get_pixbuf_from_mime_type):
+ * lib/ephy-gui.h:
+ * lib/widgets/ephy-spinner.c: (ephy_spinner_init),
+ (ephy_spinner_theme_changed), (ephy_spinner_load_images),
+ (ephy_spinner_finalize):
+ * src/ephy-shell.c: (ephy_shell_init):
+
+ Use gtkicontheme, and use it also for mime icons.
+
2003-09-26 Marco Pesenti Gritti <marco@gnome.org>
* data/epiphany.schemas.in:
diff --git a/embed/mozilla/ContentHandler.cpp b/embed/mozilla/ContentHandler.cpp
index e1a571bce..49152e586 100644
--- a/embed/mozilla/ContentHandler.cpp
+++ b/embed/mozilla/ContentHandler.cpp
@@ -553,6 +553,7 @@ MimeAskActionDialog::MimeAskActionDialog(GContentHandler *aContentHandler,
mContentHandler(aContentHandler),
mParent(aParentWidget)
{
+ GdkPixbuf *mime_icon;
GtkWidget *label;
GtkWidget *dialogWidget;
const char *description;
@@ -566,8 +567,9 @@ MimeAskActionDialog::MimeAskActionDialog(GContentHandler *aContentHandler,
GtkWidget *aMimeIcon = glade_xml_get_widget (mGXml,
"mime_ask_action_icon");
- gtk_image_set_from_file(GTK_IMAGE(aMimeIcon),
- gnome_vfs_mime_get_icon(aMimeType));
+ mime_icon = ephy_gui_get_pixbuf_from_mime_type (aMimeType, 32);
+ gtk_image_set_from_pixbuf (GTK_IMAGE(aMimeIcon), mime_icon);
+ g_object_unref (mime_icon);
description = gnome_vfs_mime_get_description (aMimeType);
if (!description) description = aMimeType;
diff --git a/lib/ephy-gui.c b/lib/ephy-gui.c
index 81077d140..af959b5aa 100644
--- a/lib/ephy-gui.c
+++ b/lib/ephy-gui.c
@@ -113,3 +113,75 @@ ephy_gui_help (GtkWindow *parent,
g_error_free (err);
}
}
+
+#define ICON_NAME_MIME_PREFIX "gnome-mime-"
+
+static char *
+make_mime_name (const char *mime_type)
+{
+ char *mime_type_without_slashes, *icon_name;
+ char *p;
+
+ if (mime_type == NULL)
+ {
+ return NULL;
+ }
+
+ mime_type_without_slashes = g_strdup (mime_type);
+
+ while ((p = strchr(mime_type_without_slashes, '/')) != NULL)
+ *p = '-';
+
+ icon_name = g_strconcat (ICON_NAME_MIME_PREFIX, mime_type_without_slashes, NULL);
+ g_free (mime_type_without_slashes);
+
+ return icon_name;
+}
+
+GdkPixbuf *
+ephy_gui_get_pixbuf_from_mime_type (const char *mime_type,
+ int size)
+{
+ GdkPixbuf *pixbuf;
+ GtkIconInfo *icon_info;
+ GtkIconTheme *icon_theme;
+ const char *icon;
+ char *icon_name;
+
+ icon_name = make_mime_name (mime_type);
+
+ icon_theme = gtk_icon_theme_get_default ();
+ g_return_val_if_fail (icon_theme != NULL, NULL);
+
+ icon_info = gtk_icon_theme_lookup_icon
+ (icon_theme, icon_name, size, -1);
+ g_free (icon_name);
+
+ /* try without specific size */
+ if (icon_info == NULL)
+ {
+ icon_info = gtk_icon_theme_lookup_icon
+ (icon_theme, icon_name, -1, -1);
+ }
+
+ /* no icon found */
+ if (icon_info == NULL) return NULL;
+
+ icon = gtk_icon_info_get_filename (icon_info);
+ pixbuf = gdk_pixbuf_new_from_file (icon, NULL);
+ g_return_val_if_fail (pixbuf != NULL, NULL);
+
+ if (size != gtk_icon_info_get_base_size (icon_info))
+ {
+ GdkPixbuf *tmp;
+
+ tmp = gdk_pixbuf_scale_simple (pixbuf, size, size,
+ GDK_INTERP_BILINEAR);
+ g_object_unref (pixbuf);
+ pixbuf = tmp;
+ }
+
+ gtk_icon_info_free (icon_info);
+
+ return pixbuf;
+}
diff --git a/lib/ephy-gui.h b/lib/ephy-gui.h
index ee2eeb155..17063388d 100644
--- a/lib/ephy-gui.h
+++ b/lib/ephy-gui.h
@@ -38,6 +38,9 @@ gboolean ephy_gui_confirm_overwrite_file (GtkWidget *parent,
void ephy_gui_help (GtkWindow *parent,
const char *file_name,
const char *link_id);
+
+GdkPixbuf *ephy_gui_get_pixbuf_from_mime_type (const char *mime_type,
+ int size);
G_END_DECLS
#endif
diff --git a/lib/widgets/ephy-spinner.c b/lib/widgets/ephy-spinner.c
index 09c0c8529..2f4e9e3d9 100644
--- a/lib/widgets/ephy-spinner.c
+++ b/lib/widgets/ephy-spinner.c
@@ -37,7 +37,7 @@
#include "ephy-file-helpers.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <libgnomeui/gnome-icon-theme.h>
+#include <gtk/gtkicontheme.h>
#define spinner_DEFAULT_TIMEOUT 100 /* Milliseconds Per Frame */
@@ -46,7 +46,7 @@
struct EphySpinnerDetails {
GList *image_list;
GdkPixbuf *quiescent_pixbuf;
- GnomeIconTheme *icon_theme;
+ GtkIconTheme *icon_theme;
int max_frame;
int delay;
@@ -62,7 +62,7 @@ static void ephy_spinner_init (EphySpinner *spinner);
static void ephy_spinner_load_images (EphySpinner *spinner);
static void ephy_spinner_unload_images (EphySpinner *spinner);
static void ephy_spinner_remove_update_callback (EphySpinner *spinner);
-static void ephy_spinner_theme_changed (GnomeIconTheme *icon_theme,
+static void ephy_spinner_theme_changed (GtkIconTheme *icon_theme,
EphySpinner *spinner);
static GObjectClass *parent_class = NULL;
@@ -178,7 +178,7 @@ ephy_spinner_init (EphySpinner *spinner)
spinner->details = EPHY_SPINNER_GET_PRIVATE (spinner);
spinner->details->delay = spinner_DEFAULT_TIMEOUT;
- spinner->details->icon_theme = gnome_icon_theme_new ();
+ spinner->details->icon_theme = gtk_icon_theme_get_default ();
g_signal_connect (spinner->details->icon_theme,
"changed",
G_CALLBACK (ephy_spinner_theme_changed),
@@ -190,7 +190,7 @@ ephy_spinner_init (EphySpinner *spinner)
/* handler for handling theme changes */
static void
-ephy_spinner_theme_changed (GnomeIconTheme *icon_theme, EphySpinner *spinner)
+ephy_spinner_theme_changed (GtkIconTheme *icon_theme, EphySpinner *spinner)
{
gtk_widget_hide (GTK_WIDGET (spinner));
ephy_spinner_load_images (spinner);
@@ -417,20 +417,25 @@ static void
ephy_spinner_load_images (EphySpinner *spinner)
{
int grid_width, grid_height, x, y, size;
- char *icon;
+ const char *icon;
GdkPixbuf *icon_pixbuf, *pixbuf;
GList *image_list;
+ GtkIconInfo *icon_info;
ephy_spinner_unload_images (spinner);
/* Load the animation */
- icon = gnome_icon_theme_lookup_icon (spinner->details->icon_theme,
- "gnome-spinner", -1, NULL, &size);
- if (icon == NULL) {
+ icon_info = gtk_icon_theme_lookup_icon (spinner->details->icon_theme,
+ "gnome-spinner", -1, 0);
+ if (icon_info == NULL) {
g_warning ("Throbber animation not found");
return;
}
+ size = gtk_icon_info_get_base_size (icon_info);
+ icon = gtk_icon_info_get_filename (icon_info);
+ g_return_if_fail (icon_info != NULL);
+
icon_pixbuf = gdk_pixbuf_new_from_file (icon, NULL);
grid_width = gdk_pixbuf_get_width (icon_pixbuf);
grid_height = gdk_pixbuf_get_height (icon_pixbuf);
@@ -453,22 +458,24 @@ ephy_spinner_load_images (EphySpinner *spinner)
spinner->details->image_list = g_list_reverse (image_list);
spinner->details->max_frame = g_list_length (spinner->details->image_list);
- g_free (icon);
+ gtk_icon_info_free (icon_info);
g_object_unref (icon_pixbuf);
/* Load the rest icon */
- icon = gnome_icon_theme_lookup_icon (spinner->details->icon_theme,
- "gnome-spinner-rest", -1, NULL, &size);
+ icon_info = gtk_icon_theme_lookup_icon (spinner->details->icon_theme,
+ "gnome-spinner-rest", -1, -1);
if (icon == NULL) {
g_warning ("Throbber rest icon not found");
return;
}
+ size = gtk_icon_info_get_base_size (icon_info);
+ icon = gtk_icon_info_get_filename (icon_info);
icon_pixbuf = gdk_pixbuf_new_from_file (icon, NULL);
spinner->details->quiescent_pixbuf = scale_to_real_size (spinner, icon_pixbuf);
g_object_unref (icon_pixbuf);
- g_free (icon);
+ gtk_icon_info_free (icon_info);
}
/*
@@ -513,8 +520,6 @@ ephy_spinner_finalize (GObject *object)
ephy_spinner_remove_update_callback (spinner);
ephy_spinner_unload_images (spinner);
- g_object_unref (spinner->details->icon_theme);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index a1c72d89a..93041eadd 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -53,7 +53,7 @@
#include <gtk/gtkmessagedialog.h>
#include <dirent.h>
#include <libgnomevfs/gnome-vfs-init.h>
-#include <libgnomeui/gnome-icon-theme.h>
+#include <gtk/gtkicontheme.h>
#include <glade/glade-init.h>
#ifdef ENABLE_NAUTILUS_VIEW
@@ -202,8 +202,9 @@ ephy_shell_init (EphyShell *gs)
{
EphyEmbedSingle *single;
EphyShell **ptr = &ephy_shell;
- GnomeIconTheme *icon_theme;
- char *file;
+ GtkIconTheme *icon_theme;
+ GtkIconInfo *icon_info;
+ const char *icon_file;
gs->priv = EPHY_SHELL_GET_PRIVATE (gs);
@@ -257,15 +258,19 @@ ephy_shell_init (EphyShell *gs)
ephy_shell_load_plugins (gs);
- icon_theme = gnome_icon_theme_new ();
- file = gnome_icon_theme_lookup_icon (icon_theme, "web-browser",
- -1, NULL, NULL);
- g_object_unref (icon_theme);
+ /* FIXME listen on icon changes */
+ icon_theme = gtk_icon_theme_get_default ();
+ icon_info = gtk_icon_theme_lookup_icon (icon_theme, "web-browser", -1, -1);
- if (file)
+ if (icon_info)
{
- gtk_window_set_default_icon_from_file (file, NULL);
- g_free (file);
+
+ icon_file = gtk_icon_info_get_filename (icon_info);
+ g_return_if_fail (icon_file != NULL);
+
+ gtk_window_set_default_icon_from_file (icon_file, NULL);
+
+ gtk_icon_info_free (icon_info);
}
else
{