[Xfce4-commits] <orage:master> 4.7.5.9: Using dynamic icon everywhere

Juha Kautto noreply at xfce.org
Sun Jan 3 12:06:01 CET 2010


Updating branch refs/heads/master
         to a8b4e8e983968947015304c4e42cdbaff104397a (commit)
       from 469a60c0b098314fc79b6ece79f5494dc584942d (commit)

commit a8b4e8e983968947015304c4e42cdbaff104397a
Author: Juha Kautto <juha at xfce.org>
Date:   Sun Jan 3 13:02:37 2010 +0200

    4.7.5.9: Using dynamic icon everywhere
    
    Instead of only using dynamic icon as tray icon, using it now everywhere.
    Made startp much faster.
    
    Fixed some more memory leaks and tuned code speed.

 NEWS             |    6 +++++
 configure.in.in  |    2 +-
 src/event-list.c |    2 +-
 src/functions.c  |    2 +-
 src/functions.h  |    2 +
 src/ical-code.c  |    2 +
 src/main.c       |    2 +-
 src/mainbox.c    |   11 ---------
 src/parameters.c |   12 +++++++++-
 src/reminder.c   |   52 +++++++++++++++++++++---------------------
 src/reminder.h   |    2 +-
 src/tray_icon.c  |   66 +++++++++++++++++++++++++++---------------------------
 src/tray_icon.h  |    2 +-
 13 files changed, 86 insertions(+), 77 deletions(-)

diff --git a/NEWS b/NEWS
index f004fd0..1c49098 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+20100103: Version 4.7.5.8
+---------
+        * Using dynamic icon everywhere instead of only as tray icon.
+        * Panel plugin setup interface changed. Instead of three fixed
+          rows, now it is possible to add/remove rows as needed.
+
 20091218: Version 4.7.5.3
 ---------
         * Possibility to create new alarm directly from Orage type alarm
diff --git a/configure.in.in b/configure.in.in
index 42636ba..5fc03b4 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -9,7 +9,7 @@ dnl Written for Xfce by Juha Kautto <juha at xfce.org>
 dnl
 
 dnl Version information
-m4_define([orage_version], [4.7.5.8-git])
+m4_define([orage_version], [4.7.5.9-git])
 
 m4_define([gtk_minimum_version], [2.10.0])
 m4_define([xfce_minimum_version], [4.6.0])
diff --git a/src/event-list.c b/src/event-list.c
index eea315a..4fb6426 100644
--- a/src/event-list.c
+++ b/src/event-list.c
@@ -1367,7 +1367,7 @@ el_win *create_el_win(char *start_date)
 
     gtk_drag_source_set(el->TreeView, GDK_BUTTON1_MASK
             , drag_targets, DRAG_TARGET_COUNT, GDK_ACTION_COPY);
-    pixbuf = orage_create_icon(TRUE, 16);
+    pixbuf = orage_create_icon(FALSE, 16);
     gtk_drag_source_set_icon_pixbuf(el->TreeView, pixbuf);
     g_object_unref(pixbuf);
     g_signal_connect(el->TreeView, "drag_data_get"
diff --git a/src/functions.c b/src/functions.c
index d58778a..37c286c 100644
--- a/src/functions.c
+++ b/src/functions.c
@@ -333,7 +333,7 @@ char *orage_process_text_commands(char *text)
     /* This is usefull in birthdays for example: I will be <&Y1980>
      * translates to "I will be 29" if the alarm is raised on 2009 */
     for (cur = text; cur && (cmd = strstr(cur, "<&Y")); cur = end) {
-        if (end = strstr(cmd, ">")) {
+        if ((end = strstr(cmd, ">"))) {
             end[0] = '\0'; /* temporarily. */
             res = sscanf(cmd, "<&Y%d", &start_year);
             end[0] = '>'; /* put it back. */
diff --git a/src/functions.h b/src/functions.h
index 07106c6..b0c7d3a 100644
--- a/src/functions.h
+++ b/src/functions.h
@@ -50,6 +50,8 @@ typedef struct _OrageRc
     void *rc;
 } OrageRc;
 
+void program_log (const char *format, ...);
+
 void orage_message(gint level, const char *format, ...);
 
 GtkWidget *orage_create_combo_box_with_content(char *text[], int size);
diff --git a/src/ical-code.c b/src/ical-code.c
index 09aef89..56bbc94 100644
--- a/src/ical-code.c
+++ b/src/ical-code.c
@@ -985,6 +985,7 @@ static void appt_add_alarm_internal_audio(xfical_appt *appt
                 , icalproperty_new_duration(
                         icaldurationtype_from_int(appt->soundrepeat_len)));
     }
+    icalattach_unref(attach);
 }
 
 /* emailprop  = 5*(
@@ -1054,6 +1055,7 @@ static void appt_add_alarm_internal_procedure(xfical_appt *appt
     if ORAGE_STR_EXISTS(appt->procedure_params)
         icalcomponent_add_property(ialarm
                 , icalproperty_new_description(appt->procedure_params));
+    icalattach_unref(attach);
 }
 
 /* Create new alarm and add trigger to it.
diff --git a/src/main.c b/src/main.c
index d5ed68a..2ca50dd 100644
--- a/src/main.c
+++ b/src/main.c
@@ -480,8 +480,8 @@ int main(int argc, char *argv[])
         gtk_widget_realize(((CalWin *)g_par.xfcal)->mWindow);
         gtk_widget_hide(((CalWin *)g_par.xfcal)->mWindow);
     }
-    reset_orage_day_change(FALSE); /* first day change after we start */
     alarm_read();
+    orage_day_change(FALSE); /* first day change after we start */
     mCalendar_month_changed_cb(
             (GtkCalendar *)((CalWin *)g_par.xfcal)->mCalendar, NULL);
 
diff --git a/src/mainbox.c b/src/mainbox.c
index 501811a..eff306b 100644
--- a/src/mainbox.c
+++ b/src/mainbox.c
@@ -708,7 +708,6 @@ void build_mainWin()
 {
 #undef P_N
 #define P_N "build_mainWin: "
-    GdkPixbuf *orage_logo;
     CalWin *cal = (CalWin *)g_par.xfcal;
     GdkColormap *pic1_cmap;
 
@@ -721,10 +720,6 @@ void build_mainWin()
     gdk_color_parse("blue", &cal->mBlue);
     gdk_colormap_alloc_color(pic1_cmap, &cal->mBlue, FALSE, TRUE);
 
-    /* using static icon here since this dynamic icon is not updated
-     * when date changes. Could be added, but not worth it.
-     * Dynamic icon is used in systray and about windows */
-    orage_logo = orage_create_icon(TRUE, 48); 
     cal->mAccel_group = gtk_accel_group_new();
     cal->Tooltips = gtk_tooltips_new();
 
@@ -733,12 +728,6 @@ void build_mainWin()
     gtk_window_set_resizable(GTK_WINDOW(cal->mWindow), TRUE);
     gtk_window_set_destroy_with_parent(GTK_WINDOW(cal->mWindow), TRUE);
 
-    if (orage_logo != NULL) {
-        gtk_window_set_icon(GTK_WINDOW(cal->mWindow), orage_logo);
-        gtk_window_set_default_icon(orage_logo);
-        g_object_unref(orage_logo);
-    }
-
     /* Build the vertical box */
     cal->mVbox = gtk_vbox_new(FALSE, 0);
     gtk_container_add(GTK_CONTAINER(cal->mWindow), cal->mVbox);
diff --git a/src/parameters.c b/src/parameters.c
index d36f817..ebf9951 100644
--- a/src/parameters.c
+++ b/src/parameters.c
@@ -352,9 +352,13 @@ static void pager_changed(GtkWidget *dialog, gpointer user_data)
 
 static void set_systray()
 {
+    GdkPixbuf *orage_logo;
+
     if (!(g_par.trayIcon 
     && gtk_status_icon_is_embedded((GtkStatusIcon *)g_par.trayIcon))) {
-        g_par.trayIcon = create_TrayIcon();
+        orage_logo = orage_create_icon(FALSE, 0);
+        g_par.trayIcon = create_TrayIcon(orage_logo);
+        g_object_unref(orage_logo);
     }
 
     if (g_par.show_systray)
@@ -852,6 +856,7 @@ static void create_parameter_dialog_extra_setup_tab(Itf *dialog)
 Itf *create_parameter_dialog()
 {
     Itf *dialog;
+    GdkPixbuf *orage_logo;
 
     dialog = g_new(Itf, 1);
     dialog->Tooltips = gtk_tooltips_new();
@@ -864,7 +869,12 @@ Itf *create_parameter_dialog()
             , GTK_WIN_POS_CENTER);
     gtk_window_set_modal(GTK_WINDOW(dialog->orage_dialog), FALSE);
     gtk_window_set_resizable(GTK_WINDOW(dialog->orage_dialog), TRUE);
+    orage_logo = orage_create_icon(FALSE, 48);
+    gtk_window_set_icon(GTK_WINDOW(dialog->orage_dialog), orage_logo);
+    g_object_unref(orage_logo);
+    /*
     gtk_window_set_icon_name(GTK_WINDOW(dialog->orage_dialog), "xfcalendar");
+    */
 
     gtk_dialog_set_has_separator(GTK_DIALOG(dialog->orage_dialog), FALSE);
 
diff --git a/src/reminder.c b/src/reminder.c
index e53c457..681d157 100644
--- a/src/reminder.c
+++ b/src/reminder.c
@@ -833,10 +833,34 @@ void create_reminders(alarm_struct *alarm)
         create_procedure_reminder(n_alarm);
 }
 
+static void reset_orage_day_change(gboolean changed)
+{
+#undef P_N
+#define P_N "reset_orage_day_change: "
+    struct tm *t;
+    gint secs_left;
+
+#ifdef ORAGE_DEBUG
+    orage_message(-100, P_N);
+#endif
+    if (changed) { /* date was change, need to count next change time */
+        t = orage_localtime();
+        /* t format is 23:59:59 -> 00:00:00 so we can use 
+         * 24:00:00 to represent next day.
+         * Let's find out how much time we have until it happens */
+        secs_left = 60*60*(24 - t->tm_hour) - 60*t->tm_min - t->tm_sec;
+    }
+    else { /* the change did not happen. Need to try again asap. */
+        secs_left = 1;
+    }
+    g_par.day_timer = g_timeout_add_seconds(secs_left
+            , (GtkFunction) orage_day_change, NULL);
+}
+
 /* fire after the date has changed and setup the icon 
  * and change the date in the mainwindow
  */
-static gboolean orage_day_change(gpointer user_data)
+gboolean orage_day_change(gpointer user_data)
 {
 #undef P_N
 #define P_N "orage_day_change: "
@@ -873,7 +897,7 @@ static gboolean orage_day_change(gpointer user_data)
         previous_day   = current_day;
         refresh_TrayIcon();
         xfical_alarm_build_list(TRUE);  /* new alarm list when date changed */
-        reset_orage_day_change(TRUE); /* setup for next time */
+        reset_orage_day_change(TRUE);   /* setup for next time */
     }
     else { 
         /* we should very seldom come here since we schedule us to happen
@@ -885,30 +909,6 @@ static gboolean orage_day_change(gpointer user_data)
     return(FALSE); /* we started new timer, so we end here */
 }
 
-void reset_orage_day_change(gboolean changed)
-{
-#undef P_N
-#define P_N "reset_orage_day_change: "
-    struct tm *t;
-    gint secs_left;
-
-#ifdef ORAGE_DEBUG
-    orage_message(-100, P_N);
-#endif
-    if (changed) { /* date was change, need to count next change time */
-        t = orage_localtime();
-        /* t format is 23:59:59 -> 00:00:00 so we can use 
-         * 24:00:00 to represent next day.
-         * Let's find out how much time we have until it happens */
-        secs_left = 60*60*(24 - t->tm_hour) - 60*t->tm_min - t->tm_sec;
-    }
-    else { /* the change did not happen. Need to try again asap. */
-        secs_left = 1;
-    }
-    g_par.day_timer = g_timeout_add_seconds(secs_left
-            , (GtkFunction) orage_day_change, NULL);
-}
-
 /* check and raise alarms if there are any */
 static gboolean orage_alarm_clock(gpointer user_data)
 {
diff --git a/src/reminder.h b/src/reminder.h
index a0a0d66..5c30a57 100644
--- a/src/reminder.h
+++ b/src/reminder.h
@@ -68,7 +68,7 @@ typedef struct _alarm_struct
     gpointer orage_display_data;
 } alarm_struct;
 
-void reset_orage_day_change(gboolean changed);
+gboolean orage_day_change(gpointer user_data);
 void setup_orage_alarm_clock(void);
 void alarm_add(alarm_struct *alarm);
 void alarm_read();
diff --git a/src/tray_icon.c b/src/tray_icon.c
index 0a510da..4cf5b43 100644
--- a/src/tray_icon.c
+++ b/src/tray_icon.c
@@ -106,7 +106,7 @@ void create_icon_pango_layout(gint line, PangoLayout *pl, struct tm *t
     gchar *row1_2_data = "%^a";
     gchar *row1_2b_data = "%a";
     gchar *row1_color = "black";
-    gchar *row1_font = "Ariel bold 24";
+    gchar *row1_font = "Ariel 24";
     gchar *row2_color = "red";
     gchar *row2_font = "Sans bold 72";
     gchar *row3_1_data = "%^B";
@@ -114,7 +114,7 @@ void create_icon_pango_layout(gint line, PangoLayout *pl, struct tm *t
     gchar *row3_2_data = "%^b";
     gchar *row3_2b_data = "%b";
     gchar *row3_color = "black";
-    gchar *row3_font = "Ariel bold 26";
+    gchar *row3_font = "Ariel 26";
     gchar *row_format = "<span foreground=\"%s\" font_desc=\"%s\">%s</span>";
     gchar *strfttime_failed = "create_icon_pango_layout: strftime %s failed";
 
@@ -241,7 +241,6 @@ GdkPixbuf *orage_create_icon(gboolean static_icon, gint size)
     gint x_offset_day = 0, y_offset_day = 0, y_size_day = 0;
     gint x_offset_weekday = 0, y_offset_weekday = 0, y_size_weekday = 0;
     gint x_offset_month = 0, y_offset_month = 0, y_size_month = 0;
-    gboolean draw_dynamic = FALSE;
 
     icon_theme = gtk_icon_theme_get_default();
     if (static_icon || !g_par.use_dynamic_icon) {
@@ -250,8 +249,7 @@ GdkPixbuf *orage_create_icon(gboolean static_icon, gint size)
         return(pixbuf);
     }
 
-    /* dynamic icon build starts now */
-    draw_dynamic = TRUE;
+    /***** dynamic icon build starts now *****/
     t = orage_localtime();
     width = 160; 
     height = 160;
@@ -300,42 +298,40 @@ GdkPixbuf *orage_create_icon(gboolean static_icon, gint size)
 
     /* weekday */
     create_icon_pango_layout(1, pl_weekday, t
-            , width-x_used, height-y_used
+            , width - x_used, height - y_used
             , &x_offset_weekday, &y_offset_weekday, &y_size_weekday);
 
     /* day */
     create_icon_pango_layout(2, pl_day, t
-            , width-x_used, height-y_used
+            , width - x_used, height - y_used
             , &x_offset_day, &y_offset_day, &y_size_day);
 
     /* month */
     create_icon_pango_layout(3, pl_month, t
-            , width-x_used, height-y_used
+            , width - x_used, height - y_used
             , &x_offset_month, &y_offset_month, &y_size_month);
 
-    if (draw_dynamic) {
-        gdk_draw_layout(pic1, pic1_gc1, x_offset_weekday, y_offset_weekday
-                , pl_weekday);
-        gdk_draw_layout(pic1, pic1_gc1, x_offset_day, y_offset_day, pl_day);
-        gdk_draw_layout(pic1, pic1_gc1, x_offset_month, y_offset_month
-                , pl_month);
-        pixbuf = gdk_pixbuf_get_from_drawable(NULL, pic1, pic1_cmap
-                , 0, 0, 0, 0, width, height);
-        if (size) {
-            pixbuf2 = gdk_pixbuf_scale_simple(pixbuf, size, size
-                    , GDK_INTERP_BILINEAR);
-            g_object_unref(pixbuf);
-            pixbuf = pixbuf2;
-        }
+    gdk_draw_layout(pic1, pic1_gc1, x_offset_weekday, y_offset_weekday
+            , pl_weekday);
+    gdk_draw_layout(pic1, pic1_gc1, x_offset_day, y_offset_day
+            , pl_day);
+    gdk_draw_layout(pic1, pic1_gc1, x_offset_month, y_offset_month
+            , pl_month);
+    pixbuf = gdk_pixbuf_get_from_drawable(NULL, pic1, pic1_cmap
+            , 0, 0, 0, 0, width, height);
+    if (size) {
+        pixbuf2 = gdk_pixbuf_scale_simple(pixbuf, size, size
+                , GDK_INTERP_BILINEAR);
+        g_object_unref(pixbuf);
+        pixbuf = pixbuf2;
     }
-    else {
+
+    if (pixbuf == NULL) {
+        g_warning("orage_create_icon: dynamic icon creation failed\n");
         pixbuf = gtk_icon_theme_load_icon(icon_theme, "xfcalendar", size
                 , GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
     }
 
-    if (pixbuf == NULL)
-        g_warning("orage_create_icon: load failed\n");
-
     g_object_unref(pic1_gc1);
     g_object_unref(pic1_gc2);
     g_object_unref(pl_day);
@@ -408,12 +404,11 @@ void destroy_TrayIcon(GtkStatusIcon *trayIcon)
     g_object_unref(trayIcon);
 }
 
-GtkStatusIcon* create_TrayIcon()
+GtkStatusIcon* create_TrayIcon(GdkPixbuf *orage_logo)
 {
     CalWin *xfcal = (CalWin *)g_par.xfcal;
     GtkWidget *trayMenu;
     GtkStatusIcon *trayIcon = NULL;
-    GdkPixbuf *pixbuf;
 
     /*
      * Create the tray icon popup menu
@@ -423,12 +418,9 @@ GtkStatusIcon* create_TrayIcon()
     /*
      * Create the tray icon
      */
-    pixbuf = orage_create_icon(FALSE, 0); /* 0 = no scaling */
-    trayIcon = gtk_status_icon_new_from_pixbuf(pixbuf);
-
+    trayIcon = gtk_status_icon_new_from_pixbuf(orage_logo);
     g_object_ref(trayIcon);
     g_object_ref_sink(trayIcon);
-    g_object_unref(pixbuf);
 
     g_signal_connect(G_OBJECT(trayIcon), "activate",
     			   G_CALLBACK(toggle_visible_cb), xfcal);
@@ -439,12 +431,20 @@ GtkStatusIcon* create_TrayIcon()
 
 void refresh_TrayIcon()
 {
+    GdkPixbuf *orage_logo;
+
+    orage_logo = orage_create_icon(FALSE, 0);
     if (g_par.show_systray) { /* refresh tray icon */
         if (ORAGE_TRAYICON && gtk_status_icon_is_embedded(ORAGE_TRAYICON)) {
             gtk_status_icon_set_visible(ORAGE_TRAYICON, FALSE);
             destroy_TrayIcon(ORAGE_TRAYICON);
         }
-        g_par.trayIcon = create_TrayIcon();
+        g_par.trayIcon = create_TrayIcon(orage_logo);
         gtk_status_icon_set_visible(ORAGE_TRAYICON, TRUE);
     }
+    gtk_window_set_default_icon(orage_logo);
+    /* main window is always active so we need to change it's icon also */
+    gtk_window_set_icon(GTK_WINDOW(((CalWin *)g_par.xfcal)->mWindow)
+            , orage_logo);
+    g_object_unref(orage_logo);
 }
diff --git a/src/tray_icon.h b/src/tray_icon.h
index f4b8730..7321189 100644
--- a/src/tray_icon.h
+++ b/src/tray_icon.h
@@ -26,7 +26,7 @@
 
 GdkPixbuf *orage_create_icon(gboolean static_icon, gint size);
 
-GtkStatusIcon *create_TrayIcon(void);
+GtkStatusIcon *create_TrayIcon(GdkPixbuf *orage_logo);
 
 void refresh_TrayIcon(void);
 



More information about the Xfce4-commits mailing list