From 39640277d8e0c2fc3b51e4f7db2e0217394406dc Mon Sep 17 00:00:00 2001 From: Cristian Henzel Date: Sat, 21 May 2011 19:56:46 +0300 Subject: [PATCH] ClipIt-1.4.0-20110521001 + Added: We are now using the shipped icon in the systray. Changes to be committed: modified: ChangeLog modified: TODO modified: src/history.h modified: src/main.c modified: src/utils.c --- ChangeLog | 3 +++ TODO | 2 -- src/history.h | 2 +- src/main.c | 13 ++++++++++++- src/utils.c | 12 ++++++++++-- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3cbeedf..5a23fd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +ClipIt-1.4.0-20110521001 - 21 May. 2011 + + Added: We are now using the shipped icon in the systray. + ClipIt-1.4.0-20110520002 - 20 May. 2011 + Fixed: Remove duplicate truncate_history functionality. + Added: Added basic history item structure. diff --git a/TODO b/TODO index 075aae3..bd0c6d1 100644 --- a/TODO +++ b/TODO @@ -4,6 +4,4 @@ actually use that return value to display an error if there was one. + Redo Preferences dialog. + Clean up the code and indent it properly. -+ Move all pop-up and menu functions from main.c to menus.c. -+ Use the shipped icon in the display. + history structure has to be changed in: main.c, manage.c, history.c diff --git a/src/history.h b/src/history.h index b386b4e..d0871dc 100644 --- a/src/history.h +++ b/src/history.h @@ -34,7 +34,7 @@ G_BEGIN_DECLS typedef struct { gboolean is_static; - char *content; + gpointer content; } history_item; extern GSList *history; diff --git a/src/main.c b/src/main.c index e3f20d9..6cf24b9 100644 --- a/src/main.c +++ b/src/main.c @@ -44,6 +44,7 @@ static gchar* clipboard_text; static gchar* synchronized_text; static GtkClipboard* primary; static GtkClipboard* clipboard; +static char *trayicon_path; #ifdef HAVE_APPINDICATOR static AppIndicator *indicator; static GtkWidget *indicator_menu = NULL; @@ -195,6 +196,15 @@ static gboolean item_check(gpointer data) return TRUE; } +static void set_icon_paths() { + gchar *pixmap_dir = g_build_path(G_DIR_SEPARATOR_S, g_get_user_data_dir(), DATA_DIR, "pixmaps", NULL); + gchar *test_path = g_build_path(G_DIR_SEPARATOR_S, pixmap_dir, "trayicon.svg", NULL); + if (g_file_test(test_path, G_FILE_TEST_EXISTS)) + trayicon_path = test_path; + else + trayicon_path = g_build_path(G_DIR_SEPARATOR_S, CLIPITPIXMAPSDIR, "trayicon.svg", NULL); +} + /* Thread function called for each action performed */ static void *execute_action(void *command) { @@ -937,10 +947,11 @@ static void clipit_init() /* Create status icon */ if (!prefs.no_icon) { + set_icon_paths(); #ifdef HAVE_APPINDICATOR create_app_indicator(1); #else - status_icon = gtk_status_icon_new_from_stock(GTK_STOCK_PASTE); + status_icon = gtk_status_icon_new_from_file(trayicon_path); gtk_status_icon_set_tooltip((GtkStatusIcon*)status_icon, _("Clipboard Manager")); g_signal_connect((GObject*)status_icon, "button_press_event", (GCallback)status_icon_clicked, NULL); #endif diff --git a/src/utils.c b/src/utils.c index 7e8e0e5..937a69a 100644 --- a/src/utils.c +++ b/src/utils.c @@ -28,11 +28,11 @@ #include "clipit-i18n.h" /* Creates program related directories if needed */ -void -check_dirs() +void check_dirs() { gchar *data_dir = g_build_path(G_DIR_SEPARATOR_S, g_get_user_data_dir(), DATA_DIR, NULL); gchar *config_dir = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), CONFIG_DIR, NULL); + gchar *pixmap_dir = g_build_path(G_DIR_SEPARATOR_S, g_get_user_data_dir(), DATA_DIR, "pixmaps", NULL); /* Check if data directory exists */ if (!g_file_test(data_dir, G_FILE_TEST_EXISTS)) { @@ -47,9 +47,17 @@ check_dirs() if (g_mkdir_with_parents(config_dir, 0755) != 0) g_warning(_("Couldn't create directory: %s\n"), config_dir); } + /* Check if pixmap directory exists */ + if (!g_file_test(pixmap_dir, G_FILE_TEST_EXISTS)) + { + /* Try to make pixmap directory */ + if (g_mkdir_with_parents(pixmap_dir, 0755) != 0) + g_warning(_("Couldn't create directory: %s\n"), pixmap_dir); + } /* Cleanup */ g_free(data_dir); g_free(config_dir); + g_free(pixmap_dir); } /* Returns TRUE if text is a hyperlink */