[Goodies-commits] r3864 - xfce4-clipman-plugin/trunk/panel-plugin
Mike Massonnet
mmassonnet at xfce.org
Thu Jan 24 14:09:04 CET 2008
Author: mmassonnet
Date: 2008-01-24 13:09:04 +0000 (Thu, 24 Jan 2008)
New Revision: 3864
Modified:
xfce4-clipman-plugin/trunk/panel-plugin/clipman.c
Log:
* panel-plugin/clipman.c(clipman_plugin_load_data),
panel-plugin/clipman.c(clipman_plugin_save_data): Replace g_return_if_fail
with return since it wouldn't be a bug in the application, but a end-user
problem (file permission, ...).
* panel-plugin/clipman.c(clipman_plugin_get_short_text): Replace the UTF-8
ellipsis with "...".
* panel-plugin/clipman.c(clipman_plugin_menu_insert_clip),
panel-plugin/clipman.c(clipman_plugin_menu_item_activate),
panel-plugin/clipman.c(clipman_plugin_menu_item_pressed): Set a gobject data
with the pointer of the clip. Remove the g_slist_nth_data() calls.
Modified: xfce4-clipman-plugin/trunk/panel-plugin/clipman.c
===================================================================
--- xfce4-clipman-plugin/trunk/panel-plugin/clipman.c 2008-01-24 13:08:58 UTC (rev 3863)
+++ xfce4-clipman-plugin/trunk/panel-plugin/clipman.c 2008-01-24 13:09:04 UTC (rev 3864)
@@ -163,10 +163,8 @@
ClipmanClips *clipman_clips = clipman_plugin->clipman_clips;
file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "xfce4/panel/clipman.rc", TRUE);
- /* NOTE: you cannot use g_return_if_fail if fail here, first because users
- * can disable this check and returning null is possible in normal
- * situations: permission problems */
- g_return_if_fail (G_LIKELY (NULL != file));
+ if (G_UNLIKELY (NULL == file))
+ return;
rc = xfce_rc_simple_open (file, FALSE);
g_free (file);
@@ -245,8 +243,8 @@
gchar *file;
file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "xfce4/panel/clipman.rc", TRUE);
- /* NOTE same here */
- g_return_if_fail (G_LIKELY (NULL != file));
+ if (G_UNLIKELY (NULL == file))
+ return;
rc = xfce_rc_simple_open (file, FALSE);
g_free (file);
@@ -364,7 +362,7 @@
tmp = g_strndup (short_text, offset - short_text);
g_free (short_text);
- short_text = g_strconcat (tmp, "\342\200\246", NULL); /* Ellipsis U+2026 */
+ short_text = g_strconcat (tmp, "...", NULL); /* Ellipsis */
g_free (tmp);
}
@@ -556,9 +554,7 @@
gtk_label_set_markup (GTK_LABEL (GTK_BIN (mi)->child), text);
g_free (text);
- g_object_set_data (G_OBJECT (mi), "index", GINT_TO_POINTER (i+j));
- if (clip->type == STATIC)
- g_object_set_data (G_OBJECT (mi), "static", GINT_TO_POINTER (1));
+ g_object_set_data (G_OBJECT (mi), "clip", clip);
/* Connect signals */
g_signal_connect (mi,
@@ -733,18 +729,10 @@
ClipmanPlugin *clipman_plugin)
{
g_return_if_fail (G_LIKELY (GTK_IS_WIDGET (widget)));
- gint i = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "index"));
- gint type_is_static = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "static"));
-
- ClipmanClip *clip = NULL;
- if (type_is_static)
- clip = (ClipmanClip *)g_slist_nth_data (clipman_plugin->clipman_clips->static_clipboard, i);
- else
- clip = (ClipmanClip *)g_slist_nth_data (clipman_plugin->clipman_clips->history, i);
+ ClipmanClip *clip = g_object_get_data (G_OBJECT (widget), "clip");
g_return_if_fail (G_LIKELY (NULL != clip));
- DBG ("Copy `%s' to clipboard", clip->text);
-
+ /* Copy the clip to the clipboard */
if (clip->type != STATIC && clipman_plugin->clipman_clips->behavior == STRICTLY)
{
if (clip->type == PRIMARY)
@@ -752,6 +740,7 @@
else
gtk_clipboard_set_text (clipman_plugin->clipman_clips->default_clipboard, clip->text, -1);
}
+ /* Copy the static clip to the clipboard */
else
{
StaticSelection static_selection = clipman_plugin->clipman_clips->static_selection;
@@ -769,21 +758,13 @@
GdkEventButton *event,
ClipmanPlugin *clipman_plugin)
{
- g_return_val_if_fail (G_LIKELY (GTK_IS_WIDGET (widget)), FALSE);
-
if (event->button != 3 && event->button != 2)
return FALSE;
- gint i = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "index"));
- gint type_is_static = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "static"));
+ g_return_val_if_fail (G_LIKELY (GTK_IS_WIDGET (widget)), FALSE);
+ ClipmanClip *clip = g_object_get_data (G_OBJECT (widget), "clip");
+ g_return_val_if_fail (G_LIKELY (NULL != clip), FALSE);
- ClipmanClip *clip = NULL;
- if (type_is_static)
- clip = (ClipmanClip *)g_slist_nth_data (clipman_plugin->clipman_clips->static_clipboard, i);
- else
- clip = (ClipmanClip *)g_slist_nth_data (clipman_plugin->clipman_clips->history, i);
- g_return_val_if_fail (G_LIKELY (NULL != clip), TRUE);
-
/* Copy clip to static clipboard */
if (event->button == 2)
clipman_plugin_add_static_with_text (clipman_plugin, clip->text);
More information about the Goodies-commits
mailing list