[Goodies-commits] r5036 - in xfce4-clipman-plugin/branches/mmassonnet: . panel-plugin
Mike Massonnet
mmassonnet at xfce.org
Wed Jul 9 12:40:08 CEST 2008
Author: mmassonnet
Date: 2008-07-09 10:40:08 +0000 (Wed, 09 Jul 2008)
New Revision: 5036
Added:
xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman-settings.c
xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman-settings.h
Modified:
xfce4-clipman-plugin/branches/mmassonnet/configure.in.in
xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman.c
xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman.h
Log:
Code cleanup
Modified: xfce4-clipman-plugin/branches/mmassonnet/configure.in.in
===================================================================
--- xfce4-clipman-plugin/branches/mmassonnet/configure.in.in 2008-07-09 00:52:31 UTC (rev 5035)
+++ xfce4-clipman-plugin/branches/mmassonnet/configure.in.in 2008-07-09 10:40:08 UTC (rev 5036)
@@ -65,6 +65,18 @@
XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0])
XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.4.0])
+dnl *********************************
+dnl *** Check for configure flags ***
+dnl *********************************
+AC_ARG_ENABLE([list-store],
+ [AC_HELP_STRING([--with-list-store],
+ [Build Clipman Plugin with a GtkListStore instead of GLists])],
+ [liststore=$enableval],
+ [liststore=no])
+if test "x$liststore" = "xyes"; then
+ AC_DEFINE([WITH_LIST_STORE], [1], [Define if build with a GtkListStore])
+fi
+
dnl ***********************************
dnl *** Check for debugging support ***
dnl ***********************************
Added: xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman-settings.c
===================================================================
Added: xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman-settings.h
===================================================================
Modified: xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman.c
===================================================================
--- xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman.c 2008-07-09 00:52:31 UTC (rev 5035)
+++ xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman.c 2008-07-09 10:40:08 UTC (rev 5036)
@@ -1,7 +1,7 @@
/* $Id$
*
* Copyright (c) 2006-2007 Nick Schermer <nick at xfce.org>
- * Copyright (c) 2007 Mike Massonnet <mmassonnet at xfce.org>
+ * Copyright (c) 2007-2008 Mike Massonnet <mmassonnet at xfce.org>
*
* 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
@@ -32,59 +32,49 @@
+/* Panel Plugin functions */
static void clipman_plugin_register (XfcePanelPlugin *panel_plugin);
-
-static ClipmanPlugin * clipman_plugin_new (XfcePanelPlugin *panel_plugin);
-
static void clipman_plugin_load_data (ClipmanPlugin *clipman_plugin);
-
static void clipman_plugin_save_data (ClipmanPlugin *clipman_plugin);
-
static void clipman_plugin_free (ClipmanPlugin *clipman_plugin);
+static gboolean clipman_plugin_set_size (ClipmanPlugin *clipman_plugin,
+ gint size);
+static gboolean clipman_plugin_message_received (ClipmanPlugin *clipman_plugin,
+ GdkEventClient *ev);
+static gboolean clipman_plugin_set_selection (ClipmanPlugin *clipman_plugin);
-static gboolean clipman_plugin_set_size (ClipmanPlugin *clipman_plugin,
- gint size);
+/* Clipman Plugin functions */
+static ClipmanPlugin * clipman_plugin_new (XfcePanelPlugin *panel_plugin);
static gchar * clipman_plugin_get_short_text (ClipmanPlugin *clipman_plugin,
- const gchar *text);
+ const gchar *text);
static void clipman_plugin_menu_new (ClipmanPlugin *clipman_plugin);
-
-static void clipman_plugin_menu_insert_clip (ClipmanClip *clip,
+static void clipman_plugin_menu_insert_clip (ClipmanClip *clip,
ClipmanPlugin *clipman_plugin);
static void clipman_plugin_menu_popup (ClipmanPlugin *clipman_plugin);
-
-static void clipman_plugin_menu_position (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data);
+static void clipman_plugin_menu_position (GtkMenu *menu,
+ gint *x,
+ gint *y,
+ gboolean *push_in,
+ gpointer user_data);
static void clipman_plugin_menu_destroy (ClipmanPlugin *clipman_plugin);
-
-static void clipman_plugin_menu_item_activate (GtkWidget *widget,
+static void clipman_plugin_menu_item_activate (GtkWidget *widget,
ClipmanPlugin *clipman_plugin);
-static gboolean clipman_plugin_menu_item_pressed (GtkWidget *widget,
+static gboolean clipman_plugin_menu_item_pressed (GtkWidget *widget,
GdkEventButton *event,
ClipmanPlugin *clipman_plugin);
static void clipman_plugin_add_static (ClipmanPlugin *clipman_plugin);
-
static void clipman_plugin_add_static_with_text (ClipmanPlugin *clipman_plugin,
- const gchar *text);
-static void clipman_plugin_delete (ClipmanPlugin *clipman_plugin,
- ClipmanClip *clip);
-static gboolean clipman_plugin_message_received (ClipmanPlugin *clipman_plugin,
- GdkEventClient *ev);
-static gboolean clipman_plugin_set_selection (ClipmanPlugin *clipman_plugin);
+ const gchar *text);
+static void clipman_plugin_delete_clip (ClipmanPlugin *clipman_plugin,
+ ClipmanClip *clip);
+static void clipman_plugin_clear_history (ClipmanPlugin *clipman_plugin);
-
-
-
+/* Clipman Clips functions */
static ClipmanClips * clipman_clips_new (ClipmanPlugin *clipman_plugin);
-
+static gboolean clipman_clips_check_clipboard (ClipmanClips *clipman_clips);
static void clipman_clips_clear_history (ClipmanClips *clipman_clips);
-
static void clipman_clips_restore_empty (ClipmanClips *clipman_clips,
ClipboardType type);
-static gboolean clipman_clips_check_clipboard (ClipmanClips *clipman_clips);
-
static void clipman_clips_add (ClipmanClips *clipman_clips,
gchar *text,
ClipboardType type);
@@ -92,18 +82,15 @@
ClipmanClip *two);
static gint clipman_clips_compare_with_type (ClipmanClip *one,
ClipmanClip *two);
+static ClipmanClip * clipman_clips_new_clip (gchar *text, ClipboardType type);
+static void clipman_clips_free_clip (ClipmanClip *clip);
-static ClipmanClip * clipman_clip_new (gchar *text, ClipboardType type);
-static void clipman_clip_free (ClipmanClip *clip);
-
-
-
-
XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (clipman_plugin_register);
+/* Panel Plugin functions */
static void
clipman_plugin_register (XfcePanelPlugin *panel_plugin)
{
@@ -136,29 +123,6 @@
gtk_widget_show_all (clipman_plugin->button);
}
-static ClipmanPlugin *
-clipman_plugin_new (XfcePanelPlugin *panel_plugin)
-{
- ClipmanPlugin *clipman_plugin = g_slice_new0 (ClipmanPlugin);
- clipman_plugin->panel_plugin = panel_plugin;
- clipman_plugin->clipman_clips = clipman_clips_new (clipman_plugin);
-
- clipman_plugin->button = xfce_create_panel_toggle_button ();
- clipman_plugin->icon = gtk_image_new ();
-
- gtk_container_add (GTK_CONTAINER (clipman_plugin->button), clipman_plugin->icon);
- gtk_container_add (GTK_CONTAINER (panel_plugin), clipman_plugin->button);
-
- g_signal_connect_swapped (clipman_plugin->button,
- "toggled",
- G_CALLBACK (clipman_plugin_menu_popup),
- clipman_plugin);
-
- clipman_plugin_load_data (clipman_plugin);
-
- return clipman_plugin;
-}
-
static void
clipman_plugin_load_data (ClipmanPlugin *clipman_plugin)
{
@@ -312,13 +276,12 @@
static void
clipman_plugin_free (ClipmanPlugin *clipman_plugin)
{
- /* There are no resources to free that won't be after we quit the plugin */
gtk_main_quit ();
}
static gboolean
clipman_plugin_set_size (ClipmanPlugin *clipman_plugin,
- gint size)
+ gint size)
{
gtk_widget_set_size_request (GTK_WIDGET (clipman_plugin->panel_plugin), size, size);
size -= 2 + 2 * MAX (clipman_plugin->button->style->xthickness,
@@ -342,9 +305,87 @@
return TRUE;
}
+static gboolean
+clipman_plugin_message_received (ClipmanPlugin *clipman_plugin,
+ GdkEventClient *ev)
+{
+ DBG ("Message received");
+ if (G_LIKELY (ev->data_format == 8 && *(ev->data.b) != '\0'))
+ {
+ if (!g_ascii_strcasecmp (XFCE_CLIPMAN_MESSAGE, ev->data.b))
+ {
+ DBG ("`%s'", ev->data.b);
+ xfce_panel_plugin_set_panel_hidden (clipman_plugin->panel_plugin, FALSE);
+ while (gtk_events_pending ())
+ gtk_main_iteration ();
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (clipman_plugin->button), TRUE);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static gboolean
+clipman_plugin_set_selection (ClipmanPlugin *clipman_plugin)
+{
+ GdkScreen *gscreen;
+ gchar *selection_name;
+ Atom selection_atom;
+ GtkWidget *win;
+ Window id;
+
+ win = gtk_invisible_new ();
+ gtk_widget_realize (win);
+ id = GDK_WINDOW_XID (GTK_WIDGET (win)->window);
+
+ gscreen = gtk_widget_get_screen (win);
+ selection_name = g_strdup_printf (XFCE_CLIPMAN_SELECTION"%d",
+ gdk_screen_get_number (gscreen));
+ selection_atom = XInternAtom (GDK_DISPLAY (), selection_name, FALSE);
+
+ if (XGetSelectionOwner (GDK_DISPLAY (), selection_atom))
+ {
+ gtk_widget_destroy (win);
+ return FALSE;
+ }
+
+ XSelectInput (GDK_DISPLAY (), id, PropertyChangeMask);
+ XSetSelectionOwner (GDK_DISPLAY (), selection_atom, id, GDK_CURRENT_TIME);
+
+ g_signal_connect_swapped (win, "client-event",
+ G_CALLBACK (clipman_plugin_message_received),
+ clipman_plugin);
+
+ return TRUE;
+}
+
+/* Clipman Plugin functions */
+static ClipmanPlugin *
+clipman_plugin_new (XfcePanelPlugin *panel_plugin)
+{
+ ClipmanPlugin *clipman_plugin = g_slice_new0 (ClipmanPlugin);
+ clipman_plugin->panel_plugin = panel_plugin;
+ clipman_plugin->clipman_clips = clipman_clips_new (clipman_plugin);
+
+ clipman_plugin->button = xfce_create_panel_toggle_button ();
+ clipman_plugin->icon = gtk_image_new ();
+
+ gtk_container_add (GTK_CONTAINER (clipman_plugin->button), clipman_plugin->icon);
+ gtk_container_add (GTK_CONTAINER (panel_plugin), clipman_plugin->button);
+
+ g_signal_connect_swapped (clipman_plugin->button,
+ "toggled",
+ G_CALLBACK (clipman_plugin_menu_popup),
+ clipman_plugin);
+
+ clipman_plugin_load_data (clipman_plugin);
+
+ return clipman_plugin;
+}
+
static gchar *
clipman_plugin_get_short_text (ClipmanPlugin *clipman_plugin,
- const gchar *text)
+ const gchar *text)
{
gchar *short_text, *tmp = NULL;
const gchar *offset;
@@ -355,6 +396,11 @@
short_text = g_strstrip (g_strdup (text));
+ /* Cleanup */
+ tmp = g_strdelimit (short_text, "\n\r\t", ' ');
+ short_text = g_markup_escape_text (tmp, -1);
+ g_free (tmp);
+
/* Shorten */
max_length = clipman_plugin->menu_item_max_chars;
if (g_utf8_strlen (short_text, -1) > max_length)
@@ -367,11 +413,6 @@
g_free (tmp);
}
- /* Cleanup */
- tmp = g_strdelimit (short_text, "\n\r\t", ' ');
- short_text = g_markup_escape_text (tmp, -1);
- g_free (tmp);
-
return short_text;
}
@@ -444,8 +485,8 @@
gtk_menu_shell_append (GTK_MENU_SHELL (clipman_plugin->menu), mi);
g_signal_connect_swapped (mi,
"activate",
- G_CALLBACK (clipman_clips_clear_history),
- clipman_plugin->clipman_clips);
+ G_CALLBACK (clipman_plugin_clear_history),
+ clipman_plugin);
/* Do the rest */
g_signal_connect_swapped (clipman_plugin->menu,
@@ -463,7 +504,7 @@
}
static void
-clipman_plugin_menu_insert_clip (ClipmanClip *clip,
+clipman_plugin_menu_insert_clip (ClipmanClip *clip,
ClipmanPlugin *clipman_plugin)
{
static gint i = 0, j = 0;
@@ -478,14 +519,14 @@
/* Get current clipboards */
if (clip->type != STATIC && G_UNLIKELY (NULL == clip_default))
{
- /* The allocation of text is used as-is in clipman_clip_new() */
+ /* The allocation of text is used as-is in clipman_clips_new_clip() */
text = gtk_clipboard_wait_for_text (clipman_plugin->clipman_clips->default_clipboard);
- clip_default = clipman_clip_new (text, DEFAULT);
+ clip_default = clipman_clips_new_clip (text, DEFAULT);
if (G_UNLIKELY (NULL == clip_default->text))
clip_default->text = g_strdup ("");
text = gtk_clipboard_wait_for_text (clipman_plugin->clipman_clips->primary_clipboard);
- clip_primary = clipman_clip_new (text, PRIMARY);
+ clip_primary = clipman_clips_new_clip (text, PRIMARY);
if (G_UNLIKELY (NULL == clip_primary->text))
clip_primary->text = g_strdup ("");
}
@@ -605,7 +646,7 @@
break;
}
- /* Check if the clip matches the last clip */
+ /* Check if the clip matches the last clip to reset stuff and static vars */
if (clip == clip_last)
{
if (clip->type != STATIC && clipman_plugin->clipman_clips->behavior == STRICTLY)
@@ -634,9 +675,9 @@
/* Free memory */
if (NULL != clip_default)
- clipman_clip_free (clip_default);
+ clipman_clips_free_clip (clip_default);
if (NULL != clip_primary)
- clipman_clip_free (clip_primary);
+ clipman_clips_free_clip (clip_primary);
/* Unset static variables */
clip_default = clip_primary = clip_last = NULL;
@@ -663,11 +704,11 @@
}
static void
-clipman_plugin_menu_position (GtkMenu *menu,
- gint *x,
- gint *y,
+clipman_plugin_menu_position (GtkMenu *menu,
+ gint *x,
+ gint *y,
gboolean *push_in,
- gpointer user_data)
+ gpointer user_data)
{
XfcePanelPlugin *panel_plugin = user_data;
GtkWidget *button;
@@ -724,7 +765,7 @@
}
static void
-clipman_plugin_menu_item_activate (GtkWidget *widget,
+clipman_plugin_menu_item_activate (GtkWidget *widget,
ClipmanPlugin *clipman_plugin)
{
g_return_if_fail (G_LIKELY (GTK_IS_WIDGET (widget)));
@@ -753,7 +794,7 @@
}
static gboolean
-clipman_plugin_menu_item_pressed (GtkWidget *widget,
+clipman_plugin_menu_item_pressed (GtkWidget *widget,
GdkEventButton *event,
ClipmanPlugin *clipman_plugin)
{
@@ -770,7 +811,7 @@
/* Delete item */
else if (event->button == 3)
- clipman_plugin_delete (clipman_plugin, clip);
+ clipman_plugin_delete_clip (clipman_plugin, clip);
return TRUE;
}
@@ -783,7 +824,7 @@
static void
clipman_plugin_add_static_with_text (ClipmanPlugin *clipman_plugin,
- const gchar *text)
+ const gchar *text)
{
/* Dialog */
GtkWidget *dialog =
@@ -796,6 +837,8 @@
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_PASTE);
gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 110);
+ gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), TRUE);
+ gtk_window_set_decorated (GTK_WINDOW (dialog), FALSE);
/* Box */
GtkWidget *vbox = GTK_DIALOG (dialog)->vbox;
@@ -836,8 +879,8 @@
}
static void
-clipman_plugin_delete (ClipmanPlugin *clipman_plugin,
- ClipmanClip *clip)
+clipman_plugin_delete_clip (ClipmanPlugin *clipman_plugin,
+ ClipmanClip *clip)
{
GtkWidget *dialog =
gtk_message_dialog_new (NULL,
@@ -876,62 +919,24 @@
clipman_clips_delete (clipman_clips, clip);
}
-static gboolean
-clipman_plugin_message_received (ClipmanPlugin *clipman_plugin,
- GdkEventClient *ev)
+static void
+clipman_plugin_clear_history (ClipmanPlugin *clipman_plugin)
{
- DBG ("Message received");
- if (G_LIKELY (ev->data_format == 8 && *(ev->data.b) != '\0'))
- {
- if (!g_ascii_strcasecmp (XFCE_CLIPMAN_MESSAGE, ev->data.b))
- {
- DBG ("`%s'", ev->data.b);
- xfce_panel_plugin_set_panel_hidden (clipman_plugin->panel_plugin, FALSE);
- while (gtk_events_pending ())
- gtk_main_iteration ();
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (clipman_plugin->button), TRUE);
- return TRUE;
- }
- }
- return FALSE;
+ GtkWidget *dialog =
+ gtk_message_dialog_new (NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_YES_NO,
+ _("Are you sure you want to clear the history?"));
+ gint result = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ if (G_UNLIKELY (result != GTK_RESPONSE_YES))
+ return;
+
+ clipman_clips_clear_history (clipman_plugin->clipman_clips);
}
-static gboolean
-clipman_plugin_set_selection (ClipmanPlugin *clipman_plugin)
-{
- GdkScreen *gscreen;
- gchar *selection_name;
- Atom selection_atom;
- GtkWidget *win;
- Window id;
-
- win = gtk_invisible_new ();
- gtk_widget_realize (win);
- id = GDK_WINDOW_XID (GTK_WIDGET (win)->window);
-
- gscreen = gtk_widget_get_screen (win);
- selection_name = g_strdup_printf (XFCE_CLIPMAN_SELECTION"%d",
- gdk_screen_get_number (gscreen));
- selection_atom = XInternAtom (GDK_DISPLAY (), selection_name, FALSE);
-
- if (XGetSelectionOwner (GDK_DISPLAY (), selection_atom))
- {
- gtk_widget_destroy (win);
- return FALSE;
- }
-
- XSelectInput (GDK_DISPLAY (), id, PropertyChangeMask);
- XSetSelectionOwner (GDK_DISPLAY (), selection_atom, id, GDK_CURRENT_TIME);
-
- g_signal_connect_swapped (win, "client-event",
- G_CALLBACK (clipman_plugin_message_received),
- clipman_plugin);
-
- return TRUE;
-}
-
-
-
+/* Clipman Clips functions */
static ClipmanClips *
clipman_clips_new (ClipmanPlugin *clipman_plugin)
{
@@ -942,8 +947,13 @@
clipman_clips->default_clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
clipman_clips->primary_clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
+ /* TODO Factorize that stuff somehow, something else than static list atoms */
+#ifdef WITH_LIST_STORE
+ clipman_clips->history = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);
+#else
clipman_clips->history = NULL;
clipman_clips->static_clipboard = NULL;
+#endif
clipman_clips->timeout =
g_timeout_add_full (G_PRIORITY_LOW,
@@ -955,24 +965,45 @@
return clipman_clips;
}
+static gboolean
+clipman_clips_check_clipboard (ClipmanClips *clipman_clips)
+{
+ GdkModifierType state;
+ gchar *text; /* We use the new allocation of
+ * gtk_clipboard_wait_for_text,
+ * so no free() on that var */
+
+ /* Default clipboard */
+ text = gtk_clipboard_wait_for_text (clipman_clips->default_clipboard);
+ if (G_LIKELY (NULL != text))
+ clipman_clips_add (clipman_clips, text, DEFAULT);
+ else if (clipman_clips->prevent_empty == TRUE)
+ clipman_clips_restore_empty (clipman_clips, DEFAULT);
+
+ /* Primary clipboard */
+ if (!clipman_clips->ignore_primary)
+ {
+ gdk_window_get_pointer (NULL, NULL, NULL, &state);
+ if (state & GDK_BUTTON1_MASK)
+ return TRUE;
+
+ text = gtk_clipboard_wait_for_text (clipman_clips->primary_clipboard);
+ if (G_LIKELY (NULL != text))
+ clipman_clips_add (clipman_clips, text, PRIMARY);
+ else if (clipman_clips->prevent_empty == TRUE)
+ clipman_clips_restore_empty (clipman_clips, PRIMARY);
+ }
+
+ return TRUE;
+}
+
static void
clipman_clips_clear_history (ClipmanClips *clipman_clips)
{
GSList *list;
- GtkWidget *dialog =
- gtk_message_dialog_new (NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_YES_NO,
- _("Are you sure you want to clear the history?"));
- gint result = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- if (G_UNLIKELY (result != GTK_RESPONSE_YES))
- return;
-
for (list = clipman_clips->history; list != NULL; list = list->next)
- clipman_clip_free ((ClipmanClip *)list->data);
+ clipman_clips_free_clip ((ClipmanClip *)list->data);
g_slist_free (list);
clipman_clips->history = NULL;
@@ -1019,41 +1050,9 @@
DBG ("Restore clipboard to `%s'", clip->text);
}
-static gboolean
-clipman_clips_check_clipboard (ClipmanClips *clipman_clips)
-{
- GdkModifierType state;
- gchar *text; /* We use the new allocation of
- * gtk_clipboard_wait_for_text,
- * so no free() on that beotche */
-
- /* Default clipboard */
- text = gtk_clipboard_wait_for_text (clipman_clips->default_clipboard);
- if (G_LIKELY (NULL != text))
- clipman_clips_add (clipman_clips, text, DEFAULT);
- else if (clipman_clips->prevent_empty == TRUE)
- clipman_clips_restore_empty (clipman_clips, DEFAULT);
-
- /* Primary clipboard */
- if (!clipman_clips->ignore_primary)
- {
- gdk_window_get_pointer (NULL, NULL, NULL, &state);
- if (state & GDK_BUTTON1_MASK)
- return TRUE;
-
- text = gtk_clipboard_wait_for_text (clipman_clips->primary_clipboard);
- if (G_LIKELY (NULL != text))
- clipman_clips_add (clipman_clips, text, PRIMARY);
- else if (clipman_clips->prevent_empty == TRUE)
- clipman_clips_restore_empty (clipman_clips, PRIMARY);
- }
-
- return TRUE;
-}
-
void
clipman_clips_delete (ClipmanClips *clipman_clips,
- ClipmanClip *clip)
+ ClipmanClip *clip)
{
g_return_if_fail (G_LIKELY (NULL != clip));
@@ -1062,12 +1061,12 @@
else
clipman_clips->history = g_slist_remove (clipman_clips->history, clip);
- clipman_clip_free (clip);
+ clipman_clips_free_clip (clip);
}
static void
clipman_clips_add (ClipmanClips *clipman_clips,
- gchar *text,
+ gchar *text,
ClipboardType type)
{
ClipmanClip *clip;
@@ -1075,19 +1074,22 @@
g_return_if_fail (G_LIKELY (NULL != text));
- clip = clipman_clip_new (text, type);
+ clip = clipman_clips_new_clip (text, type);
if (type == STATIC)
- foobar = g_slist_find_custom (clipman_clips->static_clipboard, clip, (GCompareFunc)clipman_clips_compare);
+ foobar = g_slist_find_custom (clipman_clips->static_clipboard, clip,
+ (GCompareFunc)clipman_clips_compare);
else if (clipman_clips->behavior == STRICTLY)
- foobar = g_slist_find_custom (clipman_clips->history, clip, (GCompareFunc)clipman_clips_compare_with_type);
+ foobar = g_slist_find_custom (clipman_clips->history, clip,
+ (GCompareFunc)clipman_clips_compare_with_type);
else
- foobar = g_slist_find_custom (clipman_clips->history, clip, (GCompareFunc)clipman_clips_compare);
+ foobar = g_slist_find_custom (clipman_clips->history, clip,
+ (GCompareFunc)clipman_clips_compare);
if (G_UNLIKELY (NULL != foobar))
{
/* Free the clip */
- clipman_clip_free (clip);
+ clipman_clips_free_clip (clip);
/* Push the existing clip to the top */
if (type != STATIC)
@@ -1107,7 +1109,8 @@
{
clipman_clips->history = g_slist_prepend (clipman_clips->history, clip);
if (g_slist_length (clipman_clips->history) > clipman_clips->history_length)
- clipman_clips_delete (clipman_clips, (ClipmanClip *)(g_slist_last (clipman_clips->history)->data));
+ clipman_clips_delete (clipman_clips,
+ (ClipmanClip *)(g_slist_last (clipman_clips->history)->data));
}
}
@@ -1129,12 +1132,9 @@
return -1;
}
-
-
-
static ClipmanClip *
-clipman_clip_new (gchar *text,
- ClipboardType type)
+clipman_clips_new_clip (gchar *text,
+ ClipboardType type)
{
ClipmanClip *clip = g_slice_new (ClipmanClip);
clip->type = type;
@@ -1144,7 +1144,7 @@
}
static void
-clipman_clip_free (ClipmanClip *clip)
+clipman_clips_free_clip (ClipmanClip *clip)
{
g_return_if_fail (G_LIKELY (NULL != clip));
g_free (clip->text);
Modified: xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman.h
===================================================================
--- xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman.h 2008-07-09 00:52:31 UTC (rev 5035)
+++ xfce4-clipman-plugin/branches/mmassonnet/panel-plugin/clipman.h 2008-07-09 10:40:08 UTC (rev 5036)
@@ -52,6 +52,16 @@
/* Milisecond to check the clipboards(s) */
#define TIMER_INTERVAL 1000
+/* crap */
+enum
+{
+ COLUMN_TEXT,
+ COLUMN_SHORT_TEXT,
+ COLUMN_TYPE,
+ N_COLUMNS,
+};
+/* end crap */
+
typedef enum
{
DEFAULT,
@@ -99,8 +109,12 @@
gint timeout;
+#ifdef WITH_LIST_STORE
+ GtkListStore *history;
+#else
GSList *history;
GSList *static_clipboard;
+#endif
ClipboardBehavior behavior;
gint history_length;
More information about the Goodies-commits
mailing list