[pan2] get rid of deprecated g_atexit() calls.
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2] get rid of deprecated g_atexit() calls.
- Date: Thu, 3 May 2012 17:33:13 +0000 (UTC)
commit f7d917d4cbecab754b6cb6cb032fbd0705896e90
Author: Heinrich MÃlller <henmull src gnome org>
Date: Thu May 3 19:32:40 2012 +0200
get rid of deprecated g_atexit() calls.
pan/gui/body-pane.cc | 50 ++++++++++++++++++++++++++------------------------
1 files changed, 26 insertions(+), 24 deletions(-)
---
diff --git a/pan/gui/body-pane.cc b/pan/gui/body-pane.cc
index 365d29c..f4ea029 100644
--- a/pan/gui/body-pane.cc
+++ b/pan/gui/body-pane.cc
@@ -53,8 +53,6 @@ using namespace pan;
****
***/
-/// TODO : replace g_atexit (deprecated)
-
namespace
{
@@ -190,21 +188,23 @@ namespace
CURSOR_QTY
};
- GdkCursor * cursors[CURSOR_QTY];
+ GdkCursor ** cursors(0);
GdkCursor * cursor_current (0);
void free_cursors (void)
{
for (int i=0; i<CURSOR_QTY; ++i)
gdk_cursor_unref (cursors[i]);
+ delete cursors;
}
- void ensure_cursors_created (GtkWidget * w)
+ void create_cursors()
+ {
+ cursors = new GdkCursor*[CURSOR_QTY];
+ }
+
+ void init_cursors (GtkWidget * w)
{
- static bool created (false);
- if (!created)
- {
- created = true;
GdkDisplay * display (gtk_widget_get_display (w));
int width, height;
@@ -239,14 +239,11 @@ namespace
cursors[CURSOR_IBEAM] = gdk_cursor_new (GDK_XTERM);
cursors[CURSOR_HREF] = gdk_cursor_new (GDK_HAND2);
-
- g_atexit (free_cursors);
- }
}
void set_cursor (GdkWindow *window, GtkWidget *w, int mode)
{
- ensure_cursors_created (w);
+ init_cursors(w);
GdkCursor * cursor_new = cursors[mode];
if (cursor_new != cursor_current)
gdk_window_set_cursor (window, cursor_current=cursor_new);
@@ -620,7 +617,7 @@ namespace
// don't use this directly -- use get_emoticons()
pixbufs_t emoticon_pixbufs;
- void clear_emoticon_pixbufs ()
+ void free_emoticons ()
{
foreach_const (pixbufs_t, emoticon_pixbufs, it)
g_object_unref (it->second);
@@ -628,20 +625,19 @@ namespace
pixbufs_t& get_emoticons ()
{
- static bool inited (false);
- if (!inited) {
- inited = true;
- emoticon_pixbufs[":)"] = gdk_pixbuf_new_from_inline (-1, icon_mozilla_smile, false, 0);
- emoticon_pixbufs[":-)"] = gdk_pixbuf_new_from_inline (-1, icon_mozilla_smile, false, 0);
- emoticon_pixbufs[";)"] = gdk_pixbuf_new_from_inline (-1, icon_mozilla_wink, false, 0);
- emoticon_pixbufs[":("] = gdk_pixbuf_new_from_inline (-1, icon_mozilla_frown, false, 0);
- emoticon_pixbufs[":P"] = gdk_pixbuf_new_from_inline (-1, icon_mozilla_tongueout, false, 0);
- emoticon_pixbufs[":O"] = gdk_pixbuf_new_from_inline (-1, icon_mozilla_surprised, false, 0);
- g_atexit (clear_emoticon_pixbufs);
- }
return emoticon_pixbufs;
}
+ void create_emoticons()
+ {
+ emoticon_pixbufs[":)"] = gdk_pixbuf_new_from_inline (-1, icon_mozilla_smile, false, 0);
+ emoticon_pixbufs[":-)"] = gdk_pixbuf_new_from_inline (-1, icon_mozilla_smile, false, 0);
+ emoticon_pixbufs[";)"] = gdk_pixbuf_new_from_inline (-1, icon_mozilla_wink, false, 0);
+ emoticon_pixbufs[":("] = gdk_pixbuf_new_from_inline (-1, icon_mozilla_frown, false, 0);
+ emoticon_pixbufs[":P"] = gdk_pixbuf_new_from_inline (-1, icon_mozilla_tongueout, false, 0);
+ emoticon_pixbufs[":O"] = gdk_pixbuf_new_from_inline (-1, icon_mozilla_surprised, false, 0);
+ }
+
enum TagMode { ADD, REPLACE };
void
@@ -1677,6 +1673,9 @@ BodyPane :: BodyPane (Data& data, ArticleCache& cache, Prefs& prefs, GroupPrefs
for (guint i=0; i<NUM_ICONS; ++i)
icons[i].pixbuf = gdk_pixbuf_new_from_inline (-1, icons[i].pixbuf_txt, FALSE, 0);
+ create_cursors();
+ create_emoticons();
+
// menu for popup menu for attachments
_menu = gtk_menu_new ();
l = gtk_menu_item_new_with_label(_("Save Attachment As..."));
@@ -1793,6 +1792,9 @@ BodyPane :: ~BodyPane ()
foreach (std::set<char*>, _attach_names, it)
g_free(*it);
+
+ free_emoticons();
+ free_cursors();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]