[Goodies-commits] r2644 - in xfce4-quicklauncher-plugin/trunk: . panel-plugin

Masse Nicolas bountykiller at xfce.org
Sun Apr 1 16:27:28 CEST 2007


Author: bountykiller
Date: 2007-04-01 14:27:28 +0000 (Sun, 01 Apr 2007)
New Revision: 2644

Modified:
   xfce4-quicklauncher-plugin/trunk/ChangeLog
   xfce4-quicklauncher-plugin/trunk/panel-plugin/avoid_deprecation.h
   xfce4-quicklauncher-plugin/trunk/panel-plugin/callbacks.c
   xfce4-quicklauncher-plugin/trunk/panel-plugin/main.c
   xfce4-quicklauncher-plugin/trunk/panel-plugin/types.h
Log:
+fix a problem wich makes some launcher lost their widget when adding others
+add the use of labels (not fully working)
+add an option for using tooltips (not working yet)
+replace xfce_icon_theme_load_category (deprecated) by 
xfce_themed_icon_load_category



Modified: xfce4-quicklauncher-plugin/trunk/ChangeLog
===================================================================
--- xfce4-quicklauncher-plugin/trunk/ChangeLog	2007-03-31 17:06:46 UTC (rev 2643)
+++ xfce4-quicklauncher-plugin/trunk/ChangeLog	2007-04-01 14:27:28 UTC (rev 2644)
@@ -1,3 +1,11 @@
++fix a problem wich makes some launcher lost their widget when adding others
++add the use of labels (not fully working)
++add an option for using tooltips (not working yet)
++replace xfce_icon_theme_load_category (deprecated) by xfce_themed_icon_load_category
+
+
+version 1.92:
+**************
 +replace g_assert by g_return_if_fail in order to not crash the panel.
 +removed the use of eventboxes. Looks better when a theme is used.
 +hopefully fix some compilation problems with netbsd

Modified: xfce4-quicklauncher-plugin/trunk/panel-plugin/avoid_deprecation.h
===================================================================
--- xfce4-quicklauncher-plugin/trunk/panel-plugin/avoid_deprecation.h	2007-03-31 17:06:46 UTC (rev 2643)
+++ xfce4-quicklauncher-plugin/trunk/panel-plugin/avoid_deprecation.h	2007-04-01 14:27:28 UTC (rev 2644)
@@ -1,10 +1,39 @@
+/***************************************************************************
+ *            avoid_deprecation.h
+ *
+ *  Last Update: 31/03/2007
+ *  Copyright  2005 - 2007  bountykiller
+ *  Email: masse_nicolas at yahoo.fr
+ ****************************************************************************/
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// 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 Library 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.
+
 //This file is intented to avoid problems 
-//with the fact that XfceFileChooser will be
-//deprecated soon.
+//with the fact that XfceFileChooser but also xfce_icon_theme_* will be deprecated soon.
 //Hope it works for everyone.
+
+#ifndef __QCK_LAUNCHER_AVOID_DEPRECATION__
+#define __QCK_LAUNCHER_AVOID_DEPRECATION__
+
 #include <gtk/gtk.h>
 
 #if GTK_CHECK_VERSION(2,4,0)
+	
+	#define icon_theme_get_for_screen gtk_icon_theme_get_for_screen
+	#define icon_theme_set_for_screen gtk_icon_theme_set_for_screen
+	#define DEFAULT_ICON_THEME (gtk_icon_theme_get_default())
+	
 	#define	FileChooser	GtkFileChooser
 	#define	FileChooserAction	GtkFileChooserAction
 	#define	file_chooser_dialog_new 	gtk_file_chooser_dialog_new 
@@ -47,6 +76,11 @@
 #else
 	#include <libxfcegui4.h>
 	#if !LIBXFCEGUI4_CHECK_VERSION (4, 3, 0)
+	
+	#define icon_theme_get_for_screen xfce_icon_theme_get_for_screen
+	#define icon_theme_set_for_screen xfce_icon_theme_set_for_screen
+	#define DEFAULT_ICON_THEME (xfce_icon_theme_get_for_screen(NULL))
+	
 	#define	FileChooser	XfceFileChooser
 	#define	FileChooserAction	XfceFileChooserAction
 	#define	file_chooser_dialog_new 	xfce_file_chooser_dialog_new 
@@ -89,3 +123,6 @@
 	#error you must have gtk > 2.4.0 or libxfcegui4 < 4.3.0 in order to compile this!!!
 	#endif
 #endif
+
+
+#endif

Modified: xfce4-quicklauncher-plugin/trunk/panel-plugin/callbacks.c
===================================================================
--- xfce4-quicklauncher-plugin/trunk/panel-plugin/callbacks.c	2007-03-31 17:06:46 UTC (rev 2643)
+++ xfce4-quicklauncher-plugin/trunk/panel-plugin/callbacks.c	2007-04-01 14:27:28 UTC (rev 2644)
@@ -24,13 +24,14 @@
 #  include <config.h>
 #endif
 
-#include <gtk/gtk.h>
 #include <string.h>
+#include <libxfcegui4/icons.h>
 
 #include "callbacks.h"
+#include "avoid_deprecation.h"
 #include "types.h"
-#include "avoid_deprecation.h"
 
+
 static t_qck_launcher_opt_dlg *_dlg = NULL;
 static GtkWidget  *_icon_window = NULL;
 
@@ -44,6 +45,8 @@
 void on_btn_edit_clicked(GtkButton *button, gpointer user_data);
 void on_btn_up_clicked(GtkButton *button, gpointer user_data);
 void on_btn_down_clicked(GtkButton *button, gpointer user_data);
+void on_chk_labels_clicked(GtkToggleButton *togglebutton, gpointer user_data);
+void on_chk_tooltip_clicked(GtkToggleButton *togglebutton, gpointer user_data);
 void cmd_changed(GtkCellRendererText *cellrenderertext, gchar *arg1,
 								gchar *arg2, gpointer user_data);
 //void on_tree_reorder(GtkTreeModel *treemodel, GtkTreePath *arg1, GtkTreeIter *arg2,
@@ -65,8 +68,8 @@
 //Creation functions
 //******************************************************************************
 t_qck_launcher_opt_dlg* create_qck_launcher_dlg()
- {
-  g_return_if_fail( !(_dlg || _icon_window) );
+{
+  g_return_val_if_fail( !(_dlg || _icon_window), NULL);
   _icon_window = create_icon_window();
   _dlg = (t_qck_launcher_opt_dlg *) g_new0(t_qck_launcher_opt_dlg, 1);
 
@@ -109,7 +112,15 @@
   gtk_container_add (GTK_CONTAINER (_dlg->scrolledwindow1), _dlg->treeview1);
   gtk_container_set_border_width (GTK_CONTAINER (_dlg->treeview1), 3);
   gtk_widget_set_size_request(_dlg->treeview1, 200, 150);
-
+  
+  _dlg->chk_tooltip = gtk_check_button_new_with_label(_("afficher les tooltips"));
+  gtk_widget_show (_dlg->chk_tooltip);
+  gtk_box_pack_start(GTK_BOX (_dlg->vbox), _dlg->chk_tooltip, TRUE, TRUE, 0);
+  
+  _dlg->chk_labels = gtk_check_button_new_with_label(_("afficher les labels"));
+  gtk_widget_show (_dlg->chk_labels);
+  gtk_box_pack_start(GTK_BOX (_dlg->vbox), _dlg->chk_labels, TRUE, TRUE, 0);
+  
   _dlg->vbuttonbox1 = gtk_vbutton_box_new ();
   gtk_widget_show (_dlg->vbuttonbox1);
   gtk_box_pack_start (GTK_BOX (_dlg->configbox), _dlg->vbuttonbox1, FALSE, TRUE, 5);
@@ -134,7 +145,7 @@
   gtk_widget_show (_dlg->btn_down);
   gtk_container_add (GTK_CONTAINER (_dlg->vbuttonbox1), _dlg->btn_down);
   GTK_WIDGET_SET_FLAGS (_dlg->btn_down, GTK_CAN_DEFAULT);
-
+  
   g_signal_connect_swapped( (gpointer)_dlg->dialog, "response",
 							G_CALLBACK (free_qck_launcher_dlg), NULL);
 
@@ -176,8 +187,10 @@
 	_dlg->quicklauncher = quicklauncher;
 	treemodel  = GTK_TREE_MODEL(gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER));
 	gtk_tree_view_set_model(GTK_TREE_VIEW(_dlg->treeview1), treemodel);
-	gtk_tree_view_set_reorderable (GTK_TREE_VIEW (_dlg->treeview1), FALSE);//==>besoin de gérer le reorder
+	gtk_tree_view_set_reorderable (GTK_TREE_VIEW (_dlg->treeview1), FALSE);//==>does not manage reordering
 	gtk_spin_button_set_value(GTK_SPIN_BUTTON(_dlg->spin1), (gdouble)quicklauncher->nb_lines);
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_dlg->chk_labels) ,quicklauncher->has_labels);
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_dlg->chk_tooltip) ,quicklauncher->has_tooltips);
 
 	render = gtk_cell_renderer_pixbuf_new();
 	//render = gtk_cell_renderer_combo_new();
@@ -214,6 +227,10 @@
 					G_CALLBACK (on_btn_up_clicked), NULL);
 	g_signal_connect ((gpointer) _dlg->btn_down, "clicked",
 					G_CALLBACK (on_btn_down_clicked), NULL);
+	g_signal_connect ((gpointer) _dlg->chk_labels, "toggled",
+					G_CALLBACK (on_chk_labels_clicked), NULL);
+	g_signal_connect ((gpointer) _dlg->chk_tooltip, "toggled",
+					G_CALLBACK (on_chk_tooltip_clicked), NULL);
 }
 
 
@@ -242,9 +259,9 @@
 	_icon_window = gtk_window_new(GTK_WINDOW_POPUP);
 	hbox = gtk_hbox_new(FALSE, 0);
 	gtk_container_add(GTK_CONTAINER(_icon_window), hbox);
-	for(i=0; i <XFCE_N_BUILTIN_ICON_CATEGORIES; ++i)
+	for(i=0; i < XFCE_N_BUILTIN_ICON_CATEGORIES; ++i)
 	{
-		pixbuf = xfce_icon_theme_load_category(DEFAULT_ICON_THEME, i, 16);
+		pixbuf = xfce_themed_icon_load_category(i, 16);
 		btn = xfce_iconbutton_new();
 		gtk_button_set_relief (GTK_BUTTON (btn), GTK_RELIEF_NONE);
 		xfce_iconbutton_set_pixbuf(XFCE_ICONBUTTON (btn), pixbuf);
@@ -260,7 +277,6 @@
 	g_signal_connect(btn, "clicked", G_CALLBACK(btn_clicked), (gpointer)XFCE_ICON_CATEGORY_EXTERN);
 	g_signal_connect_swapped(btn, "clicked", G_CALLBACK(gtk_widget_hide), (gpointer)_icon_window);
 	gtk_widget_show(btn);
-	//XFCE_ICON_CATEGORY_STOCK
 
 	gtk_widget_show(hbox);
 
@@ -366,11 +382,12 @@
 	GtkTreeModel *treemodel;
 	GtkTreeIter iter;
 	GdkPixbuf *pixbuf;
-	t_launcher *launcher =  launcher_new (NULL, XFCE_ICON_CATEGORY_UNKNOWN, NULL, _dlg->quicklauncher);
-
-	treemodel = gtk_tree_view_get_model(GTK_TREE_VIEW(_dlg->treeview1) );
+	t_launcher *launcher; 
+	
+	launcher = launcher_new(NULL, XFCE_ICON_CATEGORY_UNKNOWN, NULL, _dlg->quicklauncher);
+	treemodel = gtk_tree_view_get_model(GTK_TREE_VIEW(_dlg->treeview1));
 	gtk_list_store_insert(GTK_LIST_STORE(treemodel), &iter, INT_MAX); //INT_MAX must be enough ;-)
-	pixbuf = xfce_icon_theme_load_category(DEFAULT_ICON_THEME, XFCE_ICON_CATEGORY_UNKNOWN, 16);
+	pixbuf = xfce_themed_icon_load_category(XFCE_ICON_CATEGORY_UNKNOWN, 16);
 	gtk_list_store_set(GTK_LIST_STORE(treemodel), &iter, 0, pixbuf, 1, NULL ,2, (gpointer)launcher, -1);
 	UNREF(pixbuf);
 	quicklauncher_empty_widgets(_dlg->quicklauncher);
@@ -464,6 +481,16 @@
 	}
 }
 
+void on_chk_labels_clicked(GtkToggleButton *togglebutton, gpointer user_data)
+{
+	quicklauncher_set_has_labels(_dlg->quicklauncher, gtk_toggle_button_get_active(togglebutton));
+}
+
+void on_chk_tooltip_clicked(GtkToggleButton *togglebutton, gpointer user_data)
+{
+	quicklauncher_set_has_tooltips(_dlg->quicklauncher, gtk_toggle_button_get_active(togglebutton));
+}
+
 void cmd_changed(GtkCellRendererText *cellrenderertext, gchar *arg1, gchar *arg2, gpointer user_data)
 {
 	GtkTreeSelection *sel;

Modified: xfce4-quicklauncher-plugin/trunk/panel-plugin/main.c
===================================================================
--- xfce4-quicklauncher-plugin/trunk/panel-plugin/main.c	2007-03-31 17:06:46 UTC (rev 2643)
+++ xfce4-quicklauncher-plugin/trunk/panel-plugin/main.c	2007-04-01 14:27:28 UTC (rev 2644)
@@ -28,12 +28,12 @@
 
 #include "types.h"
 #include "callbacks.h"
+#include "avoid_deprecation.h"
 #include <glib/gprintf.h>
-#include <libxfcegui4/libxfcegui4.h>
 #include <string.h>
 
 //TO DO:
-//+replace xfce_icon_theme_load_category and friends
+//replace xfce_icon_theme_load_category and friends
 
 
 /* Quicklauncher funcs */
@@ -45,11 +45,13 @@
 /* Launcher funcs */
 void launcher_passthrough (t_launcher *launcher, gboolean enter);
 void launcher_clicked (t_launcher *launcher, gboolean pressed);
+void launcher_set_has_tooltip(t_launcher *launcher, gboolean has_tooltip);
+void launcher_set_has_label(t_launcher *launcher, gboolean has_label);
 t_launcher* launcher_load_config(XfceRc *rcfile, gint num, t_quicklauncher *quicklauncher);
 void launcher_save_config(t_launcher *launcher, XfceRc *rcfile, guint16 num);
 
 /* -------------------------------------------------------------------- *
- *                     Panel Plugin Interface               *
+ *	                     	Panel Plugin Interface               		*
  * -------------------------------------------------------------------- */
 
 static void
@@ -183,8 +185,11 @@
 void
 quicklauncher_add_element(t_quicklauncher *quicklauncher, t_launcher *launcher)
 {
+	GList* iter;
 	quicklauncher->launchers = g_list_append(quicklauncher->launchers, (gpointer)launcher);
 	quicklauncher->nb_launcher++;
+	for(iter = g_list_first(quicklauncher->launchers);iter; iter = g_list_next(iter))
+		DBG(((t_launcher*)iter->data)->command);
 }
 
 
@@ -228,9 +233,14 @@
 		{
 			for(j=0; (j < launch_per_line) && (toplace); ++j, toplace = g_list_next(toplace))
 			{
-				g_return_if_fail(toplace && GTK_IS_WIDGET(((t_launcher*)toplace->data)->image) );
-				gtk_table_attach_defaults(GTK_TABLE(quicklauncher->table), ((t_launcher*)toplace->data)->image,
-								j, j+1, i, i+1);
+				g_return_if_fail(toplace);
+				DBG ("To place: %s %d", ((t_launcher*)toplace->data)->command, (gint)((t_launcher*)toplace->data)->box);
+				if(!GTK_IS_WIDGET(((t_launcher*)toplace->data)->box))
+				{
+					g_print("the box has been deleted!");
+				}
+				gtk_table_attach_defaults(GTK_TABLE(quicklauncher->table), 
+											((t_launcher*)toplace->data)->box, j, j+1, i, i+1);
 			}
 		}
 	}
@@ -243,10 +253,16 @@
 	GList *launcher;
 	if (quicklauncher->table)
 	{
-		for( launcher = g_list_first(quicklauncher->launchers);
-			 launcher; launcher = g_list_next(launcher) )
-			gtk_container_remove(GTK_CONTAINER(quicklauncher->table), ((t_launcher*)launcher->data)->image);
+		for(launcher = g_list_first(quicklauncher->launchers);
+			launcher; launcher = g_list_next(launcher) )
+		{
+			DBG ("remove %s %d", ((t_launcher*)launcher->data)->command, (gint)(((t_launcher*)launcher->data)->box));
+			gtk_container_remove(GTK_CONTAINER(quicklauncher->table), ((t_launcher*)launcher->data)->box);
+			if(!GTK_IS_WIDGET(((t_launcher*)launcher->data)->box))
+				g_print("the box has been deleted!");
+		}
 	}
+	DBG ("Widgets removed");
 }
 
 
@@ -279,11 +295,29 @@
 }
 
 
+void quicklauncher_set_has_tooltips(t_quicklauncher *quicklauncher, gboolean value)
+{
+	if(quicklauncher->has_tooltips == value) return;
+	quicklauncher->has_tooltips = value;
+	g_list_foreach(quicklauncher->launchers, (GFunc)launcher_set_has_tooltip, (gpointer)value);
+}
+
+
+void quicklauncher_set_has_labels(t_quicklauncher *quicklauncher, gboolean value)
+{
+	if(quicklauncher->has_labels == value) return;
+	quicklauncher->has_labels = value;
+	g_list_foreach(quicklauncher->launchers, (GFunc)launcher_set_has_label, (gpointer)value);
+}
+
+
 void
 quicklauncher_load_default(t_quicklauncher *quicklauncher)
 {
 	t_launcher *launcher;
 	quicklauncher->nb_lines = 2;
+	quicklauncher->has_labels = FALSE;
+	quicklauncher->has_tooltips = TRUE;
 
 	launcher = launcher_new("xflock4", XFCE_ICON_CATEGORY_SYSTEM,
 							NULL, quicklauncher);
@@ -302,6 +336,7 @@
 
 int _quicklauncher_get_numlauncher(t_quicklauncher *quicklauncher, gdouble x, gdouble y)
 {
+	//TODO: Make this work with labels
 	int row, col, nb_lines, launch_per_line;
 	nb_lines = MIN(quicklauncher->nb_lines, quicklauncher->nb_launcher);
 	if (quicklauncher->orientation == GTK_ORIENTATION_HORIZONTAL)
@@ -365,7 +400,7 @@
 static gboolean
 quicklauncher_leave(XfcePanelPlugin *plugin, GdkEventCrossing *event, t_quicklauncher *quicklauncher)
 {
-    g_list_foreach(quicklauncher->launchers, (GFunc*)launcher_passthrough, FALSE);
+    g_list_foreach(quicklauncher->launchers, (GFunc)launcher_passthrough, NULL);
     quicklauncher->_last_zoomed_launcher_id = -1;
     return TRUE;
 }
@@ -385,7 +420,8 @@
 	quicklauncher->command_ids[1] = g_signal_connect(quicklauncher->plugin, "button-release-event", G_CALLBACK(quicklauncher_clicked), quicklauncher);
 	quicklauncher->command_ids[2] = g_signal_connect(quicklauncher->plugin, "motion-notify-event", G_CALLBACK(quicklauncher_moved), quicklauncher);
 	quicklauncher->command_ids[3] = g_signal_connect(quicklauncher->plugin, "leave-notify-event", G_CALLBACK(quicklauncher_leave), quicklauncher);
-	DBG ("Update Command ids: %d %d %d", quicklauncher->command_ids[0], quicklauncher->command_ids[1], quicklauncher->command_ids[2]);
+	DBG ("Update Command ids: %lu %lu %lu %lu",	quicklauncher->command_ids[0], quicklauncher->command_ids[1],
+												quicklauncher->command_ids[2], quicklauncher->command_ids[3]);
 }
 
 t_quicklauncher *
@@ -399,19 +435,18 @@
 	filename = xfce_panel_plugin_save_location(plugin, TRUE);
 	quicklauncher->icon_size = (gint) (0.70 * xfce_panel_plugin_get_size(plugin)/2);
 	DBG ("icon size: %d", quicklauncher->icon_size);
-	if((!filename) || (!quicklauncher_load_config(quicklauncher, filename) ) )
-		quicklauncher_load_default(quicklauncher);
-	quicklauncher->_last_zoomed_launcher_id = -1;
 	quicklauncher->orientation = xfce_panel_plugin_get_orientation(plugin);
 	quicklauncher->plugin = plugin;
+	quicklauncher->_last_zoomed_launcher_id = -1;
 	gtk_widget_add_events(GTK_WIDGET(plugin),GDK_POINTER_MOTION_MASK);
 	quicklauncher->table = g_object_ref(gtk_table_new(2, 2, FALSE));
 	gtk_table_set_col_spacings(GTK_TABLE(quicklauncher->table), 0);
 	gtk_table_set_row_spacings(GTK_TABLE(quicklauncher->table), 0);
 	gtk_container_add( GTK_CONTAINER(quicklauncher->plugin), quicklauncher->table);
+	gtk_widget_show(quicklauncher->table);
 	_quicklauncher_update_command(quicklauncher);
-	//xfce_panel_plugin_add_action_widget(quicklauncher->plugin, quicklauncher->table);
-	gtk_widget_show(quicklauncher->table);
+	if((!filename) || (!quicklauncher_load_config(quicklauncher, filename) ) )
+		quicklauncher_load_default(quicklauncher);
 	quicklauncher_organize(quicklauncher);
 	return quicklauncher;
 }
@@ -422,7 +457,6 @@
 {
 	g_list_foreach(quicklauncher->launchers, (GFunc) launcher_free, NULL);
 	g_list_free(quicklauncher->launchers);
-
 	g_object_unref(quicklauncher->table);
 	g_free(quicklauncher);
 }
@@ -438,6 +472,8 @@
 	{
 		xfce_rc_set_group(rcfile, NULL);
 		quicklauncher->nb_lines = xfce_rc_read_int_entry(rcfile, "nb_lines", 1);
+		quicklauncher->has_tooltips = xfce_rc_read_bool_entry(rcfile, "has_tooltips", TRUE);
+		quicklauncher->has_labels = xfce_rc_read_bool_entry(rcfile, "has_labels", FALSE);
 		i = xfce_rc_read_int_entry(rcfile, "nb_launcher", 0);
 		g_return_val_if_fail(i >= 0, FALSE);
 		while(i)
@@ -459,13 +495,16 @@
 	GList* liste;
 	guint16 i;
 	//guint16 i = quicklauncher->nb_launcher; //hope it always works ==> seems that it does not ;)
+	DBG("saving config in %s", filename);
 	i = quicklauncher->nb_launcher;
 	rcfile = xfce_rc_simple_open(filename, FALSE);
 	if(!rcfile) return;
-
+	
 	xfce_rc_set_group(rcfile, NULL);
 	xfce_rc_write_int_entry(rcfile, "nb_lines", quicklauncher->nb_lines);
 	xfce_rc_write_int_entry(rcfile, "nb_launcher", quicklauncher->nb_launcher);
+	xfce_rc_write_bool_entry(rcfile, "has_tooltips", quicklauncher->has_tooltips);
+	xfce_rc_write_bool_entry(rcfile, "has_labels", quicklauncher->has_labels);
 	xfce_rc_flush(rcfile);
 	for( liste = quicklauncher->launchers; liste; liste = g_list_next(liste), --i)
 		launcher_save_config((t_launcher*)liste->data, rcfile, i);
@@ -477,17 +516,17 @@
  *                        Launcher Interface                 *
  * -------------------------------------------------------------------- */
 
-//TO DO: support XFCE icon by name
+//TO DO: support icon by name
 GdkPixbuf *
 _create_pixbuf(gint id, const gchar* name, gint size)
 {
 	GdkPixbuf  *pixbuf;
 	if(id != XFCE_ICON_CATEGORY_EXTERN)
-		pixbuf = xfce_icon_theme_load_category(DEFAULT_ICON_THEME, id, size);
+		pixbuf = xfce_themed_icon_load_category(id, size);
 	else
 		pixbuf = gdk_pixbuf_new_from_file_at_size(name, size, size, NULL);
 	if(!pixbuf)
-		pixbuf = xfce_icon_theme_load_category(DEFAULT_ICON_THEME, XFCE_ICON_CATEGORY_UNKNOWN, size);
+		pixbuf = xfce_themed_icon_load_category(XFCE_ICON_CATEGORY_UNKNOWN, size);
 	return pixbuf;
 }
 
@@ -520,7 +559,7 @@
 	if (enter)
 	{
 		DBG ("Entred: size=%d", launcher->quicklauncher->icon_size);
-		int size = 1.25 * launcher->quicklauncher->icon_size;
+		int size = 1.2 * launcher->quicklauncher->icon_size;
 		if (!launcher->zoomed_img)
 			launcher->zoomed_img = gdk_pixbuf_scale_simple(launcher->def_img, size, size, GDK_INTERP_HYPER);
 		gtk_image_set_from_pixbuf (GTK_IMAGE(launcher->image), launcher->zoomed_img);
@@ -553,17 +592,50 @@
 }
 
 
+void launcher_set_has_tooltip(t_launcher *launcher, gboolean has_tooltip)
+{
+	if(launcher->tooltip)
+		g_object_unref_sink(launcher->tooltip);
+	if(has_tooltip)
+	{
+		launcher->tooltip = gtk_tooltips_new();
+		gtk_tooltips_set_tip(launcher->tooltip, launcher->box, launcher->command, launcher->command);
+	}
+	else
+		launcher->tooltip = NULL;
+}
+
+
+void launcher_set_has_label(t_launcher *launcher, gboolean has_label)
+{
+	if(launcher->label)
+		gtk_widget_destroy(launcher->label);
+	if(has_label)
+	{
+		launcher->label = gtk_label_new(launcher->command);
+		gtk_box_pack_end(GTK_BOX(launcher->box), launcher->label, FALSE, FALSE, 0);
+		gtk_widget_show(launcher->label);
+	}
+	else
+		launcher->label = NULL;
+}
+
+
 void create_launcher(t_launcher	*launcher)
 {
+	launcher->box = g_object_ref(gtk_hbox_new(FALSE, 0));
+	DBG ("create launcher %s with box %d", launcher->command, (gint)launcher->box);
 	launcher->image = g_object_ref(gtk_image_new());
-	launcher->tooltip = gtk_tooltips_new();
+	gtk_box_pack_start(GTK_BOX(launcher->box), launcher->image, FALSE, FALSE, 0);
 	launcher_update_icon(launcher, launcher->quicklauncher->icon_size);
-	gtk_tooltips_set_tip(launcher->tooltip, launcher->image, launcher->command, launcher->command);
-	gtk_widget_show (launcher->image);
+	gtk_widget_show(launcher->image);
+	launcher_set_has_tooltip(launcher, launcher->quicklauncher->has_tooltips);
+	launcher_set_has_label(launcher, launcher->quicklauncher->has_labels);
+	gtk_widget_show (launcher->box);
 }
 
-t_launcher *
-launcher_new (const gchar *command, gint icon_id, const gchar *icon_name, t_quicklauncher* quicklauncher)
+t_launcher *launcher_new (const gchar *command, gint icon_id, const gchar *icon_name, 
+							t_quicklauncher* quicklauncher)
 {
 	t_launcher *launcher;
 	launcher = g_new0 (t_launcher, 1);
@@ -586,13 +658,12 @@
 	UNREF(launcher->def_img);
 	UNREF(launcher->zoomed_img);
 	UNREF(launcher->clicked_img);
-	//g_object_unref(launcher->tooltip);
+	if(launcher->tooltip)
+		g_object_unref_sink(launcher->tooltip);
+	g_object_unref(launcher->box);
 	g_object_unref(launcher->image);
-
-	//gtk_widget_destroy(launcher->widget); //useless: handled by gtk
 	g_free(launcher->icon_name);
 	g_free(launcher->command);
-
     g_free (launcher);
 }
 
@@ -603,14 +674,10 @@
 	t_launcher *launcher;
 	g_sprintf(group, "launcher_%d%c", num,0);
 	xfce_rc_set_group(rcfile, group);
-
-	launcher = g_new0 (t_launcher, 1);
-	launcher->quicklauncher = quicklauncher;
-	launcher->command = g_strdup(xfce_rc_read_entry(rcfile, "command", NULL));
-	launcher->icon_name = g_strdup(xfce_rc_read_entry(rcfile, "icon_name", NULL));
-	launcher->icon_id = xfce_rc_read_int_entry(rcfile, "icon_id", 0);
-
-	create_launcher(launcher);
+	launcher = launcher_new(xfce_rc_read_entry(rcfile, "command", NULL),
+							xfce_rc_read_int_entry(rcfile, "icon_id", 0),
+							xfce_rc_read_entry(rcfile, "icon_name", NULL),
+							quicklauncher);
 	return launcher;
 }
 
@@ -618,9 +685,12 @@
 launcher_save_config(t_launcher *launcher, XfceRc *rcfile, guint16 num)
 {
 	char group[15];
+	DBG("\t launcher %d: %s", num, launcher->command);
 	g_sprintf(group, "launcher_%d%c", num,0);
+	xfce_rc_delete_group(rcfile, group, FALSE);
 	xfce_rc_set_group(rcfile, group);
-	xfce_rc_write_entry(rcfile, "command", launcher->command);
+	if(launcher->command)
+		xfce_rc_write_entry(rcfile, "command", launcher->command);
 	if(launcher->icon_name)
 		xfce_rc_write_entry(rcfile, "icon_name", launcher->icon_name);
 	xfce_rc_write_int_entry(rcfile, "icon_id", launcher->icon_id);

Modified: xfce4-quicklauncher-plugin/trunk/panel-plugin/types.h
===================================================================
--- xfce4-quicklauncher-plugin/trunk/panel-plugin/types.h	2007-03-31 17:06:46 UTC (rev 2643)
+++ xfce4-quicklauncher-plugin/trunk/panel-plugin/types.h	2007-04-01 14:27:28 UTC (rev 2644)
@@ -2,8 +2,8 @@
  *            types.h
  *
  *  Thu Jul 15 06:01:04 2004
- *  Last Update: 03/04/2005
- *  Copyright  2004 - 2005  bountykiller
+ *  Last Update: 31/03/2007
+ *  Copyright  2004 - 2007  bountykiller
  *  Email: masse_nicolas at yahoo.fr
  ****************************************************************************/
 // This program is free software; you can redistribute it and/or modify
@@ -32,7 +32,6 @@
 #define XFCE_ICON_CATEGORY_STOCK 		(XFCE_N_BUILTIN_ICON_CATEGORIES + 1) //not used yet
 #define XFCE_ICON_CATEGORY_EXTERN		(XFCE_N_BUILTIN_ICON_CATEGORIES + 2) //no this isn't nice
 
-#define DEFAULT_ICON_THEME		(xfce_icon_theme_get_for_screen(NULL))
 #define UNREF(x)				if((x)) {g_object_unref((x));}
 
 
@@ -54,6 +53,8 @@
 	gint nb_launcher;
 	gint _last_zoomed_launcher_id;
 	gulong command_ids[4];
+	gboolean has_tooltips;
+	gboolean has_labels;
 }
 t_quicklauncher;
 
@@ -77,6 +78,8 @@
 	GtkWidget *image1;
 	GtkWidget *btn_up;
 	GtkWidget *btn_down;
+	GtkWidget *chk_tooltip;
+	GtkWidget *chk_labels;
 	t_quicklauncher *quicklauncher;
 }
 t_qck_launcher_opt_dlg;
@@ -84,7 +87,9 @@
 
 typedef struct
 {
+	GtkWidget *box;
 	GtkWidget *image;
+	GtkWidget *label;
 	GdkPixbuf  *def_img;
 	GdkPixbuf  *zoomed_img;
 	GdkPixbuf  *clicked_img;
@@ -102,16 +107,15 @@
 
 t_launcher* launcher_new (const gchar *command, gint icon_id,
 						const gchar *icon_name, t_quicklauncher *quicklauncher);
-
 void launcher_free (t_launcher *launcher);
 void launcher_update_icon(t_launcher *launcher, gint size) ;
-
-
 t_quicklauncher *quicklauncher_new (XfcePanelPlugin *plugin);
 void quicklauncher_add_element(t_quicklauncher *quicklauncher, t_launcher *launcher);
 t_launcher* quicklauncher_remove_element(t_quicklauncher *quicklauncher, gint num);
 void quicklauncher_organize(t_quicklauncher *quicklauncher);
 void quicklauncher_empty_widgets(t_quicklauncher *quicklauncher);
 void quicklauncher_set_nblines(t_quicklauncher *quicklauncher, gint nb_lines);
+void quicklauncher_set_has_tooltips(t_quicklauncher *quicklauncher, gboolean value);
+void quicklauncher_set_has_labels(t_quicklauncher *quicklauncher, gboolean value);
 
 #endif




More information about the Goodies-commits mailing list