[pan2] leave g_atexit in for now.
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2] leave g_atexit in for now.
- Date: Fri, 4 May 2012 21:03:05 +0000 (UTC)
commit d9f90f9e3d97ddd5be0f17520bfb387c53a6b5ac
Author: Heinrich MÃlller <henmull src gnome org>
Date: Fri May 4 23:02:45 2012 +0200
leave g_atexit in for now.
pan/gui/body-pane.cc | 50 ++++++++++++++++++++++++--------------------------
1 files changed, 24 insertions(+), 26 deletions(-)
---
diff --git a/pan/gui/body-pane.cc b/pan/gui/body-pane.cc
index f4ea029..441d19a 100644
--- a/pan/gui/body-pane.cc
+++ b/pan/gui/body-pane.cc
@@ -53,6 +53,8 @@ using namespace pan;
****
***/
+/// TODO : replace g_atexit (deprecated)!!!
+
namespace
{
@@ -188,23 +190,21 @@ namespace
CURSOR_QTY
};
- GdkCursor ** cursors(0);
+ GdkCursor * cursors[CURSOR_QTY];
GdkCursor * cursor_current (0);
void free_cursors (void)
{
for (int i=0; i<CURSOR_QTY; ++i)
gdk_cursor_unref (cursors[i]);
- delete cursors;
- }
-
- void create_cursors()
- {
- cursors = new GdkCursor*[CURSOR_QTY];
}
- void init_cursors (GtkWidget * w)
+ void ensure_cursors_created (GtkWidget * w)
{
+ static bool created (false);
+ if (!created)
+ {
+ created = true;
GdkDisplay * display (gtk_widget_get_display (w));
int width, height;
@@ -239,11 +239,14 @@ 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)
{
- init_cursors(w);
+ ensure_cursors_created (w);
GdkCursor * cursor_new = cursors[mode];
if (cursor_new != cursor_current)
gdk_window_set_cursor (window, cursor_current=cursor_new);
@@ -617,7 +620,7 @@ namespace
// don't use this directly -- use get_emoticons()
pixbufs_t emoticon_pixbufs;
- void free_emoticons ()
+ void clear_emoticon_pixbufs ()
{
foreach_const (pixbufs_t, emoticon_pixbufs, it)
g_object_unref (it->second);
@@ -625,19 +628,20 @@ 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
@@ -1673,9 +1677,6 @@ 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..."));
@@ -1792,9 +1793,6 @@ 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]