aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2007-04-20 02:53:33 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2007-04-20 02:53:33 +0800
commit64977cb1bcc55bf4c7c0fc38cd3d047b1e6a25c6 (patch)
tree4ebe95239bef43cb97c0e46aa8194d44e6c88be6 /e-util
parentbb05f6e6d0541bf29c8dde4e264cc7c23ba52fbb (diff)
downloadgsoc2013-evolution-64977cb1bcc55bf4c7c0fc38cd3d047b1e6a25c6.tar
gsoc2013-evolution-64977cb1bcc55bf4c7c0fc38cd3d047b1e6a25c6.tar.gz
gsoc2013-evolution-64977cb1bcc55bf4c7c0fc38cd3d047b1e6a25c6.tar.bz2
gsoc2013-evolution-64977cb1bcc55bf4c7c0fc38cd3d047b1e6a25c6.tar.lz
gsoc2013-evolution-64977cb1bcc55bf4c7c0fc38cd3d047b1e6a25c6.tar.xz
gsoc2013-evolution-64977cb1bcc55bf4c7c0fc38cd3d047b1e6a25c6.tar.zst
gsoc2013-evolution-64977cb1bcc55bf4c7c0fc38cd3d047b1e6a25c6.zip
Massive code cleanup (bug #429422)
svn path=/trunk/; revision=33432
Diffstat (limited to 'e-util')
-rw-r--r--e-util/ChangeLog60
-rw-r--r--e-util/Makefile.am2
-rw-r--r--e-util/e-dialog-widgets.c87
-rw-r--r--e-util/e-gtk-utils.c223
-rw-r--r--e-util/e-gtk-utils.h49
-rw-r--r--e-util/e-gui-utils.c90
-rw-r--r--e-util/e-gui-utils.h6
-rw-r--r--e-util/e-icon-factory.c153
-rw-r--r--e-util/e-mktemp.c2
-rw-r--r--e-util/e-sorter-array.c4
-rw-r--r--e-util/e-util.c543
-rw-r--r--e-util/e-util.h190
-rw-r--r--e-util/e-xml-utils.c1
-rw-r--r--e-util/eggtrayicon.c3
14 files changed, 315 insertions, 1098 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 2a036e75f5..e56b6d878c 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,63 @@
+2007-04-19 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #429422
+
+ * Makefile.am:
+ Remove e-gtk-utils.h and e-gtk-utils.c.
+
+ * e-mktemp.c (get_dir):
+ Use g_mkdir_with_parents() instead of e_util_mkdir_hier().
+
+ * e-gui-utils.[ch]:
+ Remove e_create_image_widget() and e_button_new_with_stock_icon()
+
+ * e-gui-utils.c (e_icon_for_mime_type):
+ Use GtkIconTheme instead of GnomeIconTheme.
+
+ * eggtrayicon.c (gtk_status_icon_init):
+ Use g_object_ref_sink() instead of gtk_object_sink().
+
+ * e-sorter-array.c (esa_sort):
+ Use g_qsort_with_data() instead of e_sort().
+
+ * e-util.[ch]:
+ Some cosmetic cleanups.
+ Remove some unused or redundant symbols:
+ E_MAKE_X_TYPE
+ GET_STRING_ARRAY_FROM_ELLIPSIS
+ GET_DUPLICATED_STRING_ARRAY_FROM_ELLIPSIS
+ E_OBJECT_CLASS_ADD_SIGNALS
+ E_OBJECT_CLASS_TYPE
+ e_strdup_strip()
+ e_free_object_list()
+ e_free_object_slist()
+ e_free_string_list()
+ e_free_string_slist()
+ e_read_file()
+ e_write_file_mkstemp()
+ e_read_uri()
+ e_strsplit()
+ e_create_directory()
+ e_sort()
+ e_strdupv()
+
+ * e-util.c (e_format_number), (e_format_number_as_float):
+ e_free_string_list() is dead; just do it manually.
+
+ * e-icon-factory.c:
+ Use GtkIconTheme instead of GnomeIconTheme.
+ Use GStaticMutex instead of pthread_mutex_t.
+ Allocate icons with GSlice.
+
+ * e-xml-utils.c:
+ Include missing header file(s).
+
+ * e-dialog-widget.c:
+ Drop support for GnomePropertyBox; nothing uses it.
+
+ * e-dialog-widget.c (e_dialog_dateedit_get):
+ Use gnome_date_edit_get_time() instead of gnome_date_edit_get_date().
+
2007-03-20 Matthew Barnes <mbarnes@redhat.com>
** Fixes part of bug #419524
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index 75f9809337..d78143c23d 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -52,7 +52,6 @@ eutilinclude_HEADERS = \
e-event.h \
e-folder-map.h \
e-fsutils.h \
- e-gtk-utils.h \
e-gui-utils.h \
e-html-utils.h \
e-icon-factory.h \
@@ -91,7 +90,6 @@ libeutil_la_SOURCES = \
e-event.c \
e-folder-map.c \
e-fsutils.c \
- e-gtk-utils.c \
e-gui-utils.c \
e-html-utils.c \
e-icon-factory.c \
diff --git a/e-util/e-dialog-widgets.c b/e-util/e-dialog-widgets.c
index 6d17a3d1f1..205cf97e26 100644
--- a/e-util/e-dialog-widgets.c
+++ b/e-util/e-dialog-widgets.c
@@ -33,7 +33,6 @@
#include <gtk/gtksignal.h>
#include <gtk/gtkspinbutton.h>
#include <libgnomeui/gnome-dateedit.h>
-#include <libgnomeui/gnome-propertybox.h>
#include "e-dialog-widgets.h"
@@ -116,44 +115,19 @@ index_to_value (const int *value_map, int index)
return -1;
}
-/* Callback for the "toggled" signal of toggle buttons */
-static void
-toggled_cb (GtkToggleButton *toggle, gpointer data)
-{
- GnomePropertyBox *pbox;
-
- pbox = GNOME_PROPERTY_BOX (data);
-
- /* For radio buttons, we only notify the property box if the button is
- * active, because we'll get one call for each of the changed buttons in
- * the radio group.
- */
- if (!GTK_IS_RADIO_BUTTON (toggle) || toggle->active)
- gnome_property_box_changed (pbox);
-}
-
/* Hooks a radio button group */
static void
hook_radio (GtkWidget *dialog, GtkRadioButton *radio, gpointer value_var, gpointer info)
{
const int *value_map;
- GSList *group, *l;
int *value;
- group = gtk_radio_button_get_group (radio);
-
/* Set the value */
value = (int *) value_var;
value_map = (const int *) info;
e_dialog_radio_set (GTK_WIDGET (radio), *value, value_map);
-
- /* Hook to changed */
-
- if (GNOME_IS_PROPERTY_BOX (dialog))
- for (l = group; l; l = l->next)
- g_signal_connect (l->data, "toggled", G_CALLBACK (toggled_cb), dialog);
}
/* Gets the value of a radio button group */
@@ -169,16 +143,6 @@ get_radio_value (GtkRadioButton *radio, gpointer value_var, gpointer info)
*value = e_dialog_radio_get (GTK_WIDGET (radio), value_map);
}
-/* Callback for the "activate" signal of menu items */
-static void
-activate_cb (GtkMenuItem *item, gpointer data)
-{
- GnomePropertyBox *pbox;
-
- pbox = GNOME_PROPERTY_BOX (data);
- gnome_property_box_changed (pbox);
-}
-
/* Hooks an option menu */
static void
hook_option_menu (GtkWidget *dialog, GtkOptionMenu *omenu, gpointer value_var, gpointer info)
@@ -192,18 +156,6 @@ hook_option_menu (GtkWidget *dialog, GtkOptionMenu *omenu, gpointer value_var, g
value_map = (const int *) info;
e_dialog_option_menu_set (GTK_WIDGET (omenu), *value, value_map);
-
- /* Hook to changed */
-
- if (GNOME_IS_PROPERTY_BOX (dialog)) {
- GtkMenu *menu;
- GList *l;
-
- menu = GTK_MENU (gtk_option_menu_get_menu (omenu));
-
- for (l = GTK_MENU_SHELL (menu)->children; l; l = l->next)
- g_signal_connect (l->data, "activate", G_CALLBACK (activate_cb), dialog);
- }
}
/* Gets the value of an option menu */
@@ -229,11 +181,6 @@ hook_toggle (GtkWidget *dialog, GtkToggleButton *toggle, gpointer value_var, gpo
value = (gboolean *) value_var;
e_dialog_toggle_set (GTK_WIDGET (toggle), *value);
-
- /* Hook to changed */
-
- if (GNOME_IS_PROPERTY_BOX (dialog))
- g_signal_connect (toggle, "toggled", G_CALLBACK (toggled_cb), dialog);
}
/* Gets the value of a toggle button */
@@ -246,16 +193,6 @@ get_toggle_value (GtkToggleButton *toggle, gpointer value_var, gpointer info)
*value = e_dialog_toggle_get (GTK_WIDGET (toggle));
}
-/* Callback for the "value_changed" signal of the adjustment of a spin button */
-static void
-value_changed_cb (GtkAdjustment *adj, gpointer data)
-{
- GnomePropertyBox *pbox;
-
- pbox = GNOME_PROPERTY_BOX (data);
- gnome_property_box_changed (pbox);
-}
-
/* Hooks a spin button */
static void
hook_spin_button (GtkWidget *dialog, GtkSpinButton *spin, gpointer value_var, gpointer info)
@@ -271,9 +208,6 @@ hook_spin_button (GtkWidget *dialog, GtkSpinButton *spin, gpointer value_var, gp
/* Hook to changed */
adj = gtk_spin_button_get_adjustment (spin);
-
- if (GNOME_IS_PROPERTY_BOX (dialog))
- g_signal_connect (adj, "value_changed", G_CALLBACK (value_changed_cb), dialog);
}
/* Gets the value of a spin button */
@@ -286,16 +220,6 @@ get_spin_button_value (GtkSpinButton *spin, gpointer value_var, gpointer info)
*value = e_dialog_spin_get_double (GTK_WIDGET (spin));
}
-/* Callback for the "changed" signal of a GtkEditable widget */
-static void
-changed_cb (GtkEditable *editable, gpointer data)
-{
- GnomePropertyBox *pbox;
-
- pbox = GNOME_PROPERTY_BOX (data);
- gnome_property_box_changed (pbox);
-}
-
/* Hooks a GtkEditable widget */
static void
hook_editable (GtkWidget *dialog, GtkEditable *editable, gpointer value_var, gpointer info)
@@ -307,11 +231,6 @@ hook_editable (GtkWidget *dialog, GtkEditable *editable, gpointer value_var, gpo
value = (char **) value_var;
e_dialog_editable_set (GTK_WIDGET (editable), *value);
-
- /* Hook to changed */
-
- if (GNOME_IS_PROPERTY_BOX (dialog))
- g_signal_connect (editable, "changed", G_CALLBACK (changed_cb), dialog);
}
/* Gets the value of a GtkEditable widget */
@@ -718,7 +637,7 @@ e_dialog_dateedit_get (GtkWidget *widget)
g_return_val_if_fail (widget != NULL, -1);
g_return_val_if_fail (GNOME_IS_DATE_EDIT (widget), -1);
- return gnome_date_edit_get_date (GNOME_DATE_EDIT (widget));
+ return gnome_date_edit_get_time (GNOME_DATE_EDIT (widget));
}
/**
@@ -743,10 +662,6 @@ e_dialog_dateedit_get (GtkWidget *widget)
* use is to call that function in the handler for the "OK" button of a dialog
* box.
*
- * In addition, if the specified @dialog is a #GnomePropertyBox, the widgets wil
- * automatically turn on the "Apply" button of the property box when they are
- * modified by the user.
- *
* Return value: TRUE if the type of the specified @widget is supported, FALSE
* otherwise.
**/
diff --git a/e-util/e-gtk-utils.c b/e-util/e-gtk-utils.c
deleted file mode 100644
index d8282d2c1a..0000000000
--- a/e-util/e-gtk-utils.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-gtk-utils.c
- *
- * Copyright (C) 2000 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Ettore Perazzoli
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtklayout.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkwidget.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkstock.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkimage.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkalignment.h>
-
-#ifdef GDK_WINDOWING_X11
-#include <gdk/gdkx.h>
-
-#include <X11/Xlib.h>
-#endif
-
-#include "e-gtk-utils.h"
-
-
-void
-e_signal_connect_while_alive (void *instance,
- const char *name,
- GCallback callback,
- void *callback_data,
- void *alive_instance)
-{
- GClosure *closure;
-
- g_return_if_fail (GTK_IS_OBJECT (instance));
-
- closure = g_cclosure_new (callback, callback_data, NULL);
- g_object_watch_closure (alive_instance, closure);
- g_signal_connect_closure_by_id (instance, g_signal_lookup (name, G_OBJECT_TYPE (instance)), 0,
- closure, FALSE);
-}
-
-
-/* (Cut and pasted from Gtk.) */
-
-typedef struct DisconnectInfo {
- unsigned int signal_handler;
-
- GtkObject *object1;
- unsigned int disconnect_handler1;
-
- GtkObject *object2;
- unsigned int disconnect_handler2;
-} DisconnectInfo;
-
-static unsigned int
-alive_disconnecter (GtkObject *object,
- DisconnectInfo *info)
-{
- g_assert (info != NULL);
-
- g_signal_handler_disconnect (info->object1, info->disconnect_handler1);
- g_signal_handler_disconnect (info->object1, info->signal_handler);
- g_signal_handler_disconnect (info->object2, info->disconnect_handler2);
-
- g_free (info);
-
- return 0;
-}
-
-/**
- * e_gtk_signal_connect_full_while_alive:
- * @object:
- * @name:
- * @func:
- * @marshal:
- * @data:
- * @destroy_func:
- * @object_signal:
- * @after:
- * @alive_object:
- *
- * Connect a signal like `gtk_signal_connect_while_alive()', but with full
- * params like `gtk_signal_connect_full()'.
- **/
-void
-e_signal_connect_full_while_alive (void *instance,
- const char *name,
- GtkSignalFunc func,
- GtkCallbackMarshal marshal,
- void *data,
- GtkDestroyNotify destroy_func,
- gboolean instance_signal,
- gboolean after,
- void *alive_instance)
-{
- DisconnectInfo *info;
-
- g_return_if_fail (GTK_IS_OBJECT (instance));
- g_return_if_fail (name != NULL);
- g_return_if_fail (func != NULL);
- g_return_if_fail (GTK_IS_OBJECT (alive_instance));
-
- info = g_new (DisconnectInfo, 1);
-
- info->signal_handler = gtk_signal_connect_full (instance, name,
- func, marshal, data,
- destroy_func,
- instance_signal, after);
-
- info->object1 = instance;
- info->disconnect_handler1 = g_signal_connect (instance, "destroy",
- G_CALLBACK (alive_disconnecter), info);
-
- info->object2 = alive_instance;
- info->disconnect_handler2 = g_signal_connect (alive_instance, "destroy",
- G_CALLBACK (alive_disconnecter), info);
-}
-
-
-#ifdef GDK_WINDOWING_X11
-/* BackingStore support. */
-
-static void
-widget_realize_callback_for_backing_store (GtkWidget *widget,
- void *data)
-{
- XSetWindowAttributes attributes;
- GdkWindow *window;
-
- if (GTK_IS_LAYOUT (widget))
- window = GTK_LAYOUT (widget)->bin_window;
- else
- window = widget->window;
-
- attributes.backing_store = Always;
- XChangeWindowAttributes (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XWINDOW (window),
- CWBackingStore, &attributes);
-}
-
-#endif
-
-/**
- * e_make_widget_backing_stored:
- * @widget: A GtkWidget
- *
- * Make sure that the window for @widget has the BackingStore attribute set to
- * Always when realized. This will allow the widget to be refreshed by the X
- * server even if the application is currently not responding to X events (this
- * is e.g. very useful for the splash screen).
- *
- * Notice that this will not work 100% in all cases as the server might not
- * support that or just refuse to do so.
- **/
-void
-e_make_widget_backing_stored (GtkWidget *widget)
-{
-#ifdef GDK_WINDOWING_X11
- g_signal_connect (widget, "realize", G_CALLBACK (widget_realize_callback_for_backing_store), NULL);
-#endif
-}
-
-
-/**
- * e_gtk_button_new_with_icon:
- * @text: The mnemonic text for the label.
- * @stock: The name of the stock item to get the icon from.
- *
- * Create a gtk button with a custom label and a stock icon.
- *
- *
- * Return value: The widget.
- **/
-GtkWidget *
-e_gtk_button_new_with_icon(const char *text, const char *stock)
-{
- GtkWidget *button, *label;
- GtkStockItem item;
-
- button = gtk_button_new();
- label = gtk_label_new_with_mnemonic(text);
- gtk_label_set_mnemonic_widget((GtkLabel *)label, button);
-
- if (gtk_stock_lookup(stock, &item)) {
- GtkWidget *image, *hbox, *align;
-
- image = gtk_image_new_from_stock(stock, GTK_ICON_SIZE_BUTTON);
- hbox = gtk_hbox_new(FALSE, 2);
- align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
- gtk_box_pack_start((GtkBox *)hbox, image, FALSE, FALSE, 0);
- gtk_box_pack_end((GtkBox *)hbox, label, FALSE, FALSE, 0);
- gtk_container_add((GtkContainer *)align, hbox);
- gtk_container_add((GtkContainer *)button, align);
- gtk_widget_show_all(align);
- } else {
- gtk_misc_set_alignment((GtkMisc *)label, 0.5, 0.5);
- gtk_container_add((GtkContainer *)button, label);
- gtk_widget_show(label);
- }
-
- return button;
-}
diff --git a/e-util/e-gtk-utils.h b/e-util/e-gtk-utils.h
deleted file mode 100644
index cebb5b757d..0000000000
--- a/e-util/e-gtk-utils.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-gtk-utils.c
- *
- * Copyright (C) 2000 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Ettore Perazzoli
- */
-
-#ifndef E_GTK_UTILS_H
-#define E_GTK_UTILS_H
-
-#include <gtk/gtkobject.h>
-#include <gtk/gtkradiobutton.h>
-
-void e_signal_connect_while_alive (void *object,
- const char *name,
- GCallback callback,
- void *data,
- void *alive_instance);
-
-void e_signal_connect_full_while_alive (void *instance,
- const char *name,
- GtkSignalFunc func,
- GtkCallbackMarshal marshal,
- void *data,
- GtkDestroyNotify destroy_func,
- gboolean object_signal,
- gboolean after,
- void *alive_instance);
-
-void e_make_widget_backing_stored (GtkWidget *widget);
-
-GtkWidget *e_gtk_button_new_with_icon(const char *text, const char *stock);
-
-#endif
diff --git a/e-util/e-gui-utils.c b/e-util/e-gui-utils.c
index 3c1f6f67af..875dc91ad9 100644
--- a/e-util/e-gui-utils.c
+++ b/e-util/e-gui-utils.c
@@ -31,58 +31,6 @@
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
#include <libgnomeui/gnome-icon-lookup.h>
-GtkWidget *e_create_image_widget(gchar *name,
- gchar *string1, gchar *string2,
- gint int1, gint int2)
-{
- GtkWidget *alignment = NULL;
- GtkWidget *w;
-
- if (string1) {
- w = e_icon_factory_get_image (string1, E_ICON_SIZE_DIALOG);
-
- gtk_misc_set_alignment (GTK_MISC (w), 0.5, 0.5);
-
- alignment = gtk_widget_new(gtk_alignment_get_type(),
- "child", w,
- "xalign", (double) 0,
- "yalign", (double) 0,
- "xscale", (double) 0,
- "yscale", (double) 0,
- NULL);
-
- gtk_widget_show_all (alignment);
- }
-
- return alignment;
-}
-
-GtkWidget *
-e_button_new_with_stock_icon (const char *label_str, const char *stockid)
-{
- GtkWidget *button, *hbox, *label, *align, *image;
-
- button = gtk_button_new ();
-
- label = gtk_label_new_with_mnemonic (label_str);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
-
- image = gtk_image_new_from_stock (stockid, GTK_ICON_SIZE_BUTTON);
- hbox = gtk_hbox_new (FALSE, 2);
-
- align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
-
- gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
- gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- gtk_container_add (GTK_CONTAINER (button), align);
- gtk_container_add (GTK_CONTAINER (align), hbox);
- gtk_widget_show_all (align);
-
- return button;
-}
-
/**
* e_icon_for_mime_type:
* @mime_type: a MIME type
@@ -97,35 +45,19 @@ e_button_new_with_stock_icon (const char *label_str, const char *stockid)
GdkPixbuf *
e_icon_for_mime_type (const char *mime_type, int size_hint)
{
- static GnomeIconTheme *icon_theme = NULL;
- char *icon_name, *icon_path = NULL;
+ gchar *icon_name;
GdkPixbuf *pixbuf = NULL;
-
- /* Try the icon theme. (GNOME 2.2 or Sun GNOME 2.0).
- * This will also look in GNOME VFS.
- */
-
- if (!icon_theme)
- icon_theme = gnome_icon_theme_new ();
- gnome_icon_theme_set_allow_svg (icon_theme, TRUE);
-
- icon_name = gnome_icon_lookup (icon_theme, NULL, NULL, NULL, NULL,
- mime_type, 0, NULL);
- if (icon_name) {
- /* FIXME: should we take size_hint as being the same
- * as e-icon-factory.c? or should we just leave this
- * as pixel size? */
- icon_path = gnome_icon_theme_lookup_icon (
- icon_theme, icon_name, size_hint, NULL, NULL);
+
+ icon_name = gnome_icon_lookup (
+ gtk_icon_theme_get_default (),
+ NULL, NULL, NULL, NULL, mime_type, 0, NULL);
+
+ if (icon_name != NULL) {
+ pixbuf = gtk_icon_theme_load_icon (
+ gtk_icon_theme_get_default (),
+ icon_name, size_hint, 0, NULL);
g_free (icon_name);
}
-
- if (icon_path == NULL)
- return NULL;
-
- pixbuf = gdk_pixbuf_new_from_file (icon_path, NULL);
- g_free (icon_path);
-
+
return pixbuf;
}
-
diff --git a/e-util/e-gui-utils.h b/e-util/e-gui-utils.h
index 8701949cb0..de219e8bc4 100644
--- a/e-util/e-gui-utils.h
+++ b/e-util/e-gui-utils.h
@@ -2,12 +2,6 @@
#define E_GUI_UTILS_H
#include <gtk/gtkwidget.h>
-#include <bonobo/bonobo-ui-util.h>
-#include <bonobo/bonobo-control.h>
-
-GtkWidget *e_create_image_widget (gchar *name, gchar *string1, gchar *string2, gint int1, gint int2);
-
-GtkWidget *e_button_new_with_stock_icon (const char *label_str, const char *stockid);
GdkPixbuf *e_icon_for_mime_type (const char *mime_type, int size);
diff --git a/e-util/e-icon-factory.c b/e-util/e-icon-factory.c
index 5471b5adab..96cd9d5ce2 100644
--- a/e-util/e-icon-factory.c
+++ b/e-util/e-icon-factory.c
@@ -30,8 +30,8 @@
#include <pthread.h>
+#include <gtk/gtkicontheme.h>
#include <gtk/gtkimage.h>
-#include <libgnomeui/gnome-icon-theme.h>
#include "e-icon-factory.h"
#include "e-util-private.h"
@@ -58,8 +58,8 @@ static GdkPixbuf *broken16_pixbuf = NULL;
static GdkPixbuf *broken24_pixbuf = NULL;
static GHashTable *name_to_icon = NULL;
-static GnomeIconTheme *icon_theme = NULL;
-static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+static GtkIconTheme *icon_theme = NULL;
+static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
/* Note: takes ownership of the pixbufs (eg. does not ref them) */
@@ -67,11 +67,11 @@ static Icon *
icon_new (const char *name, GdkPixbuf *pixbuf)
{
Icon *icon;
-
- icon = g_malloc0 (sizeof (Icon));
+
+ icon = g_slice_new (Icon);
icon->name = g_strdup (name);
icon->pixbuf = pixbuf;
-
+
return icon;
}
@@ -81,7 +81,7 @@ icon_free (Icon *icon)
g_free (icon->name);
if (icon->pixbuf)
g_object_unref (icon->pixbuf);
- g_free (icon);
+ g_slice_free (Icon, icon);
}
static Icon *
@@ -89,11 +89,20 @@ load_icon (const char *icon_key, const char *icon_name, int size, int scale)
{
GdkPixbuf *pixbuf, *unscaled = NULL;
char *basename, *filename = NULL;
-
+
if (g_path_is_absolute (icon_name))
filename = g_strdup (icon_name);
- else
- filename = gnome_icon_theme_lookup_icon (icon_theme, icon_name, size, NULL, NULL);
+ else {
+ GtkIconInfo *icon_info;
+
+ icon_info = gtk_icon_theme_lookup_icon (
+ icon_theme, icon_name, size, 0);
+ if (icon_info != NULL) {
+ filename = g_strdup (
+ gtk_icon_info_get_filename (icon_info));
+ gtk_icon_info_free (icon_info);
+ }
+ }
if (!filename || !(unscaled = gdk_pixbuf_new_from_file (filename, NULL))) {
if (scale) {
@@ -145,9 +154,9 @@ load_icon (const char *icon_key, const char *icon_name, int size, int scale)
unscaled = gdk_pixbuf_new_from_file (filename, NULL);
}
}
-
+
done:
-
+
g_free (filename);
if (unscaled != NULL) {
pixbuf = gdk_pixbuf_scale_simple (unscaled, size, size, GDK_INTERP_BILINEAR);
@@ -155,7 +164,7 @@ load_icon (const char *icon_key, const char *icon_name, int size, int scale)
} else {
pixbuf = NULL;
}
-
+
return icon_new (icon_key, pixbuf);
}
@@ -165,29 +174,21 @@ static int
pixel_size_to_icon_size (int pixel_size)
{
int i, icon_size = -1;
-
+
for (i = 0; i < E_ICON_NUM_SIZES; i++) {
if (pixel_size == sizes[i]) {
icon_size = i;
break;
}
}
-
- return icon_size;
-}
-static gboolean
-icon_foreach_remove (gpointer key, gpointer value, gpointer user_data)
-{
- icon_free (value);
-
- return TRUE;
+ return icon_size;
}
static void
-icon_theme_changed_cb (GnomeIconTheme *object, gpointer user_data)
+icon_theme_changed_cb (GtkIconTheme *icon_theme, gpointer user_data)
{
- g_hash_table_foreach_remove (name_to_icon, (GHRFunc) icon_foreach_remove, NULL);
+ g_hash_table_remove_all (name_to_icon);
}
/**
@@ -200,20 +201,22 @@ e_icon_factory_init (void)
{
if (name_to_icon != NULL)
return;
-
- icon_theme = gnome_icon_theme_new ();
- gnome_icon_theme_set_allow_svg (icon_theme, TRUE);
- name_to_icon = g_hash_table_new (g_str_hash, g_str_equal);
- g_signal_connect (G_OBJECT (icon_theme), "changed", G_CALLBACK (icon_theme_changed_cb), NULL);
-
- broken16_pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) broken_image_16_xpm);
- broken24_pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) broken_image_24_xpm);
-}
-static void
-icon_foreach_free (gpointer key, gpointer value, gpointer user_data)
-{
- icon_free (value);
+ name_to_icon = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) NULL,
+ (GDestroyNotify) icon_free);
+
+ icon_theme = gtk_icon_theme_get_default ();
+
+ g_signal_connect (
+ icon_theme, "changed",
+ G_CALLBACK (icon_theme_changed_cb), NULL);
+
+ broken16_pixbuf = gdk_pixbuf_new_from_xpm_data (
+ (const char **) broken_image_16_xpm);
+ broken24_pixbuf = gdk_pixbuf_new_from_xpm_data (
+ (const char **) broken_image_24_xpm);
}
/**
@@ -226,12 +229,10 @@ e_icon_factory_shutdown (void)
{
if (name_to_icon == NULL)
return;
-
- g_hash_table_foreach (name_to_icon, (GHFunc) icon_foreach_free, NULL);
+
g_hash_table_destroy (name_to_icon);
g_object_unref (broken16_pixbuf);
g_object_unref (broken24_pixbuf);
- g_object_unref (icon_theme);
name_to_icon = NULL;
}
@@ -248,21 +249,31 @@ e_icon_factory_shutdown (void)
char *
e_icon_factory_get_icon_filename (const char *icon_name, int icon_size)
{
+ GtkIconInfo *icon_info;
char *filename;
-
+
g_return_val_if_fail (icon_name != NULL, NULL);
g_return_val_if_fail (strcmp (icon_name, ""), NULL);
-
+
if (icon_size >= E_ICON_NUM_SIZES) {
- g_warning ("calling e_icon_factory_get_icon_filename with unknown icon_size value (%d)", icon_size);
+ g_warning (
+ "calling %s with unknown icon_size value (%d)",
+ G_STRFUNC, icon_size);
if ((icon_size = pixel_size_to_icon_size (icon_size)) == -1)
return NULL;
}
-
- pthread_mutex_lock (&lock);
- filename = gnome_icon_theme_lookup_icon (icon_theme, icon_name, sizes[icon_size], NULL, NULL);
- pthread_mutex_unlock (&lock);
-
+
+ g_static_mutex_lock (&mutex);
+ icon_info = gtk_icon_theme_lookup_icon (
+ icon_theme, icon_name, sizes[icon_size], 0);
+ if (icon_info != NULL) {
+ filename = g_strdup (
+ gtk_icon_info_get_filename (icon_info));
+ gtk_icon_info_free (icon_info);
+ } else
+ filename = NULL;
+ g_static_mutex_unlock (&mutex);
+
return filename;
}
@@ -287,32 +298,34 @@ e_icon_factory_get_icon (const char *icon_name, int icon_size)
char *icon_key;
Icon *icon;
int size;
-
+
if (icon_size >= E_ICON_NUM_SIZES) {
- g_warning ("calling e_icon_factory_get_icon with unknown icon_size value (%d)", icon_size);
+ g_warning (
+ "calling %s with unknown icon_size value (%d)",
+ G_STRFUNC, icon_size);
if ((icon_size = pixel_size_to_icon_size (icon_size)) == -1)
return NULL;
}
-
+
size = sizes[icon_size];
-
+
if (icon_name == NULL || !strcmp (icon_name, "")) {
if (size >= 24)
return gdk_pixbuf_scale_simple (broken24_pixbuf, size, size, GDK_INTERP_NEAREST);
else
return gdk_pixbuf_scale_simple (broken16_pixbuf, size, size, GDK_INTERP_NEAREST);
}
-
+
icon_key = g_alloca (strlen (icon_name) + 7);
sprintf (icon_key, "%dx%d/%s", size, size, icon_name);
-
- pthread_mutex_lock (&lock);
-
+
+ g_static_mutex_lock (&mutex);
+
if (!(icon = g_hash_table_lookup (name_to_icon, icon_key))) {
icon = load_icon (icon_key, icon_name, size, TRUE);
g_hash_table_insert (name_to_icon, icon->name, icon);
}
-
+
if ((pixbuf = icon->pixbuf)) {
g_object_ref (pixbuf);
} else {
@@ -321,9 +334,9 @@ e_icon_factory_get_icon (const char *icon_name, int icon_size)
else
pixbuf = gdk_pixbuf_scale_simple (broken16_pixbuf, size, size, GDK_INTERP_NEAREST);
}
-
- pthread_mutex_unlock (&lock);
-
+
+ g_static_mutex_unlock (&mutex);
+
return pixbuf;
}
@@ -332,7 +345,7 @@ e_icon_factory_get_image (const char *icon_name, int icon_size)
{
GdkPixbuf *pixbuf;
GtkWidget *image;
-
+
pixbuf = e_icon_factory_get_icon (icon_name, icon_size);
image = gtk_image_new_from_pixbuf (pixbuf);
g_object_unref (pixbuf);
@@ -355,14 +368,14 @@ e_icon_factory_get_icon_list (const char *icon_name)
char *icon_key;
Icon *icon;
int size, i;
-
+
if (!icon_name || !strcmp (icon_name, ""))
return NULL;
-
- pthread_mutex_lock (&lock);
-
+
+ g_static_mutex_lock (&mutex);
+
icon_key = g_alloca (strlen (icon_name) + 9);
-
+
for (i = 0; i < G_N_ELEMENTS (icon_list_sizes); i++) {
size = icon_list_sizes[i];
sprintf (icon_key, "%dx%d/%s", size, size, icon_name);
@@ -377,8 +390,8 @@ e_icon_factory_get_icon_list (const char *icon_name)
g_object_ref (icon->pixbuf);
}
}
-
- pthread_mutex_unlock (&lock);
-
+
+ g_static_mutex_unlock (&mutex);
+
return list;
}
diff --git a/e-util/e-mktemp.c b/e-util/e-mktemp.c
index 56345d9c68..2b4fdf5d47 100644
--- a/e-util/e-mktemp.c
+++ b/e-util/e-mktemp.c
@@ -113,7 +113,7 @@ get_dir (gboolean make)
tmpdir = g_build_filename(g_get_home_dir(), ".evolution",
"cache", "tmp", NULL);
path = g_string_new(tmpdir);
- if (make && e_util_mkdir_hier(tmpdir, 0777) == -1) {
+ if (make && g_mkdir_with_parents(tmpdir, 0777) == -1) {
g_string_free(path, TRUE);
path = NULL;
}
diff --git a/e-util/e-sorter-array.c b/e-util/e-sorter-array.c
index 7b7e6ab4ea..0f103a339a 100644
--- a/e-util/e-sorter-array.c
+++ b/e-util/e-sorter-array.c
@@ -85,7 +85,9 @@ esa_sort(ESorterArray *esa)
esa->sorted[i] = i;
if (esa->compare)
- e_sort (esa->sorted, rows, sizeof(int), esort_callback, esa);
+ g_qsort_with_data (
+ esa->sorted, rows, sizeof(int),
+ esort_callback, esa);
}
static void
diff --git a/e-util/e-util.c b/e-util/e-util.c
index f5e33f04bd..28deaa74e9 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -49,8 +49,8 @@
#include "e-util.h"
#include "e-util-private.h"
-int
-e_str_compare (const void *x, const void *y)
+gint
+e_str_compare (gconstpointer x, gconstpointer y)
{
if (x == NULL || y == NULL) {
if (x == y)
@@ -62,8 +62,8 @@ e_str_compare (const void *x, const void *y)
return strcmp (x, y);
}
-int
-e_str_case_compare (const void *x, const void *y)
+gint
+e_str_case_compare (gconstpointer x, gconstpointer y)
{
if (x == NULL || y == NULL) {
if (x == y)
@@ -75,8 +75,8 @@ e_str_case_compare (const void *x, const void *y)
return g_utf8_collate (g_utf8_casefold (x, -1), g_utf8_casefold (y, -1));
}
-int
-e_collate_compare (const void *x, const void *y)
+gint
+e_collate_compare (gconstpointer x, gconstpointer y)
{
if (x == NULL || y == NULL) {
if (x == y)
@@ -88,158 +88,17 @@ e_collate_compare (const void *x, const void *y)
return g_utf8_collate (x, y);
}
-int
-e_int_compare (const void *x, const void *y)
-{
- if (GPOINTER_TO_INT (x) < GPOINTER_TO_INT (y))
- return -1;
- else if (GPOINTER_TO_INT (x) == GPOINTER_TO_INT (y))
- return 0;
- else
- return 1;
-}
-
-char *
-e_strdup_strip(const char *string)
-{
- int i;
- int length = 0;
- int initial = 0;
- for ( i = 0; string[i]; i++ ) {
- if (initial == i && isspace((unsigned char) string[i])) {
- initial ++;
- }
- if (!isspace((unsigned char) string[i])) {
- length = i - initial + 1;
- }
- }
- return g_strndup(string + initial, length);
-}
-
-void
-e_free_object_list (GList *list)
-{
- GList *p;
-
- for (p = list; p != NULL; p = p->next)
- g_object_unref (p->data);
-
- g_list_free (list);
-}
-
-void
-e_free_object_slist (GSList *list)
-{
- GSList *p;
-
- for (p = list; p != NULL; p = p->next)
- g_object_unref (p->data);
-
- g_slist_free (list);
-}
-
-void
-e_free_string_list (GList *list)
-{
- GList *p;
-
- for (p = list; p != NULL; p = p->next)
- g_free (p->data);
-
- g_list_free (list);
-}
-
-void
-e_free_string_slist (GSList *list)
-{
- GSList *p;
-
- for (p = list; p != NULL; p = p->next)
- g_free (p->data);
- g_slist_free (list);
-}
-
-#define BUFF_SIZE 1024
-
-char *
-e_read_file(const char *filename)
-{
- int fd;
- char buffer[BUFF_SIZE];
- GList *list = NULL, *list_iterator;
- GList *lengths = NULL, *lengths_iterator;
- int length = 0;
- int bytes;
- char *ret_val;
-
- fd = g_open(filename, O_RDONLY, 0);
- if (fd == -1)
- return NULL;
- bytes = read(fd, buffer, BUFF_SIZE);
- while (bytes) {
- if (bytes > 0) {
- char *temp = g_malloc(bytes);
- memcpy (temp, buffer, bytes);
- list = g_list_prepend(list, temp);
- lengths = g_list_prepend(lengths, GINT_TO_POINTER(bytes));
- length += bytes;
- } else {
- if (errno != EINTR) {
- close(fd);
- g_list_foreach(list, (GFunc) g_free, NULL);
- g_list_free(list);
- g_list_free(lengths);
- return NULL;
- }
- }
- bytes = read(fd, buffer, BUFF_SIZE);
- }
- ret_val = g_new(char, length + 1);
- ret_val[length] = 0;
- lengths_iterator = lengths;
- list_iterator = list;
- for ( ; list_iterator; list_iterator = list_iterator->next, lengths_iterator = lengths_iterator->next) {
- int this_length = GPOINTER_TO_INT(lengths_iterator->data);
- length -= this_length;
- memcpy(ret_val + length, list_iterator->data, this_length);
- }
- close(fd);
- g_list_foreach(list, (GFunc) g_free, NULL);
- g_list_free(list);
- g_list_free(lengths);
- return ret_val;
-}
-
gint
-e_write_file(const char *filename, const char *data, int flags)
+e_int_compare (gconstpointer x, gconstpointer y)
{
- int fd;
- int length = strlen(data);
- int bytes;
- fd = g_open(filename, flags | O_WRONLY, 0666);
- if (fd == -1)
- return errno;
- while (length > 0) {
- bytes = write(fd, data, length);
- if (bytes > 0) {
- length -= bytes;
- data += bytes;
- } else {
- if (errno != EINTR && errno != EAGAIN) {
- int save_errno = errno;
- close(fd);
- return save_errno;
- }
- }
- }
- if (close(fd) != 0) {
- return errno;
- }
- return 0;
+ gint nx = GPOINTER_TO_INT (x);
+ gint ny = GPOINTER_TO_INT (y);
+
+ return (nx == ny) ? 0 : (nx < ny) ? -1 : 1;
}
gint
-e_write_file_uri (const char *filename, const char *data)
+e_write_file_uri (const gchar *filename, const gchar *data)
{
guint64 length = strlen(data);
guint64 bytes;
@@ -267,141 +126,18 @@ e_write_file_uri (const char *filename, const char *data)
return 0;
}
-gint
-e_write_file_mkstemp(char *filename, const char *data)
-{
- int fd;
- int length = strlen(data);
- int bytes;
- fd = g_mkstemp (filename);
- if (fd == -1)
- return errno;
- while (length > 0) {
- bytes = write(fd, data, length);
- if (bytes > 0) {
- length -= bytes;
- data += bytes;
- } else {
- if (errno != EINTR && errno != EAGAIN) {
- int save_errno = errno;
- close(fd);
- return save_errno;
- }
- }
- }
- if (close(fd) != 0) {
- return errno;
- }
- return 0;
-}
-
-#if 0
-char *
-e_read_uri(const char *uri)
-{
- GnomeVFSHandle *handle;
- GList *list = NULL, *list_iterator;
- GList *lengths = NULL, *lengths_iterator;
- gchar buffer[1025];
- gchar *ret_val;
- int length = 0;
- GnomeVFSFileSize bytes;
-
- gnome_vfs_open(&handle, uri, GNOME_VFS_OPEN_READ);
-
- gnome_vfs_read(handle, buffer, 1024, &bytes);
- while (bytes) {
- if (bytes) {
- char *temp = g_malloc(bytes);
- memcpy (temp, buffer, bytes);
- list = g_list_prepend(list, temp);
- lengths = g_list_prepend(lengths, GINT_TO_POINTER((gint) bytes));
- length += bytes;
- }
- gnome_vfs_read(handle, buffer, 1024, &bytes);
- }
-
- ret_val = g_new(char, length + 1);
- ret_val[length] = 0;
- lengths_iterator = lengths;
- list_iterator = list;
- for ( ; list_iterator; list_iterator = list_iterator->next, lengths_iterator = lengths_iterator->next) {
- int this_length = GPOINTER_TO_INT(lengths_iterator->data);
- length -= this_length;
- memcpy(ret_val + length, list_iterator->data, this_length);
- }
- gnome_vfs_close(handle);
- g_list_foreach(list, (GFunc) g_free, NULL);
- g_list_free(list);
- g_list_free(lengths);
- return ret_val;
-}
-#endif
-
/* Include build marshalers */
#include "e-util-marshal.h"
-gchar**
-e_strsplit (const gchar *string,
- const gchar *delimiter,
- gint max_tokens)
-{
- GSList *string_list = NULL, *slist;
- gchar **str_array, *s;
- guint i, n = 1;
-
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (delimiter != NULL, NULL);
-
- if (max_tokens < 1)
- max_tokens = G_MAXINT;
-
- s = strstr (string, delimiter);
- if (s)
- {
- guint delimiter_len = strlen (delimiter);
-
- do
- {
- guint len;
- gchar *new_string;
-
- len = s - string;
- new_string = g_new (gchar, len + 1);
- strncpy (new_string, string, len);
- new_string[len] = 0;
- string_list = g_slist_prepend (string_list, new_string);
- n++;
- string = s + delimiter_len;
- s = strstr (string, delimiter);
- }
- while (--max_tokens && s);
- }
-
- n++;
- string_list = g_slist_prepend (string_list, g_strdup (string));
-
- str_array = g_new (gchar*, n);
-
- i = n - 1;
-
- str_array[i--] = NULL;
- for (slist = string_list; slist; slist = slist->next)
- str_array[i--] = slist->data;
-
- g_slist_free (string_list);
-
- return str_array;
-}
-
static gint
-epow10 (gint number) {
- gint value;
+epow10 (gint number)
+{
+ gint value = 1;
- for (value = 1; number > 0; number --) {
+ while (number-- > 0)
value *= 10;
- }
+
return value;
}
@@ -412,16 +148,16 @@ e_format_number (gint number)
struct lconv *locality;
gint char_length = 0;
gint group_count = 0;
- guchar *grouping;
- int last_count = 3;
- int divider;
- char *value;
- char *value_iterator;
+ gchar *grouping;
+ gint last_count = 3;
+ gint divider;
+ gchar *value;
+ gchar *value_iterator;
locality = localeconv();
grouping = locality->grouping;
while (number) {
- char *group;
+ gchar *group;
switch (*grouping) {
default:
last_count = *grouping;
@@ -446,7 +182,7 @@ e_format_number (gint number)
}
if (list) {
- value = g_new(char, 1 + char_length + (group_count - 1) * strlen(locality->thousands_sep));
+ value = g_new(gchar, 1 + char_length + (group_count - 1) * strlen(locality->thousands_sep));
iterator = list;
value_iterator = value;
@@ -460,7 +196,8 @@ e_format_number (gint number)
strcpy(value_iterator, iterator->data);
value_iterator += strlen(iterator->data);
}
- e_free_string_list (list);
+ g_list_foreach (list, (GFunc) g_free, NULL);
+ g_list_free (list);
return value;
} else {
return g_strdup("0");
@@ -468,23 +205,23 @@ e_format_number (gint number)
}
static gchar *
-do_format_number_as_float (double number)
+do_format_number_as_float (gdouble number)
{
GList *iterator, *list = NULL;
struct lconv *locality;
gint char_length = 0;
gint group_count = 0;
- guchar *grouping;
- int last_count = 3;
- int divider;
- char *value;
- char *value_iterator;
- double fractional;
+ gchar *grouping;
+ gint last_count = 3;
+ gint divider;
+ gchar *value;
+ gchar *value_iterator;
+ gdouble fractional;
locality = localeconv();
grouping = locality->grouping;
while (number >= 1.0) {
- char *group;
+ gchar *group;
switch (*grouping) {
default:
last_count = *grouping;
@@ -500,7 +237,7 @@ do_format_number_as_float (double number)
if (number >= 1.0) {
group = g_strdup_printf("%0*d", last_count, (int) fractional);
} else {
- group = g_strdup_printf("%d", (int) fractional);
+ group = g_strdup_printf("%d", (gint) fractional);
}
break;
case CHAR_MAX:
@@ -511,7 +248,7 @@ do_format_number_as_float (double number)
fractional = floor (fractional);
while (number >= 1.0) {
- group = g_strdup_printf("%0*d", last_count, (int) fractional);
+ group = g_strdup_printf("%0*d", last_count, (gint) fractional);
char_length += strlen(group);
list = g_list_prepend(list, group);
@@ -524,7 +261,7 @@ do_format_number_as_float (double number)
fractional = floor (fractional);
}
- group = g_strdup_printf("%d", (int) fractional);
+ group = g_strdup_printf("%d", (gint) fractional);
break;
}
char_length += strlen(group);
@@ -533,7 +270,7 @@ do_format_number_as_float (double number)
}
if (list) {
- value = g_new(char, 1 + char_length + (group_count - 1) * strlen(locality->thousands_sep));
+ value = g_new(gchar, 1 + char_length + (group_count - 1) * strlen(locality->thousands_sep));
iterator = list;
value_iterator = value;
@@ -547,7 +284,8 @@ do_format_number_as_float (double number)
strcpy(value_iterator, iterator->data);
value_iterator += strlen(iterator->data);
}
- e_free_string_list (list);
+ g_list_foreach (list, (GFunc) g_free, NULL);
+ g_list_free (list);
return value;
} else {
return g_strdup("0");
@@ -568,7 +306,7 @@ e_format_number_float (gfloat number)
locality = localeconv();
int_part = floor (number);
- str_intpart = do_format_number_as_float ((double) int_part);
+ str_intpart = do_format_number_as_float ((gdouble) int_part);
if (!strcmp(locality->mon_decimal_point, "")) {
decimal_point = ".";
@@ -577,7 +315,7 @@ e_format_number_float (gfloat number)
decimal_point = locality->mon_decimal_point;
}
- fraction = (int) ((number - int_part) * 100);
+ fraction = (gint) ((number - int_part) * 100);
if (fraction == 0) {
str_fraction = g_strdup ("00");
@@ -593,31 +331,21 @@ e_format_number_float (gfloat number)
return value;
}
-gboolean
-e_create_directory (gchar *directory)
-{
- gint ret_val = e_util_mkdir_hier (directory, 0777);
- if (ret_val == -1)
- return FALSE;
- else
- return TRUE;
-}
-
-
/* Perform a binary search for key in base which has nmemb elements
of size bytes each. The comparisons are done by (*compare)(). */
-void e_bsearch (const void *key,
- const void *base,
- size_t nmemb,
- size_t size,
- ESortCompareFunc compare,
- gpointer closure,
- size_t *start,
- size_t *end)
+void
+e_bsearch (gconstpointer key,
+ gconstpointer base,
+ gsize nmemb,
+ gsize size,
+ ESortCompareFunc compare,
+ gpointer closure,
+ gsize *start,
+ gsize *end)
{
- size_t l, u, idx;
- const void *p;
- int comparison;
+ gsize l, u, idx;
+ gconstpointer p;
+ gint comparison;
if (!(start || end))
return;
@@ -625,20 +353,20 @@ void e_bsearch (cons
u = nmemb;
while (l < u) {
idx = (l + u) / 2;
- p = (void *) (((const char *) base) + (idx * size));
+ p = (((const gchar *) base) + (idx * size));
comparison = (*compare) (key, p, closure);
if (comparison < 0)
u = idx;
else if (comparison > 0)
l = idx + 1;
else {
- size_t lsave, usave;
+ gsize lsave, usave;
lsave = l;
usave = u;
if (start) {
while (l < u) {
idx = (l + u) / 2;
- p = (void *) (((const char *) base) + (idx * size));
+ p = (((const gchar *) base) + (idx * size));
comparison = (*compare) (key, p, closure);
if (comparison <= 0)
u = idx;
@@ -653,7 +381,7 @@ void e_bsearch (cons
if (end) {
while (l < u) {
idx = (l + u) / 2;
- p = (void *) (((const char *) base) + (idx * size));
+ p = (((const gchar *) base) + (idx * size));
comparison = (*compare) (key, p, closure);
if (comparison < 0)
u = idx;
@@ -672,42 +400,6 @@ void e_bsearch (cons
*end = l;
}
-static gpointer closure_closure;
-static ESortCompareFunc compare_closure;
-
-static int
-qsort_callback(const void *data1, const void *data2)
-{
- return (*compare_closure) (data1, data2, closure_closure);
-}
-
-/* Forget it. We're just going to use qsort. I lost the need for a stable sort. */
-void
-e_sort (void *base,
- size_t nmemb,
- size_t size,
- ESortCompareFunc compare,
- gpointer closure)
-{
- closure_closure = closure;
- compare_closure = compare;
- qsort(base, nmemb, size, qsort_callback);
-#if 0
- void *base_copy;
- int i;
- base_copy = g_malloc(nmemb * size);
-
- for (i = 0; i < nmemb; i++) {
- int position;
- e_bsearch(base + (i * size), base_copy, i, size, compare, closure, NULL, &position);
- memmove(base_copy + (position + 1) * size, base_copy + position * size, (i - position) * size);
- memcpy(base_copy + position * size, base + i * size, size);
- }
- memcpy(base, base_copy, nmemb * size);
- g_free(base_copy);
-#endif
-}
-
/**
* Function to do a last minute fixup of the AM/PM stuff if the locale
* and gettext haven't done it right. Most English speaking countries
@@ -726,16 +418,18 @@ e_sort (void *base,
* there isn't a stray space.
**/
-size_t e_strftime_fix_am_pm(char *s, size_t max, const char *fmt, const struct tm *tm)
+gsize
+e_strftime_fix_am_pm (gchar *str, gsize max, const gchar *fmt,
+ const struct tm *tm)
{
- char buf[10];
- char *sp;
- char *ffmt;
- size_t ret;
+ gchar buf[10];
+ gchar *sp;
+ gchar *ffmt;
+ gsize ret;
if (strstr(fmt, "%p")==NULL && strstr(fmt, "%P")==NULL) {
/* No AM/PM involved - can use the fmt string directly */
- ret=e_strftime(s, max, fmt, tm);
+ ret=e_strftime(str, max, fmt, tm);
} else {
/* Get the AM/PM symbol from the locale */
e_strftime (buf, 10, "%p", tm);
@@ -745,7 +439,7 @@ size_t e_strftime_fix_am_pm(char *s, size_t max, const char *fmt, const struct t
* AM/PM have been defined in the locale
* so we can use the fmt string directly
**/
- ret=e_strftime(s, max, fmt, tm);
+ ret=e_strftime(str, max, fmt, tm);
} else {
/**
* No AM/PM defined by locale
@@ -762,7 +456,7 @@ size_t e_strftime_fix_am_pm(char *s, size_t max, const char *fmt, const struct t
for (sp=ffmt; (sp=strstr(sp, "%I")); sp++) {
sp[1]='H';
}
- ret=e_strftime(s, max, ffmt, tm);
+ ret=e_strftime(str, max, ffmt, tm);
g_free(ffmt);
}
}
@@ -770,38 +464,39 @@ size_t e_strftime_fix_am_pm(char *s, size_t max, const char *fmt, const struct t
return(ret);
}
-size_t
-e_utf8_strftime_fix_am_pm(char *s, size_t max, const char *fmt, const struct tm *tm)
+gsize
+e_utf8_strftime_fix_am_pm (gchar *str, gsize max, const gchar *fmt,
+ const struct tm *tm)
{
- size_t sz, ret;
- char *locale_fmt, *buf;
+ gsize sz, ret;
+ gchar *locale_fmt, *buf;
locale_fmt = g_locale_from_utf8(fmt, -1, NULL, &sz, NULL);
if (!locale_fmt)
return 0;
- ret = e_strftime_fix_am_pm(s, max, locale_fmt, tm);
+ ret = e_strftime_fix_am_pm(str, max, locale_fmt, tm);
if (!ret) {
g_free (locale_fmt);
return 0;
}
- buf = g_locale_to_utf8(s, ret, NULL, &sz, NULL);
+ buf = g_locale_to_utf8(str, ret, NULL, &sz, NULL);
if (!buf) {
g_free (locale_fmt);
return 0;
}
if (sz >= max) {
- char *tmp = buf + max - 1;
+ gchar *tmp = buf + max - 1;
tmp = g_utf8_find_prev_char(buf, tmp);
if (tmp)
sz = tmp - buf;
else
sz = 0;
}
- memcpy(s, buf, sz);
- s[sz] = '\0';
+ memcpy(str, buf, sz);
+ str[sz] = '\0';
g_free(locale_fmt);
g_free(buf);
return sz;
@@ -827,17 +522,16 @@ e_utf8_strftime_fix_am_pm(char *s, size_t max, const char *fmt, const struct tm
* Return value: the gdouble value.
**/
gdouble
-e_flexible_strtod (const gchar *nptr,
- gchar **endptr)
+e_flexible_strtod (const gchar *nptr, gchar **endptr)
{
gchar *fail_pos;
gdouble val;
struct lconv *locale_data;
- const char *decimal_point;
- int decimal_point_len;
- const char *p, *decimal_point_pos;
- const char *end = NULL; /* Silence gcc */
- char *copy, *c;
+ const gchar *decimal_point;
+ gint decimal_point_len;
+ const gchar *p, *decimal_point_pos;
+ const gchar *end = NULL; /* Silence gcc */
+ gchar *copy, *c;
g_return_val_if_fail (nptr != NULL, 0);
@@ -929,9 +623,9 @@ e_flexible_strtod (const gchar *nptr,
if (fail_pos) {
if (fail_pos > decimal_point_pos)
- fail_pos = (char *)nptr + (fail_pos - copy) - (decimal_point_len - 1);
+ fail_pos = (gchar *)nptr + (fail_pos - copy) - (decimal_point_len - 1);
else
- fail_pos = (char *)nptr + (fail_pos - copy);
+ fail_pos = (gchar *)nptr + (fail_pos - copy);
}
g_free (copy);
@@ -965,16 +659,13 @@ e_flexible_strtod (const gchar *nptr,
* Return value: The pointer to the buffer with the converted string.
**/
gchar *
-e_ascii_dtostr (gchar *buffer,
- gint buf_len,
- const gchar *format,
- gdouble d)
+e_ascii_dtostr (gchar *buffer, gint buf_len, const gchar *format, gdouble d)
{
struct lconv *locale_data;
- const char *decimal_point;
- int decimal_point_len;
+ const gchar *decimal_point;
+ gint decimal_point_len;
gchar *p;
- int rest_len;
+ gint rest_len;
gchar format_char;
g_return_val_if_fail (buffer != NULL, NULL);
@@ -1040,8 +731,8 @@ e_strdup_append_strings (gchar *first_string, ...)
gint length;
va_list args1;
va_list args2;
- char *v_string;
- int v_int;
+ gchar *v_string;
+ gint v_int;
va_start (args1, first_string);
G_VA_COPY (args2, args1);
@@ -1050,32 +741,32 @@ e_strdup_append_strings (gchar *first_string, ...)
v_string = first_string;
while (v_string) {
- v_int = va_arg (args1, int);
+ v_int = va_arg (args1, gint);
if (v_int >= 0)
length += v_int;
else
length += strlen (v_string);
- v_string = va_arg (args1, char *);
+ v_string = va_arg (args1, gchar *);
}
- buffer = g_new (char, length + 1);
+ buffer = g_new (gchar, length + 1);
current = buffer;
v_string = first_string;
while (v_string) {
- v_int = va_arg (args2, int);
+ v_int = va_arg (args2, gint);
if (v_int < 0) {
- int i;
+ gint i;
for (i = 0; v_string[i]; i++) {
*(current++) = v_string[i];
}
} else {
- int i;
+ gint i;
for (i = 0; v_string[i] && i < v_int; i++) {
*(current++) = v_string[i];
}
}
- v_string = va_arg (args2, char *);
+ v_string = va_arg (args2, gchar *);
}
*(current++) = 0;
@@ -1085,36 +776,10 @@ e_strdup_append_strings (gchar *first_string, ...)
return buffer;
}
-gchar **
-e_strdupv (const gchar **str_array)
-{
- if (str_array) {
- gint i;
- gchar **retval;
-
- i = 0;
- while (str_array[i])
- i++;
-
- retval = g_new (gchar*, i + 1);
-
- i = 0;
- while (str_array[i]) {
- retval[i] = g_strdup (str_array[i]);
- i++;
- }
- retval[i] = NULL;
-
- return retval;
- } else {
- return NULL;
- }
-}
-
cairo_font_options_t *
get_font_options ()
{
- char *antialiasing, *hinting, *subpixel_order;
+ gchar *antialiasing, *hinting, *subpixel_order;
GConfClient *gconf = gconf_client_get_default ();
cairo_font_options_t *font_options = cairo_font_options_create ();
@@ -1183,7 +848,7 @@ get_font_options ()
* file URI.
**/
void
-e_file_update_save_path(char *uri, gboolean free)
+e_file_update_save_path (gchar *uri, gboolean free)
{
GConfClient *gconf = gconf_client_get_default();
@@ -1200,11 +865,11 @@ e_file_update_save_path(char *uri, gboolean free)
* the users home directory. Returns an allocated URI that should be freed by
* the caller.
**/
-char *
-e_file_get_save_path(void)
+gchar *
+e_file_get_save_path (void)
{
GConfClient *gconf = gconf_client_get_default();
- char *uri;
+ gchar *uri;
uri = gconf_client_get_string(gconf, "/apps/evolution/mail/save_dir", NULL);
g_object_unref(gconf);
diff --git a/e-util/e-util.h b/e-util/e-util.h
index d0faa995d8..1d4307dab4 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -61,164 +61,74 @@ GType l##_get_type(void)\
return type; \
}
-
-#define E_MAKE_X_TYPE(l,str,t,ci,i,parent,poa_init,offset) \
-GtkType l##_get_type(void) \
-{ \
- static GtkType type = 0; \
- if (!type){ \
- GTypeInfo info = { \
- sizeof (t##Class), \
- \
- (GBaseInitFunc) NULL, \
- (GBaseFinalizeFunc) NULL, \
- \
- (GClassInitFunc) ci, \
- (GClassFinalizeFunc) NULL, \
- \
- NULL, /* class_data */ \
- \
- sizeof (t), \
- 0, /* n_preallocs */ \
- (GInstanceInitFunc) i, \
- }; \
- type = bonobo_x_type_unique ( \
- parent, poa_init, NULL, \
- offset, &info, str); \
- } \
- return type; \
-}
-
-#define GET_STRING_ARRAY_FROM_ELLIPSIS(labels, first_string) \
- { \
- va_list args; \
- int i; \
- char *s; \
- \
- va_start (args, (first_string)); \
- \
- i = 0; \
- for (s = (first_string); s; s = va_arg (args, char *)) \
- i++; \
- va_end (args); \
- \
- (labels) = g_new (char *, i + 1); \
- \
- va_start (args, (first_string)); \
- i = 0; \
- for (s = (first_string); s; s = va_arg (args, char *)) \
- (labels)[i++] = s; \
- \
- va_end (args); \
- (labels)[i] = NULL; \
- }
-
-
-#define GET_DUPLICATED_STRING_ARRAY_FROM_ELLIPSIS(labels, first_string) \
- { \
- int i; \
- GET_STRING_ARRAY_FROM_ELLIPSIS ((labels), (first_string)); \
- for (i = 0; labels[i]; i++) \
- labels[i] = g_strdup (labels[i]); \
- }
-
-
-#if 0
-# define E_OBJECT_CLASS_ADD_SIGNALS(oc,sigs,last) \
- gtk_object_class_add_signals (oc, sigs, last)
-# define E_OBJECT_CLASS_TYPE(oc) (oc)->type
-#else
-# define E_OBJECT_CLASS_ADD_SIGNALS(oc,sigs,last)
-# define E_OBJECT_CLASS_TYPE(oc) G_TYPE_FROM_CLASS (oc)
-#endif
-
-
typedef enum {
E_FOCUS_NONE,
E_FOCUS_CURRENT,
E_FOCUS_START,
E_FOCUS_END
} EFocus;
-int e_str_compare (const void *x,
- const void *y);
-int e_str_case_compare (const void *x,
- const void *y);
-int e_collate_compare (const void *x,
- const void *y);
-int e_int_compare (const void *x,
- const void *y);
-char *e_strdup_strip (const char *string);
-void e_free_object_list (GList *list);
-void e_free_object_slist (GSList *list);
-void e_free_string_list (GList *list);
-void e_free_string_slist (GSList *list);
-char *e_read_file (const char *filename);
-int e_write_file (const char *filename,
- const char *data,
- int flags);
-int e_write_file_uri (const char *filename,
- const char *data);
-int e_write_file_mkstemp (char *filename,
- const char *data);
-
-gchar **e_strsplit (const gchar *string,
- const gchar *delimiter,
- gint max_tokens);
-/* This only makes a filename safe for usage as a filename. It still may have shell meta-characters in it. */
-gchar *e_format_number (gint number);
-gchar *e_format_number_float (gfloat number);
-gboolean e_create_directory (gchar *directory);
-gchar **e_strdupv (const gchar **str_array);
-
-
-typedef int (*ESortCompareFunc) (const void *first,
- const void *second,
- gpointer closure);
-void e_sort (void *base,
- size_t nmemb,
- size_t size,
- ESortCompareFunc compare,
- gpointer closure);
-void e_bsearch (const void *key,
- const void *base,
- size_t nmemb,
- size_t size,
- ESortCompareFunc compare,
- gpointer closure,
- size_t *start,
- size_t *end);
-size_t e_strftime_fix_am_pm (char *s,
- size_t max,
- const char *fmt,
- const struct tm *tm);
-
-size_t e_utf8_strftime_fix_am_pm (char *s,
- size_t max,
- const char *fmt,
- const struct tm *tm);
+gint e_str_compare (gconstpointer x,
+ gconstpointer y);
+gint e_str_case_compare (gconstpointer x,
+ gconstpointer y);
+gint e_collate_compare (gconstpointer x,
+ gconstpointer y);
+gint e_int_compare (gconstpointer x,
+ gconstpointer y);
+gint e_write_file_uri (const gchar *filename,
+ const gchar *data);
+
+/* This only makes a filename safe for usage as a filename.
+ * It still may have shell meta-characters in it. */
+gchar * e_format_number (gint number);
+gchar * e_format_number_float (gfloat number);
+
+typedef gint (*ESortCompareFunc) (gconstpointer first,
+ gconstpointer second,
+ gpointer closure);
+
+void e_bsearch (gconstpointer key,
+ gconstpointer base,
+ gsize nmemb,
+ gsize size,
+ ESortCompareFunc compare,
+ gpointer closure,
+ gsize *start,
+ gsize *end);
+
+gsize e_strftime_fix_am_pm (gchar *str,
+ gsize max,
+ const gchar *fmt,
+ const struct tm *tm);
+gsize e_utf8_strftime_fix_am_pm (gchar *str,
+ gsize max,
+ const gchar *fmt,
+ const struct tm *tm);
/* String to/from double conversion functions */
-gdouble e_flexible_strtod (const gchar *nptr,
- gchar **endptr);
+gdouble e_flexible_strtod (const gchar *nptr,
+ gchar **endptr);
/* 29 bytes should enough for all possible values that
* g_ascii_dtostr can produce with the %.17g format.
* Then add 10 for good measure */
#define E_ASCII_DTOSTR_BUF_SIZE (DBL_DIG + 12 + 10)
-gchar *e_ascii_dtostr (gchar *buffer,
- gint buf_len,
- const gchar *format,
- gdouble d);
+gchar * e_ascii_dtostr (gchar *buffer,
+ gint buf_len,
+ const gchar *format,
+ gdouble d);
/* Alternating char * and int arguments with a NULL char * to end.
Less than 0 for the int means copy the whole string. */
-gchar *e_strdup_append_strings (gchar *first_string,
- ...);
-cairo_font_options_t * get_font_options ();
+gchar * e_strdup_append_strings (gchar *first_string,
+ ...);
+
+cairo_font_options_t * get_font_options (void);
-void e_file_update_save_path(char *uri, gboolean free);
-char *e_file_get_save_path(void);
+void e_file_update_save_path (gchar *uri,
+ gboolean free);
+gchar * e_file_get_save_path (void);
#ifdef __cplusplus
}
diff --git a/e-util/e-xml-utils.c b/e-util/e-xml-utils.c
index 5d83247d05..7f9f1870c8 100644
--- a/e-util/e-xml-utils.c
+++ b/e-util/e-xml-utils.c
@@ -36,6 +36,7 @@
#include <string.h>
#include <glib.h>
+#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include <libxml/parser.h>
#include <libxml/xmlmemory.h>
diff --git a/e-util/eggtrayicon.c b/e-util/eggtrayicon.c
index 6c4a20e96a..0c79810fa9 100644
--- a/e-util/eggtrayicon.c
+++ b/e-util/eggtrayicon.c
@@ -1253,8 +1253,7 @@ gtk_status_icon_init (GtkStatusIcon *status_icon)
gtk_widget_show (status_icon->priv->tray_icon);
status_icon->priv->tooltips = gtk_tooltips_new ();
- g_object_ref (status_icon->priv->tooltips);
- gtk_object_sink (GTK_OBJECT (status_icon->priv->tooltips));
+ g_object_ref_sink (status_icon->priv->tooltips);
#endif
#ifdef GDK_WINDOWING_WIN32