[Xfce4-commits] <orage:master> Minor changes to tray icon

Juha Kautto noreply at xfce.org
Thu Nov 26 16:14:01 CET 2009


Updating branch refs/heads/master
         to 6e10754143b10141562c407ea89fc03328bcc7ca (commit)
       from d8f9634a484289340aad99f7dd2a674d7894bd79 (commit)

commit 6e10754143b10141562c407ea89fc03328bcc7ca
Author: Juha Kautto <juha at xfce.org>
Date:   Thu Nov 26 17:09:19 2009 +0200

    Minor changes to tray icon
    
    1) More beutifull tray icon (fixed bug 4667)
    2) More beatifull tray icon tooltip with colour and bold
    3) Replaced trayicon size parameters with on/off flag for using dynamic icon

 INSTALL                |  156 ++++++++++++++++-------
 NEWS                   |    6 +
 configure.in.in        |    2 +-
 src/about-xfcalendar.c |    2 +-
 src/event-list.c       |    2 +-
 src/mainbox.c          |    2 +-
 src/parameters.c       |   76 ++++--------
 src/parameters.h       |    2 +-
 src/reminder.c         |   23 +++-
 src/tray_icon.c        |  336 +++++++++++++++++++++++++++---------------------
 src/tray_icon.h        |    2 +-
 11 files changed, 360 insertions(+), 249 deletions(-)

diff --git a/INSTALL b/INSTALL
index 23e5f25..2550dab 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,16 +1,19 @@
 Installation Instructions
 *************************
 
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
-Software Foundation, Inc.
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
-This file is free documentation; the Free Software Foundation gives
+   This file is free documentation; the Free Software Foundation gives
 unlimited permission to copy, distribute and modify it.
 
 Basic Installation
 ==================
 
-These are generic installation instructions.
+   Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
 
    The `configure' shell script attempts to guess correct values for
 various system-dependent variables used during compilation.  It uses
@@ -23,9 +26,9 @@ debugging `configure').
 
    It can also use an optional file (typically called `config.cache'
 and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring.  (Caching is
+the results of its tests to speed up reconfiguring.  Caching is
 disabled by default to prevent problems with accidental use of stale
-cache files.)
+cache files.
 
    If you need to do unusual things to compile the package, please try
 to figure out how `configure' could check whether to do them, and mail
@@ -35,20 +38,17 @@ some point `config.cache' contains results you don't want to keep, you
 may remove or edit it.
 
    The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'.  You only need
-`configure.ac' if you want to change it or regenerate `configure' using
-a newer version of `autoconf'.
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
 
 The simplest way to compile this package is:
 
   1. `cd' to the directory containing the package's source code and type
-     `./configure' to configure the package for your system.  If you're
-     using `csh' on an old version of System V, you might need to type
-     `sh ./configure' instead to prevent `csh' from trying to execute
-     `configure' itself.
+     `./configure' to configure the package for your system.
 
-     Running `configure' takes awhile.  While running, it prints some
-     messages telling which features it is checking for.
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
 
   2. Type `make' to compile the package.
 
@@ -67,42 +67,57 @@ The simplest way to compile this package is:
      all sorts of other programs in order to regenerate files that came
      with the distribution.
 
+  6. Often, you can also type `make uninstall' to remove the installed
+     files again.
+
 Compilers and Options
 =====================
 
-Some systems require unusual options for compilation or linking that the
-`configure' script does not know about.  Run `./configure --help' for
-details on some of the pertinent environment variables.
+   Some systems require unusual options for compilation or linking that
+the `configure' script does not know about.  Run `./configure --help'
+for details on some of the pertinent environment variables.
 
    You can give `configure' initial values for configuration parameters
 by setting variables in the command line or in the environment.  Here
 is an example:
 
-     ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
 
    *Note Defining Variables::, for more details.
 
 Compiling For Multiple Architectures
 ====================================
 
-You can compile the package for more than one kind of computer at the
+   You can compile the package for more than one kind of computer at the
 same time, by placing the object files for each architecture in their
-own directory.  To do this, you must use a version of `make' that
-supports the `VPATH' variable, such as GNU `make'.  `cd' to the
+own directory.  To do this, you can use GNU `make'.  `cd' to the
 directory where you want the object files and executables to go and run
 the `configure' script.  `configure' automatically checks for the
 source code in the directory that `configure' is in and in `..'.
 
-   If you have to use a `make' that does not support the `VPATH'
-variable, you have to compile the package for one architecture at a
-time in the source code directory.  After you have installed the
-package for one architecture, use `make distclean' before reconfiguring
-for another architecture.
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+   On MacOS X 10.5 and later systems, you can create libraries and
+executables that work on multiple system types--known as "fat" or
+"universal" binaries--by specifying multiple `-arch' options to the
+compiler but only a single `-arch' option to the preprocessor.  Like
+this:
+
+     ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+                 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+                 CPP="gcc -E" CXXCPP="g++ -E"
+
+   This is not guaranteed to produce working output in all cases, you
+may have to build one architecture at a time and combine the results
+using the `lipo' tool if you have problems.
 
 Installation Names
 ==================
 
-By default, `make install' installs the package's commands under
+   By default, `make install' installs the package's commands under
 `/usr/local/bin', include files under `/usr/local/include', etc.  You
 can specify an installation prefix other than `/usr/local' by giving
 `configure' the option `--prefix=PREFIX'.
@@ -125,7 +140,7 @@ option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
 Optional Features
 =================
 
-Some packages pay attention to `--enable-FEATURE' options to
+   Some packages pay attention to `--enable-FEATURE' options to
 `configure', where FEATURE indicates an optional part of the package.
 They may also pay attention to `--with-PACKAGE' options, where PACKAGE
 is something like `gnu-as' or `x' (for the X Window System).  The
@@ -137,14 +152,46 @@ find the X include and library files automatically, but if it doesn't,
 you can use the `configure' options `--x-includes=DIR' and
 `--x-libraries=DIR' to specify their locations.
 
+Particular systems
+==================
+
+   On HP-UX, the default C compiler is not ANSI C compatible.  If GNU
+CC is not installed, it is recommended to use the following options in
+order to use an ANSI C compiler:
+
+     ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
+
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+
+   On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
+parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
+a workaround.  If GNU CC is not installed, it is therefore recommended
+to try
+
+     ./configure CC="cc"
+
+and if that doesn't work, try
+
+     ./configure CC="cc -nodtk"
+
+   On Solaris, don't put `/usr/ucb' early in your `PATH'.  This
+directory contains several dysfunctional programs; working variants of
+these programs are available in `/usr/bin'.  So, if you need `/usr/ucb'
+in your `PATH', put it _after_ `/usr/bin'.
+
+   On Haiku, software installed for all users goes in `/boot/common',
+not `/usr/local'.  It is recommended to use the following options:
+
+     ./configure --prefix=/boot/common
+
 Specifying the System Type
 ==========================
 
-There may be some features `configure' cannot figure out automatically,
-but needs to determine by the type of machine the package will run on.
-Usually, assuming the package is built to be run on the _same_
-architectures, `configure' can figure that out, but if it prints a
-message saying it cannot guess the machine type, give it the
+   There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on.  Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
 `--build=TYPE' option.  TYPE can either be a short name for the system
 type, such as `sun4', or a canonical name which has the form:
 
@@ -152,7 +199,8 @@ type, such as `sun4', or a canonical name which has the form:
 
 where SYSTEM can have one of these forms:
 
-     OS KERNEL-OS
+     OS
+     KERNEL-OS
 
    See the file `config.sub' for the possible values of each field.  If
 `config.sub' isn't included in this package, then this package doesn't
@@ -170,9 +218,9 @@ eventually be run) with `--host=TYPE'.
 Sharing Defaults
 ================
 
-If you want to set default values for `configure' scripts to share, you
-can create a site shell script called `config.site' that gives default
-values for variables like `CC', `cache_file', and `prefix'.
+   If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
 `configure' looks for `PREFIX/share/config.site' if it exists, then
 `PREFIX/etc/config.site' if it exists.  Or, you can set the
 `CONFIG_SITE' environment variable to the location of the site script.
@@ -181,7 +229,7 @@ A warning: not all `configure' scripts look for a site script.
 Defining Variables
 ==================
 
-Variables not defined in a site shell script can be set in the
+   Variables not defined in a site shell script can be set in the
 environment passed to `configure'.  However, some packages may run
 configure again during the build, and the customized values of these
 variables may be lost.  In order to avoid this problem, you should set
@@ -190,21 +238,29 @@ them in the `configure' command line, using `VAR=value'.  For example:
      ./configure CC=/usr/local2/bin/gcc
 
 causes the specified `gcc' to be used as the C compiler (unless it is
-overridden in the site shell script).  Here is a another example:
+overridden in the site shell script).
 
-     /bin/bash ./configure CONFIG_SHELL=/bin/bash
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
 
-Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
-configuration-related scripts to be executed by `/bin/bash'.
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
 
 `configure' Invocation
 ======================
 
-`configure' recognizes the following options to control how it operates.
+   `configure' recognizes the following options to control how it
+operates.
 
 `--help'
 `-h'
-     Print a summary of the options to `configure', and exit.
+     Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+     Print a summary of the options unique to this package's
+     `configure', and exit.  The `short' variant lists options used
+     only in the top level, while the `recursive' variant lists options
+     also present in any nested packages.
 
 `--version'
 `-V'
@@ -231,6 +287,16 @@ configuration-related scripts to be executed by `/bin/bash'.
      Look for the package's source code in directory DIR.  Usually
      `configure' can determine that directory automatically.
 
+`--prefix=DIR'
+     Use DIR as the installation prefix.  *Note Installation Names::
+     for more details, including other options available for fine-tuning
+     the installation locations.
+
+`--no-create'
+`-n'
+     Run the configure checks, but stop before creating any output
+     files.
+
 `configure' also accepts some other, not widely useful, options.  Run
 `configure --help' for more details.
 
diff --git a/NEWS b/NEWS
index 18e5e40..c73a8c2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+20091127: Minor enhancements to tray icon
+---------
+        * Better looking tray icon (bug 4667).
+        * Try icon Size is fully automatic so size parameters removed.
+        * Try icon tooltip better looking with colour and bold time.
+
 20091030: Minor enhancements
 ---------
         * Possible to change the size of main calendar window (Bug 5890).
diff --git a/configure.in.in b/configure.in.in
index b717e14..2bc6ea3 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.4.10-test])
+m4_define([orage_version], [4.7.4.11-test])
 
 m4_define([gtk_minimum_version], [2.10.0])
 m4_define([xfce_minimum_version], [4.6.0])
diff --git a/src/about-xfcalendar.c b/src/about-xfcalendar.c
index 220c42e..c1147df 100644
--- a/src/about-xfcalendar.c
+++ b/src/about-xfcalendar.c
@@ -42,7 +42,7 @@ void create_wAbout(GtkWidget *widget, gpointer user_data)
           , _("Manage your time with Xfce4")
           , XFCE_COPYRIGHT_TEXT("2003-2008", " Juha Kautto")
           , XFCE_LICENSE_GPL);
-  orage_logo = orage_create_icon(FALSE, 48, 48);
+  orage_logo = orage_create_icon(FALSE, 48);
   xfce_about_info_set_homepage(about, "http://www.xfce.org");
 
   /* Credits */
diff --git a/src/event-list.c b/src/event-list.c
index fa40f79..eea315a 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, 16);
+    pixbuf = orage_create_icon(TRUE, 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/mainbox.c b/src/mainbox.c
index 30a7ba6..01de81f 100644
--- a/src/mainbox.c
+++ b/src/mainbox.c
@@ -722,7 +722,7 @@ void build_mainWin()
     /* 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, 48); 
+    orage_logo = orage_create_icon(TRUE, 48); 
     cal->mAccel_group = gtk_accel_group_new();
     cal->Tooltips = gtk_tooltips_new();
 
diff --git a/src/parameters.c b/src/parameters.c
index 9f05a15..490123d 100644
--- a/src/parameters.c
+++ b/src/parameters.c
@@ -62,6 +62,7 @@ typedef struct _Itf
     GtkWidget *notebook;
 
     /* Tabs */
+    /***** Main Tab *****/
     GtkWidget *setup_tab;
     GtkWidget *setup_tab_label;
     GtkWidget *setup_vbox;
@@ -78,6 +79,7 @@ typedef struct _Itf
     GtkWidget *sound_application_entry;
     GtkWidget *sound_application_open_button;
 
+    /***** Display Tab *****/
     GtkWidget *display_tab;
     GtkWidget *display_tab_label;
     GtkWidget *display_vbox;
@@ -103,27 +105,24 @@ typedef struct _Itf
     GtkWidget *visibility_hide_radiobutton;
     GtkWidget *visibility_minimized_radiobutton;
 
+    /***** Extra Tab *****/
     GtkWidget *extra_tab;
     GtkWidget *extra_tab_label;
     GtkWidget *extra_vbox;
     /* select_always_today */
     GtkWidget *always_today_frame;
     GtkWidget *always_today_checkbutton;
-
     /* icon size */
     GtkWidget *icon_size_frame;
-    GtkWidget *icon_size_x_spin;
-    GtkWidget *icon_size_y_spin;
+    GtkWidget *use_dynamic_icon_checkbutton;
     /* show event/days window from main calendar */
     GtkWidget *click_to_show_frame;
     GSList    *click_to_show_radiobutton_group;
     GtkWidget *click_to_show_days_radiobutton;
     GtkWidget *click_to_show_events_radiobutton;
-
     /* eventlist window number of extra days to show */
     GtkWidget *el_extra_days_frame;
     GtkWidget *el_extra_days_spin;
-
     /* the rest */
     GtkWidget *close_button;
     GtkWidget *help_button;
@@ -454,21 +453,13 @@ static void always_today_changed(GtkWidget *dialog, gpointer user_data)
             GTK_TOGGLE_BUTTON(itf->always_today_checkbutton));
 }
 
-static void set_icon_size()
+static void use_dynamic_icon_changed(GtkWidget *dialog, gpointer user_data)
 {
-    refresh_TrayIcon();
-}
-
-static void icon_size_x_spin_changed(GtkSpinButton *sb, gpointer user_data)
-{
-    g_par.icon_size_x = gtk_spin_button_get_value(sb);
-    set_icon_size();
-}
+    Itf *itf = (Itf *)user_data;
 
-static void icon_size_y_spin_changed(GtkSpinButton *sb, gpointer user_data)
-{
-    g_par.icon_size_y = gtk_spin_button_get_value(sb);
-    set_icon_size();
+    g_par.use_dynamic_icon = gtk_toggle_button_get_active(
+            GTK_TOGGLE_BUTTON(itf->use_dynamic_icon_checkbutton));
+    refresh_TrayIcon();
 }
 
 static void el_extra_days_spin_changed(GtkSpinButton *sb, gpointer user_data)
@@ -777,43 +768,24 @@ static void create_parameter_dialog_extra_setup_tab(Itf *dialog)
     g_signal_connect(G_OBJECT(dialog->always_today_checkbutton), "toggled"
             , G_CALLBACK(always_today_changed), dialog);
 
-    /***** tray icon size  (0 = use static icon) *****/
-    vbox = gtk_vbox_new(FALSE, 0);
+    /***** use dynamic tray icon *****/
+    hbox = gtk_vbox_new(FALSE, 0);
     dialog->icon_size_frame = orage_create_framebox_with_content(
-            _("Dynamic icon size"), vbox);
+            _("Use dynamic tray icon"), hbox);
     gtk_box_pack_start(GTK_BOX(dialog->extra_vbox)
             , dialog->icon_size_frame, FALSE, FALSE, 5);
 
-    hbox = gtk_hbox_new(FALSE, 0);
-    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
-    label = gtk_label_new("X:");
-    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
-    dialog->icon_size_x_spin = gtk_spin_button_new_with_range(0, 128, 1);
+    dialog->use_dynamic_icon_checkbutton = 
+            gtk_check_button_new_with_mnemonic(_("Use dynamic icon"));
     gtk_box_pack_start(GTK_BOX(hbox)
-            , dialog->icon_size_x_spin, FALSE, FALSE, 5);
-    gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->icon_size_x_spin)
-            , g_par.icon_size_x);
-    label = gtk_label_new(_("(0 = use static icon)"));
-    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
-    gtk_tooltips_set_tip(dialog->Tooltips, dialog->icon_size_x_spin
-            , _("Dynamic icon shows current day and month. It is visible only in tray. If tray is too small for dynamic icon size, Orage switches automatically back to static icon.")
+            , dialog->use_dynamic_icon_checkbutton, FALSE, FALSE, 5);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
+            dialog->use_dynamic_icon_checkbutton), g_par.use_dynamic_icon);
+    gtk_tooltips_set_tip(dialog->Tooltips, dialog->use_dynamic_icon_checkbutton
+            , _("Dynamic icon shows current month and day of the month. It is visible only in system tray.")
             , NULL);
-    g_signal_connect(G_OBJECT(dialog->icon_size_x_spin), "value-changed"
-            , G_CALLBACK(icon_size_x_spin_changed), dialog);
-
-    hbox = gtk_hbox_new(FALSE, 0);
-    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
-    label = gtk_label_new("Y:");
-    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
-    dialog->icon_size_y_spin = gtk_spin_button_new_with_range(0, 128, 1);
-    gtk_box_pack_start(GTK_BOX(hbox)
-            , dialog->icon_size_y_spin, FALSE, FALSE, 5);
-    gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->icon_size_y_spin)
-            , g_par.icon_size_y);
-    label = gtk_label_new(_("(0 = use static icon)"));
-    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
-    g_signal_connect(G_OBJECT(dialog->icon_size_y_spin), "value-changed"
-            , G_CALLBACK(icon_size_y_spin_changed), dialog);
+    g_signal_connect(G_OBJECT(dialog->use_dynamic_icon_checkbutton), "toggled"
+            , G_CALLBACK(use_dynamic_icon_changed), dialog);
 
     /***** Start event or day window from main calendar *****/
     dialog->click_to_show_radiobutton_group = NULL;
@@ -981,8 +953,7 @@ void write_parameters()
     orage_rc_put_bool(orc, "Start minimized", g_par.start_minimized);
     orage_rc_put_bool(orc, "Set sticked", g_par.set_stick);
     orage_rc_put_bool(orc, "Set ontop", g_par.set_ontop);
-    orage_rc_put_int(orc, "Dynamic icon X", g_par.icon_size_x);
-    orage_rc_put_int(orc, "Dynamic icon Y", g_par.icon_size_y);
+    orage_rc_put_bool(orc, "Use dynamic icon", g_par.use_dynamic_icon);
     /* we write this with X so that we do not read it back unless
      * it is manually changed. It should need changes really seldom. */
     orage_rc_put_int(orc, "XIcal week start day"
@@ -1140,8 +1111,7 @@ void read_parameters(void)
     g_par.start_minimized = orage_rc_get_bool(orc, "Start minimized", FALSE);
     g_par.set_stick = orage_rc_get_bool(orc, "Set sticked", TRUE);
     g_par.set_ontop = orage_rc_get_bool(orc, "Set ontop", FALSE);
-    g_par.icon_size_x = orage_rc_get_int(orc, "Dynamic icon X", 42);
-    g_par.icon_size_y = orage_rc_get_int(orc, "Dynamic icon Y", 32);
+    g_par.use_dynamic_icon = orage_rc_get_bool(orc, "Use dynamic icon", TRUE);
     /* 0 = monday, ..., 6 = sunday */
     g_par.ical_weekstartday = orage_rc_get_int(orc, "Ical week start day"
             , get_first_weekday_from_locale());
diff --git a/src/parameters.h b/src/parameters.h
index 5cfdbd9..0d4bfab 100644
--- a/src/parameters.h
+++ b/src/parameters.h
@@ -84,7 +84,7 @@ typedef struct _parameters
 
     /* tray icon */
     void *trayIcon; /* this is GtkStatusIcon * */
-    gint icon_size_x, icon_size_y;
+    gboolean use_dynamic_icon;
 
     /* event-list window */
     gint el_pos_x, el_pos_y;
diff --git a/src/reminder.c b/src/reminder.c
index 0688cce..a1526fc 100644
--- a/src/reminder.c
+++ b/src/reminder.c
@@ -817,7 +817,7 @@ gboolean orage_tooltip_update(gpointer user_data)
     GList *alarm_l;
     alarm_struct *cur_alarm;
     gboolean more_alarms=TRUE;
-    GString *tooltip=NULL;
+    GString *tooltip=NULL, *tooltip_highlight_helper=NULL;
     gint alarm_cnt=0;
     gint tooltip_alarm_limit=5;
     gint year, month, day, hour, minute, second;
@@ -834,6 +834,10 @@ gboolean orage_tooltip_update(gpointer user_data)
     }
     t = orage_localtime();
     tooltip = g_string_new(_("Next active alarms:"));
+#if GTK_CHECK_VERSION(2,16,0)
+    g_string_prepend(tooltip, ("<span foreground=\"blue\" weight=\"bold\" underline=\"single\">"));
+    g_string_append_printf(tooltip, (" </span>"));
+#endif
   /* Check if there are any alarms to show */
     alarm_l = g_par.alarm_list;
     for (alarm_l = g_list_first(alarm_l);
@@ -860,9 +864,20 @@ gboolean orage_tooltip_update(gpointer user_data)
                 hh += 24;
                 dd -= 1;
             }
+#if GTK_CHECK_VERSION(2,16,0)
+            g_string_append_printf(tooltip, ("<span weight=\"bold\">"));
+            tooltip_highlight_helper = g_string_new(" </span>");
+            g_string_append_printf(tooltip_highlight_helper, 
+                    (" %s"), cur_alarm->title);
+            g_string_append_printf(tooltip, 
+                    _("\n%02d d %02d h %02d min to: %s"),
+                    dd, hh, min, tooltip_highlight_helper->str);
+            g_string_free(tooltip_highlight_helper, TRUE);
+#else
             g_string_append_printf(tooltip, 
                     _("\n%02d d %02d h %02d min to: %s"),
                     dd, hh, min, cur_alarm->title);
+#endif
             alarm_cnt++;
         }
         else /* sorted so scan can be stopped */
@@ -870,7 +885,13 @@ gboolean orage_tooltip_update(gpointer user_data)
     }
     if (alarm_cnt == 0)
         g_string_append_printf(tooltip, _("\nNo active alarms found"));
+    /* deprecated since version 2.16 */
+    /* after 2.16 use gtk_status_icon_set_tooltip_markup to get nicer text */
+#if GTK_CHECK_VERSION(2,16,0)
+    gtk_status_icon_set_tooltip_markup((GtkStatusIcon *)g_par.trayIcon, tooltip->str);
+#else
     gtk_status_icon_set_tooltip((GtkStatusIcon *)g_par.trayIcon, tooltip->str);
+#endif
     g_string_free(tooltip, TRUE);
     return(TRUE);
 }
diff --git a/src/tray_icon.c b/src/tray_icon.c
index 0961725..4e91b38 100644
--- a/src/tray_icon.c
+++ b/src/tray_icon.c
@@ -89,61 +89,161 @@ void toggle_visible_cb(GtkStatusIcon *status_icon, gpointer user_data)
 void show_menu(GtkStatusIcon *status_icon, guint button, guint activate_time
         , gpointer user_data)
 {
-    gtk_menu_popup((GtkMenu *)user_data, NULL, NULL, NULL, NULL, button, activate_time);
+    gtk_menu_popup((GtkMenu *)user_data, NULL, NULL, NULL, NULL
+            , button, activate_time);
 }
 
-GdkPixbuf *orage_create_icon2(gboolean static_icon, gint x, gint y)
+void create_icon_pango_layout(gint line, PangoLayout *pl, struct tm *t
+        , gint width, gint height
+        , gint *x_offset, gint *y_offset, gint *y_size)
 {
+    gchar ts[200], row[20];
+    PangoRectangle real_rect, log_rect;
+    gint x_size;
+    gboolean first_try = TRUE, done = FALSE;
+
+    while (!done) {
+        switch (line) {
+            case 1:
+                if (first_try) {
+                    if (strftime(row, 19, "%^A", t) == 0) {
+                        g_warning("create_icon_pango_layout: strftime %%^A failed");
+                        if (strftime(row, 19, "%A", t) == 0) {
+                            g_warning("create_icon_pango_layout: strftime %%A failed");
+                            g_sprintf(row, "orage");
+                        }
+                    }
+                }
+                else { /* we failed once, let's try shorter string */
+                    if (strftime(row, 19, "%^a", t) == 0) {
+                        g_warning("create_icon_pango_layout: strftime %%^a failed");
+                        if (strftime(row, 19, "%a", t) == 0) {
+                            g_warning("create_icon_pango_layout: strftime %%a failed");
+                            g_sprintf(row, "orage");
+                        }
+                    }
+                }
+                g_snprintf(ts, 199
+                        , "<span foreground=\"black\" font_desc=\"Ariel bold 20\">%s</span>"
+                        , row);
+                break;
+            case 2:
+                g_snprintf(ts, 199
+                        , "<span foreground=\"red\" font_desc=\"Sans bold 72\">%02d</span>"
+                        , t->tm_mday);
+                break;
+            case 3:
+                if (first_try) {
+                    if (strftime(row, 19, "%^B", t) == 0) {
+                        g_warning("create_icon_pango_layout: strftime %%^B failed");
+                        if (strftime(row, 19, "%B", t) == 0) {
+                            g_warning("create_icon_pango_layout: strftime %%B failed");
+                            g_sprintf(row, "orage");
+                        }
+                    }
+                }
+                else { /* we failed once, let's try shorter string */
+                    if (strftime(row, 19, "%^b", t) == 0) {
+                        g_warning("create_icon_pango_layout: strftime %%^b failed");
+                        if (strftime(row, 19, "%b", t) == 0) {
+                            g_warning("create_icon_pango_layout: strftime %%b failed");
+                            g_sprintf(row, "orage");
+                        }
+                    }
+                }
+                g_snprintf(ts, 199
+                        , "<span foreground=\"black\" font_desc=\"Ariel bold 24\">%s</span>"
+                        , row);
+                break;
+            default:
+                g_warning("create_icon_pango_layout: wrong line number %d", line);
+        }
+        pango_layout_set_markup(pl, ts, -1);
+        pango_layout_set_alignment(pl, PANGO_ALIGN_CENTER);
+        pango_layout_get_extents(pl, &real_rect, &log_rect);
+        /* real_rect is smaller than log_rect. real is the minimal rectangular
+           to cover the text while log has some room around it. It is safer to
+           use log since it is hard to position real.
+           */
+        /* x_offset, y_offset = free space left after this layout 
+           divided equally to start and end */
+        x_size = PANGO_PIXELS(log_rect.width);
+        *y_size = PANGO_PIXELS(log_rect.height);
+        *x_offset = (width - x_size)/2;
+        if (line == 1)
+            *y_offset = 2; /* we have 1 pixel border line */
+        else if (line == 2)
+            *y_offset = (height - *y_size)/2;
+        else if (line == 3)
+            *y_offset = (height - *y_size);
+        if (*x_offset < 0) { /* it does not fit */
+            if (first_try) {
+                first_try = FALSE;
+            }
+            else {
+                orage_message(110, "trayicon: row %d does not fit in dynamic icon", line);
+                done = TRUE; /* failed */
+            }
+        }
+        else 
+            done = TRUE;
+    }
+    /*
+    g_print("\n\norage row %d offset\n"
+            "width=%d x-offset=%d\n"
+            "\t(real pixel text width=%d logical pixel text width=%d)\n"
+            "height=%d y-offset=%d\n"
+            "\t(real pixel text height=%d logical pixel text height=%d)\n"
+            "\n" 
+            , line
+            , width, *x_offset
+            , PANGO_PIXELS(real_rect.width), x_size
+            , height, *y_offset
+            , PANGO_PIXELS(real_rect.height), *y_size
+            ); 
+            */
+    /*
+    gdk_draw_rectangle(pic1, pic1_gc2, FALSE
+            , *x_offset+(x_size-PANGO_PIXELS(real_rect.width))/2
+            , *y_offset+(*y_size-PANGO_PIXELS(real_rect.height))/2
+            , PANGO_PIXELS(real_rect.width), PANGO_PIXELS(real_rect.height));
+    gdk_draw_rectangle(pic1, pic1_gc2, FALSE
+            , *x_offset, *y_offset, x_size, *y_size);
+            */
 }
 
-GdkPixbuf *orage_create_icon(gboolean static_icon, gint x, gint y)
+GdkPixbuf *orage_create_icon(gboolean static_icon, gint size)
 {
     CalWin *xfcal = (CalWin *)g_par.xfcal;
     GtkIconTheme *icon_theme = NULL;
-    GdkPixbuf *pixbuf;
+    GdkPixbuf *pixbuf, *pixbuf2;
     GdkPixmap *pic1;
     GdkGC *pic1_gc1, *pic1_gc2;
     GdkColormap *pic1_cmap;
     GdkColor color;
     GdkVisual *pic1_vis;
-    PangoLayout *pl_day, *pl_head, *pl_month;
+    PangoLayout *pl_day, *pl_weekday, *pl_month;
     gint width = 0, height = 0, depth = 16;
     gint red = 239, green = 235, blue = 230;
-    PangoRectangle real_rect, log_rect;
     struct tm *t;
-    gchar ts[200], month[50];
-    gint x_offset = 0, y_offset = 0, y_used = 0, i, limit;
-    gint x_day = 0, y_day = 0;
-    gint x_head = 0, y_head = 0, y_used_head = 0;
-    gint x_month = 0, y_month = 0, y_used_month = 0;
-    gboolean draw_head = FALSE, draw_month = FALSE;
-    gboolean draw_dynamic = FALSE, work_in_progress = TRUE;
-    gchar *day_sizes[] = {"xx-large", "x-large", "large", "medium"
-                         , "small", "x-small", "xx-small", "END"};
+    gint x_used = 0, y_used = 0;
+    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) {
-        pixbuf = gtk_icon_theme_load_icon(icon_theme, "xfcalendar", x
-                , GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
-        return(pixbuf);
-    }
-    if (x <= 12 || y <= 12) {
-        orage_message(110, "Too small icon size, using static icon\n");
-        pixbuf = gtk_icon_theme_load_icon(icon_theme, "xfcalendar", 16
-                , GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
-        return(pixbuf);
-    }
-    if (g_par.icon_size_x == 0 
-    ||  g_par.icon_size_y == 0) { /* signal to use static icon */
-        orage_message(110, "Icon size set to zero, using static icon\n");
-        pixbuf = gtk_icon_theme_load_icon(icon_theme, "xfcalendar", x
+    if (static_icon || !g_par.use_dynamic_icon) {
+        pixbuf = gtk_icon_theme_load_icon(icon_theme, "xfcalendar", size
                 , GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
         return(pixbuf);
     }
 
+    /* dynamic icon build starts now */
+    draw_dynamic = TRUE;
     t = orage_localtime();
-    width = x; 
-    height = y;
+    width = 160; 
+    height = 160;
     pic1_cmap = gdk_colormap_get_system();
     pic1_vis = gdk_colormap_get_visual(pic1_cmap);
     depth = pic1_vis->depth;
@@ -161,121 +261,60 @@ GdkPixbuf *orage_create_icon(gboolean static_icon, gint x, gint y)
     */
     gdk_colormap_alloc_color(pic1_cmap, &color, FALSE, TRUE);
     gdk_gc_set_foreground(pic1_gc1, &color);
+    /*
     gdk_draw_rectangle(pic1, pic1_gc1, TRUE, 0, 0, width, height);
     gdk_draw_rectangle(pic1, pic1_gc2, FALSE, 0, 0, width-1, height-1);
     gdk_draw_rectangle(pic1, pic1_gc2, FALSE, 0, 0, width-3, height-3);
+    gdk_draw_rectangle(pic1, pic1_gc2, FALSE, 0, 0, width-5, height-5);
+    */
+    gdk_draw_rectangle(pic1, pic1_gc1, TRUE, 0, 0, width, height);
+    gdk_draw_line(pic1, pic1_gc2, 4, height-1, width-1, height-1);
+    gdk_draw_line(pic1, pic1_gc2, width-1, 4, width-1, height-1);
+    gdk_draw_line(pic1, pic1_gc2, 2, height-3, width-3, height-3);
+    gdk_draw_line(pic1, pic1_gc2, width-3, 2, width-3, height-3);
+    gdk_draw_rectangle(pic1, pic1_gc2, FALSE, 0, 0, width-5, height-5);
+    x_used = 6;
+    y_used = 6;
 
     /* gdk_draw_line(pic1, pic1_gc1, 10, 20, 30, 38); */
 
     /* create any valid pango layout to get things started */
-    /* this does not quite work, but almost
-    pl_day = pango_layout_new(gdk_pango_context_get_for_screen(gdk_screen_get_default()));
-    */
     pl_day = gtk_widget_create_pango_layout(xfcal->mWindow, "x");
-    pl_head = pango_layout_copy(pl_day);
+    pl_weekday = pango_layout_copy(pl_day);
     pl_month = pango_layout_copy(pl_day);
 
-    /* heading: orage */
-    g_snprintf(ts, 199
-            , "<span foreground=\"blue\" size=\"x-small\">Orage</span>");
-    pango_layout_set_markup(pl_head, ts, -1);
-    pango_layout_set_alignment(pl_head, PANGO_ALIGN_CENTER);
-    pango_layout_get_extents(pl_head, &real_rect, &log_rect);
-    x_offset = (width - PANGO_PIXELS(log_rect.width) - 2)/2;
-    y_offset = -2;
-    /* g_print("orage offset x=%d y=%d height=%d text height=%d real text height=%d\n" , x_offset, y_offset, height, PANGO_PIXELS(log_rect.height), PANGO_PIXELS(real_rect.height)); */
-    if (x_offset > 0 && (height-PANGO_PIXELS(log_rect.height)-y_offset) > 0) {
-        draw_head = TRUE; /* fits */
-        x_head = x_offset;
-        y_head = y_offset;
-        y_used_head = PANGO_PIXELS(real_rect.height);
-    }
-    else
-        orage_message(110, "trayicon: heading does not fit in dynamic icon");
-
-    /* month */
-    if (strftime(month, 19, "%^b", t) == 0) {
-        g_warning("orage_create_icon: strftime %%^b failed");
-        if (strftime(month, 19, "%b", t) == 0) {
-            g_warning("orage_create_icon: strftime %%b failed");
-            g_sprintf(month, "orage");
-        }
-    }
-    g_snprintf(ts, 199
-            , "<span foreground=\"blue\" size=\"x-small\">%s</span>", month);
-    pango_layout_set_markup(pl_month, ts, -1);
-    pango_layout_set_alignment(pl_month, PANGO_ALIGN_CENTER);
-    pango_layout_get_extents(pl_month, &real_rect, &log_rect);
-    x_offset = (width - PANGO_PIXELS(real_rect.width) - 2)/2;
-    y_offset = (height - PANGO_PIXELS(log_rect.height) - 2);
-    if (x_offset > 0 && (height - y_offset - PANGO_PIXELS(log_rect.height))) {
-        draw_month = TRUE; /* fits */
-        x_month = x_offset;
-        y_month = y_offset;
-        y_used_month = PANGO_PIXELS(real_rect.height);
-    }
-    else
-        orage_message(110, "trayicon: month does not fit in dynamic icon");
-
-    do { /* main loop where we try our best to fit header+day+month into icon */
-        y_used = 0;
-        if (draw_month || draw_head) {
-            limit = 3; /* = medium */
-            if (draw_head)
-                y_used += y_used_head;
-            if (draw_month)
-                y_used += y_used_month;
-        }
-        else
-            limit = 10; /* no limit */
+    /* weekday */
+    create_icon_pango_layout(1, pl_weekday, t
+            , width-x_used, height-y_used
+            , &x_offset_weekday, &y_offset_weekday, &y_size_weekday);
 
     /* day */
-        for (i = 0, x_offset = 0, y_offset = 0; 
-             (strcmp(day_sizes[i], "END") != 0) 
-                  && (i <= limit)
-                  && ((x_offset <= 0) || ((y_offset) <= 0));
-             i++) {
-            g_snprintf(ts, 199
-                    , "<span foreground=\"red\" weight=\"bold\" size=\"%s\">%02d</span>"
-                    , day_sizes[i], t->tm_mday);
-            pango_layout_set_markup(pl_day, ts, -1);
-            pango_layout_set_alignment(pl_day, PANGO_ALIGN_CENTER);
-            pango_layout_get_extents(pl_day, &real_rect, &log_rect);
-            x_offset = (width - PANGO_PIXELS(log_rect.width))/2;
-            y_offset = (height - y_used - PANGO_PIXELS(log_rect.height))/2;
-        } /* for */
-        if (x_offset >= 0 && (y_offset) >= 0) { /* it fits */
-            draw_dynamic = TRUE;
-            work_in_progress = FALSE; /* done! */
-            x_day = x_offset;
-            y_day = (height - PANGO_PIXELS(log_rect.height) - 2)/2;
-            if (!draw_head && draw_month)
-                y_day -= y_used_head/2;
-            if (draw_head && !draw_month)
-                y_day += y_used_head/2;
-        }
-        else {
-            if (draw_head)
-                draw_head = FALSE; /* does not fit */
-            else if (draw_month)
-                draw_month = FALSE; /* does not fit */
-            else
-                work_in_progress = FALSE; /* done! */
-        }
-    } while (work_in_progress);
+    create_icon_pango_layout(2, pl_day, t
+            , width-x_used, height-y_used
+            , &x_offset_day, &y_offset_day, &y_size_day);
 
-    if (draw_dynamic) {
-        if (draw_head)
-            gdk_draw_layout(pic1, pic1_gc1, x_head, y_head, pl_head);
-        if (draw_month)
-            gdk_draw_layout(pic1, pic1_gc1, x_month, y_month, pl_month);
-        gdk_draw_layout(pic1, pic1_gc1, x_day, y_day, pl_day);
+    /* month */
+    create_icon_pango_layout(3, pl_month, t
+            , 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;
+        }
     }
     else {
-        pixbuf = gtk_icon_theme_load_icon(icon_theme, "xfcalendar", x
+        pixbuf = gtk_icon_theme_load_icon(icon_theme, "xfcalendar", size
                 , GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
     }
 
@@ -285,29 +324,19 @@ GdkPixbuf *orage_create_icon(gboolean static_icon, gint x, gint y)
     g_object_unref(pic1_gc1);
     g_object_unref(pic1_gc2);
     g_object_unref(pl_day);
-    g_object_unref(pl_head);
+    g_object_unref(pl_weekday);
     g_object_unref(pl_month);
     g_object_unref(pic1);
   
     return(pixbuf);
 }
 
-void destroy_TrayIcon(GtkStatusIcon *trayIcon)
-{
-    g_object_unref(trayIcon);
-}
-
-GtkStatusIcon* create_TrayIcon()
+GtkWidget *create_TrayIcon_menu()
 {
     CalWin *xfcal = (CalWin *)g_par.xfcal;
-    GtkStatusIcon *trayIcon = NULL;
-    GtkWidget *menuItem;
     GtkWidget *trayMenu;
-    GdkPixbuf *pixbuf;
+    GtkWidget *menuItem;
 
-    /*
-     * Create the tray icon popup menu
-     */
     trayMenu = gtk_menu_new();
     menuItem = gtk_image_menu_item_new_with_mnemonic(_("Today"));
     gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuItem)
@@ -356,11 +385,30 @@ GtkStatusIcon* create_TrayIcon()
     gtk_menu_shell_append(GTK_MENU_SHELL(trayMenu), menuItem);
     gtk_widget_show(menuItem);
 
+    return(trayMenu);
+}
+
+void destroy_TrayIcon(GtkStatusIcon *trayIcon)
+{
+    g_object_unref(trayIcon);
+}
+
+GtkStatusIcon* create_TrayIcon()
+{
+    CalWin *xfcal = (CalWin *)g_par.xfcal;
+    GtkWidget *trayMenu;
+    GtkStatusIcon *trayIcon = NULL;
+    GdkPixbuf *pixbuf;
+
     /*
-     * Create the tray icon
+     * Create the tray icon popup menu
      */
+    trayMenu = create_TrayIcon_menu();
 
-    pixbuf = orage_create_icon(FALSE, g_par.icon_size_x, g_par.icon_size_y);
+    /*
+     * Create the tray icon
+     */
+    pixbuf = orage_create_icon(FALSE, 0); /* 0 = no scaling */
     trayIcon = gtk_status_icon_new_from_pixbuf(pixbuf);
 
     g_object_ref(trayIcon);
diff --git a/src/tray_icon.h b/src/tray_icon.h
index 677f344..f4b8730 100644
--- a/src/tray_icon.h
+++ b/src/tray_icon.h
@@ -24,7 +24,7 @@
 #ifndef __TRAY_ICON_H__
 #define __TRAY_ICON_H__
 
-GdkPixbuf *orage_create_icon(gboolean static_icon, gint x, gint y);
+GdkPixbuf *orage_create_icon(gboolean static_icon, gint size);
 
 GtkStatusIcon *create_TrayIcon(void);
 



More information about the Xfce4-commits mailing list