ClipIt-v1.3.2-22112010001

+ Fixed: Fixed most of the markup and indentation (replaced double spaces
		with tabs).
+ Fixed: Removed clipboard restoring from history, as this seems to cause
		more problems than it solves.
This commit is contained in:
Cristian Henzel 2010-11-22 10:59:01 +02:00 committed by Cristian Henzel
parent cba465c964
commit 85d1ec0416
15 changed files with 556 additions and 676 deletions

View File

@ -1,3 +1,9 @@
ClipIt-v1.3.2-22112010001 - 22 Nov. 2010
+ Fixed: Fixed most of the markup and indentation (replaced double spaces
with tabs).
+ Fixed: Removed clipboard restoring from history, as this seems to cause
more problems than it solves.
ClipIt-v1.3.1-17112010001 - 17 Nov. 2010
+ Added: Added autostart support for LXDE.
+ Fixed: Fixed problem with "Edit" window not appearing.

View File

@ -2,7 +2,7 @@
# Autoconf/automake.
# -------------------------------------------------------------------------------
AC_PREREQ([2.5])
AC_INIT([clipit], [1.3.1], [oss@web-tm.com])
AC_INIT([clipit], [1.3.2], [oss@web-tm.com])
AM_INIT_AUTOMAKE([AC_PACKAGE_TARNAME()], [AC_PACKAGE_VERSION()])
AC_CONFIG_MACRO_DIR([m4])

View File

@ -32,8 +32,7 @@ static GtkClipboard* clipboard;
/* Called during the daemon loop to protect primary/clipboard contents */
static void
daemon_check()
static void daemon_check()
{
/* Get current primary/clipboard contents */
gchar *primary_temp = gtk_clipboard_wait_for_text(primary);
@ -84,8 +83,7 @@ daemon_check()
}
/* Called if timeout was destroyed */
static void
reset_daemon(gpointer data)
static void reset_daemon(gpointer data)
{
if (timeout_id != 0)
g_source_remove(timeout_id);
@ -98,8 +96,7 @@ reset_daemon(gpointer data)
}
/* Initializes daemon mode */
void
init_daemon_mode()
void init_daemon_mode()
{
/* Create clipboard and primary and connect signals */
primary = gtk_clipboard_get(GDK_SELECTION_PRIMARY);

View File

@ -26,8 +26,7 @@ G_BEGIN_DECLS
#define DAEMON_INTERVAL 500
void
init_daemon_mode();
void init_daemon_mode();
G_END_DECLS

View File

@ -29,8 +29,7 @@
GSList *history;
/* Reads history from ~/.local/share/clipit/history */
void
read_history ()
void read_history ()
{
/* Build file path */
gchar *history_path = g_build_filename(g_get_home_dir(),
@ -68,8 +67,7 @@ read_history ()
}
/* Saves history to ~/.local/share/clipit/history */
void
save_history()
void save_history()
{
/* Check that the directory is available */
check_dirs();
@ -87,8 +85,9 @@ save_history()
/* Write each element to a binary file */
for (element = history; element != NULL; element = element->next)
{
/* Create new GString from element data, write its length (size)
* to file followed by the element data itself
/* Create new GString from element data, write its
* length (size) to file followed by the element
* data itself
*/
GString *item = g_string_new((gchar*)element->data);
fwrite(&(item->len), 4, 1, history_file);
@ -103,8 +102,7 @@ save_history()
}
/* Checks if item should be included in history and calls append */
void
check_and_append(gchar* item)
void check_and_append(gchar *item)
{
if (item)
{
@ -129,12 +127,12 @@ check_and_append(gchar* item)
}
/* Adds item to the end of history */
void
append_item(gchar* item)
void append_item(gchar *item)
{
history = g_slist_prepend(history, g_strdup(item));
/* Shorten history if necessary */
GSList* last_possible_element = g_slist_nth(history, prefs.history_limit - 1);
GSList *last_possible_element = g_slist_nth(history,
prefs.history_limit - 1);
if (last_possible_element)
{
/* Free last posible element and subsequent elements */
@ -147,13 +145,13 @@ append_item(gchar* item)
}
/* Truncates history to history_limit items */
void
truncate_history()
void truncate_history()
{
if (history)
{
/* Shorten history if necessary */
GSList* last_possible_element = g_slist_nth(history, prefs.history_limit - 1);
GSList *last_possible_element = g_slist_nth(history,
prefs.history_limit - 1);
if (last_possible_element)
{
/* Free last posible element and subsequent elements */
@ -167,8 +165,7 @@ truncate_history()
}
/* Returns pointer to last item in history */
gpointer
get_last_item()
gpointer get_last_item()
{
if (history)
{
@ -186,8 +183,7 @@ get_last_item()
}
/* Deletes duplicate item in history */
void
delete_duplicate(gchar* item)
void delete_duplicate(gchar *item)
{
GSList *element;
/* Go through each element compare each */

View File

@ -25,6 +25,7 @@
G_BEGIN_DECLS
#define HISTORY_FILE ".local/share/clipit/history"
/* Set maximum size of one clipboard entry to 1024KB (1MB)
* 1024 pages × 2000 characters per page - should be more than enough.
* WARNING: if you use all 1000 history items, clipit could use up to
@ -33,26 +34,19 @@ G_BEGIN_DECLS
extern GSList* history;
void
read_history();
void read_history();
void
save_history();
void save_history();
void
check_and_append(gchar* item);
void check_and_append(gchar* item);
void
append_item(gchar* item);
void append_item(gchar* item);
void
truncate_history();
void truncate_history();
gpointer
get_last_item();
gpointer get_last_item();
void
delete_duplicate(gchar* item);
void delete_duplicate(gchar* item);
G_END_DECLS

View File

@ -55,8 +55,7 @@ prefs_t prefs = {DEF_USE_COPY, DEF_USE_PRIMARY, DEF_SYNCHRONIZE,
INIT_MENU_KEY, INIT_SEARCH_KEY, DEF_NO_ICON};
/* Called every CHECK_INTERVAL seconds to check for new items */
static gboolean
item_check(gpointer data)
static gboolean item_check(gpointer data)
{
/* Grab the current primary and clipboard text */
gchar* primary_temp = gtk_clipboard_wait_for_text(primary);
@ -80,12 +79,13 @@ item_check(gpointer data)
/* if use_primary is enabled, we restore from primary */
gtk_clipboard_set_text(primary, primary_text, -1);
}
else
{
/* else, we restore from history */
GSList* element = g_slist_nth(history, 0);
gtk_clipboard_set_text(primary, (gchar*)element->data, -1);
}
/* else
* {
* /* else, we restore from history
* GSList* element = g_slist_nth(history, 0);
* gtk_clipboard_set_text(primary, (gchar*)element->data, -1);
* }
*/
}
}
else
@ -186,8 +186,7 @@ item_check(gpointer data)
}
/* Thread function called for each action performed */
static void *
execute_action(void *command)
static void *execute_action(void *command)
{
/* Execute action */
int sys_return;
@ -210,8 +209,7 @@ execute_action(void *command)
}
/* Called when execution action exits */
static void
action_exit(GPid pid, gint status, gpointer data)
static void action_exit(GPid pid, gint status, gpointer data)
{
g_spawn_close_pid(pid);
if (!prefs.no_icon)
@ -223,8 +221,7 @@ action_exit(GPid pid, gint status, gpointer data)
}
/* Called when an action is selected from actions menu */
static void
action_selected(GtkButton *button, gpointer user_data)
static void action_selected(GtkButton *button, gpointer user_data)
{
/* Change icon and enable lock */
actions_lock = TRUE;
@ -255,8 +252,7 @@ action_selected(GtkButton *button, gpointer user_data)
}
/* Called when Edit Actions is selected from actions menu */
static void
edit_actions_selected(GtkButton *button, gpointer user_data)
static void edit_actions_selected(GtkButton *button, gpointer user_data)
{
/* This helps prevent multiple instances */
if (!gtk_grab_get_current())
@ -275,8 +271,7 @@ item_selected(GtkMenuItem *menu_item, gpointer user_data)
}
/* Called when Clear is selected from history menu */
static void
clear_selected(GtkMenuItem *menu_item, gpointer user_data)
static void clear_selected(GtkMenuItem *menu_item, gpointer user_data)
{
/* Check for confirm clear option */
if (prefs.confirm_clear)
@ -323,8 +318,7 @@ clear_selected(GtkMenuItem *menu_item, gpointer user_data)
}
/* Called when About is selected from right-click menu */
static void
show_about_dialog(GtkMenuItem *menu_item, gpointer user_data)
static void show_about_dialog(GtkMenuItem *menu_item, gpointer user_data)
{
/* This helps prevent multiple instances */
if (!gtk_grab_get_current())
@ -391,8 +385,7 @@ show_about_dialog(GtkMenuItem *menu_item, gpointer user_data)
}
/* Called when Preferences is selected from right-click menu */
static void
preferences_selected(GtkMenuItem *menu_item, gpointer user_data)
static void preferences_selected(GtkMenuItem *menu_item, gpointer user_data)
{
/* This helps prevent multiple instances */
if (!gtk_grab_get_current())
@ -401,8 +394,7 @@ preferences_selected(GtkMenuItem *menu_item, gpointer user_data)
}
/* Called when Quit is selected from right-click menu */
static void
quit_selected(GtkMenuItem *menu_item, gpointer user_data)
static void quit_selected(GtkMenuItem *menu_item, gpointer user_data)
{
/* Prevent quit with dialogs open */
if (!gtk_grab_get_current())
@ -411,8 +403,7 @@ quit_selected(GtkMenuItem *menu_item, gpointer user_data)
}
/* Called when status icon is control-clicked */
static gboolean
show_actions_menu(gpointer data)
static gboolean show_actions_menu(gpointer data)
{
/* Declare some variables */
GtkWidget *menu, *menu_item,
@ -521,8 +512,7 @@ show_actions_menu(gpointer data)
return FALSE;
}
static gboolean
show_history_menu_full(gpointer data)
static gboolean show_history_menu_full(gpointer data)
{
/* Declare some variables */
GtkWidget *menu, *menu_item,
@ -550,32 +540,9 @@ show_history_menu_full(gpointer data)
{
GString* string = g_string_new((gchar*)element->data);
/* Ellipsize text */
if (string->len > prefs.item_length)
{
switch (prefs.ellipsize)
{
case PANGO_ELLIPSIZE_START:
string = g_string_erase(string, 0, string->len-(prefs.item_length));
string = g_string_prepend(string, "...");
break;
case PANGO_ELLIPSIZE_MIDDLE:
string = g_string_erase(string, (prefs.item_length/2), string->len-(prefs.item_length));
string = g_string_insert(string, (string->len/2), "...");
break;
case PANGO_ELLIPSIZE_END:
string = g_string_truncate(string, prefs.item_length);
string = g_string_append(string, "...");
break;
}
}
string = ellipsize_string(string);
/* Remove control characters */
int i = 0;
while (i < string->len)
{
if (string->str[i] == '\n')
g_string_overwrite(string, i, " ");
i++;
}
string = remove_newlines_string(string);
/* Make new item with ellipsized text */
gchar* list_item;
if (prefs.show_indexes)
@ -642,8 +609,7 @@ show_history_menu_full(gpointer data)
}
/* Generates the small history menu */
static gboolean
show_history_menu_small(gpointer data)
static gboolean show_history_menu_small(gpointer data)
{
/* Declare some variables */
GtkWidget *menu, *menu_item,
@ -672,32 +638,9 @@ show_history_menu_small(gpointer data)
{
GString* string = g_string_new((gchar*)element->data);
/* Ellipsize text */
if (string->len > prefs.item_length)
{
switch (prefs.ellipsize)
{
case PANGO_ELLIPSIZE_START:
string = g_string_erase(string, 0, string->len-(prefs.item_length));
string = g_string_prepend(string, "...");
break;
case PANGO_ELLIPSIZE_MIDDLE:
string = g_string_erase(string, (prefs.item_length/2), string->len-(prefs.item_length));
string = g_string_insert(string, (string->len/2), "...");
break;
case PANGO_ELLIPSIZE_END:
string = g_string_truncate(string, prefs.item_length);
string = g_string_append(string, "...");
break;
}
}
string = ellipsize_string(string);
/* Remove control characters */
int i = 0;
while (i < string->len)
{
if (string->str[i] == '\n')
g_string_overwrite(string, i, " ");
i++;
}
string = remove_newlines_string(string);
/* Make new item with ellipsized text */
gchar* list_item;
if (prefs.show_indexes)
@ -771,8 +714,7 @@ show_history_menu_small(gpointer data)
}
/* Called when status icon is left-clicked */
static gboolean
show_history_menu()
static gboolean show_history_menu()
{
if (prefs.small_history)
g_timeout_add(POPUP_DELAY, show_history_menu_small, NULL);
@ -783,8 +725,7 @@ show_history_menu()
}
/* Called when status icon is right-clicked */
static void
show_clipit_menu(GtkStatusIcon *status_icon, guint button, guint activate_time)
static void show_clipit_menu(GtkStatusIcon *status_icon, guint button, guint activate_time)
{
/* Declare some variables */
GtkWidget *menu, *menu_item,
@ -827,8 +768,7 @@ show_clipit_menu(GtkStatusIcon *status_icon, guint button, guint activate_time)
/* Called when status icon is clicked */
/* (checks type of click and calls correct function */
static void
status_icon_clicked(GtkStatusIcon *status_icon, GdkEventButton *event )
static void status_icon_clicked(GtkStatusIcon *status_icon, GdkEventButton *event )
{
/* Check what type of click was recieved */
GdkModifierType state;
@ -841,11 +781,12 @@ status_icon_clicked(GtkStatusIcon *status_icon, GdkEventButton *event )
g_timeout_add(POPUP_DELAY, show_actions_menu, NULL);
}
}
/* Normal click */
/* Left click */
else if (event->button == 1)
{
show_history_menu();
}
/* Right click */
else
{
show_clipit_menu(status_icon, event->button, gtk_get_current_event_time());
@ -853,36 +794,31 @@ status_icon_clicked(GtkStatusIcon *status_icon, GdkEventButton *event )
}
/* Called when history global hotkey is pressed */
void
history_hotkey(char *keystring, gpointer user_data)
void history_hotkey(char *keystring, gpointer user_data)
{
g_timeout_add(POPUP_DELAY, show_history_menu, NULL);
}
/* Called when actions global hotkey is pressed */
void
actions_hotkey(char *keystring, gpointer user_data)
void actions_hotkey(char *keystring, gpointer user_data)
{
g_timeout_add(POPUP_DELAY, show_actions_menu, NULL);
}
/* Called when actions global hotkey is pressed */
void
menu_hotkey(char *keystring, gpointer user_data)
void menu_hotkey(char *keystring, gpointer user_data)
{
show_clipit_menu(status_icon, 0, 0);
}
/* Called when search global hotkey is pressed */
void
search_hotkey(char *keystring, gpointer user_data)
void search_hotkey(char *keystring, gpointer user_data)
{
g_timeout_add(POPUP_DELAY, show_search, NULL);
}
/* Startup calls and initializations */
static void
clipit_init()
static void clipit_init()
{
/* Create clipboard */
primary = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
@ -913,8 +849,7 @@ clipit_init()
}
/* This is Sparta! */
int
main(int argc, char *argv[])
int main(int argc, char *argv[])
{
bindtextdomain(GETTEXT_PACKAGE, CLIPITLOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");

View File

@ -65,17 +65,13 @@ prefs_t;
extern prefs_t prefs;
void
history_hotkey(char *keystring, gpointer user_data);
void history_hotkey(char *keystring, gpointer user_data);
void
actions_hotkey(char *keystring, gpointer user_data);
void actions_hotkey(char *keystring, gpointer user_data);
void
menu_hotkey(char *keystring, gpointer user_data);
void menu_hotkey(char *keystring, gpointer user_data);
void
search_hotkey(char *keystring, gpointer user_data);
void search_hotkey(char *keystring, gpointer user_data);
G_END_DECLS

View File

@ -34,8 +34,7 @@ GtkWidget *search_entry;
GtkWidget* treeview_search;
/* Search through the history */
static void
search_history()
static void search_history()
{
guint16 search_len = gtk_entry_get_text_length((GtkEntry*)search_entry);
/* Test if there is text in the search box */
@ -62,31 +61,8 @@ search_history()
{
GtkTreeIter row_iter;
gtk_list_store_append(search_list, &row_iter);
if (string->len > prefs.item_length)
{
switch (prefs.ellipsize)
{
case PANGO_ELLIPSIZE_START:
string = g_string_erase(string, 0, string->len-(prefs.item_length));
string = g_string_prepend(string, "...");
break;
case PANGO_ELLIPSIZE_MIDDLE:
string = g_string_erase(string, (prefs.item_length/2), string->len-(prefs.item_length));
string = g_string_insert(string, (string->len/2), "...");
break;
case PANGO_ELLIPSIZE_END:
string = g_string_truncate(string, prefs.item_length);
string = g_string_append(string, "...");
break;
}
}
int i = 0;
while (i < string->len)
{
if (string->str[i] == '\n')
g_string_overwrite(string, i, " ");
i++;
}
string = ellipsize_string(string);
string = remove_newlines_string(string);
int row_num = g_slist_position(history, element);
gtk_list_store_set(search_list, &row_iter, 0, row_num, 1, string->str, -1);
}
@ -114,31 +90,8 @@ search_history()
GString *string = g_string_new((gchar*)element->data);
GtkTreeIter row_iter;
gtk_list_store_append(search_list, &row_iter);
if (string->len > prefs.item_length)
{
switch (prefs.ellipsize)
{
case PANGO_ELLIPSIZE_START:
string = g_string_erase(string, 0, string->len-(prefs.item_length));
string = g_string_prepend(string, "...");
break;
case PANGO_ELLIPSIZE_MIDDLE:
string = g_string_erase(string, (prefs.item_length/2), string->len-(prefs.item_length));
string = g_string_insert(string, (string->len/2), "...");
break;
case PANGO_ELLIPSIZE_END:
string = g_string_truncate(string, prefs.item_length);
string = g_string_append(string, "...");
break;
}
}
int i = 0;
while (i < string->len)
{
if (string->str[i] == '\n')
g_string_overwrite(string, i, " ");
i++;
}
string = ellipsize_string(string);
string = remove_newlines_string(string);
int row_num = g_slist_position(history, element);
gtk_list_store_set(search_list, &row_iter, 0, row_num, 1, string->str, -1);
@ -150,8 +103,7 @@ search_history()
}
/* Called when Edit is selected from Manage dialog */
static void
edit_selected()
static void edit_selected()
{
GtkTreeIter sel_iter;
GtkTreeSelection* search_selection = gtk_tree_view_get_selection((GtkTreeView*)treeview_search);
@ -201,8 +153,7 @@ edit_selected()
/* Insert new element before the old one */
history = g_slist_insert_before(history, element->next,
g_strdup(gtk_text_buffer_get_text(clipboard_buffer, &start, &end, TRUE))
);
g_strdup(gtk_text_buffer_get_text(clipboard_buffer, &start, &end, TRUE)));
/* Remove old entry */
history = g_slist_remove(history, element->data);
@ -213,8 +164,7 @@ edit_selected()
clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text(clipboard,
gtk_text_buffer_get_text(clipboard_buffer, &start, &end, TRUE),
-1
);
-1);
}
}
gtk_widget_destroy(dialog);
@ -224,8 +174,7 @@ edit_selected()
}
/* Called when Remove is selected from Manage dialog */
static void
remove_selected()
static void remove_selected()
{
GtkTreeIter sel_iter;
GtkTreeSelection* search_selection = gtk_tree_view_get_selection((GtkTreeView*)treeview_search);
@ -242,8 +191,7 @@ remove_selected()
}
}
static void
search_doubleclick()
static void search_doubleclick()
{
GtkTreeIter sel_iter;
GtkTreeSelection* search_selection = gtk_tree_view_get_selection((GtkTreeView*)treeview_search);
@ -260,8 +208,7 @@ search_doubleclick()
}
}
gint
search_click(GtkWidget *widget, GdkEventButton *event, GtkWidget *search_window)
gint search_click(GtkWidget *widget, GdkEventButton *event, GtkWidget *search_window)
{
if(event->type==GDK_2BUTTON_PRESS || event->type==GDK_3BUTTON_PRESS)
{
@ -271,8 +218,7 @@ search_click(GtkWidget *widget, GdkEventButton *event, GtkWidget *search_window)
return FALSE;
}
static gint
search_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
static gint search_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
{
/* Check if [Return] key was pressed */
if ((event->keyval == 0xff0d) || (event->keyval == 0xff8d))
@ -280,8 +226,7 @@ search_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
return FALSE;
}
void
search_window_response(GtkDialog *dialog, gint response_id, gpointer user_data)
void search_window_response(GtkDialog *dialog, gint response_id, gpointer user_data)
{
if(response_id < 0)
{
@ -291,8 +236,7 @@ search_window_response(GtkDialog *dialog, gint response_id, gpointer user_data)
}
/* Shows the search dialog */
gboolean
show_search()
gboolean show_search()
{
/* Prevent multiple instances */
if(gtk_grab_get_current())

View File

@ -24,8 +24,7 @@
G_BEGIN_DECLS
gboolean
show_search();
gboolean show_search();
G_END_DECLS

View File

@ -56,8 +56,7 @@ GtkListStore* exclude_list;
GtkTreeSelection* exclude_selection;
/* Apply the new preferences */
static void
apply_preferences()
static void apply_preferences()
{
/* Unbind the keys before binding new ones */
keybinder_unbind(prefs.history_key, history_hotkey);
@ -104,8 +103,7 @@ apply_preferences()
}
/* Save preferences to ~/.config/clipit/clipitrc */
static void
save_preferences()
static void save_preferences()
{
/* Create key */
GKeyFile* rc_key = g_key_file_new();
@ -142,8 +140,7 @@ save_preferences()
}
/* Read ~/.config/clipit/clipitrc */
void
read_preferences()
void read_preferences()
{
gchar* rc_file = g_build_filename(g_get_home_dir(), PREFERENCES_FILE, NULL);
/* Create key */
@ -203,8 +200,7 @@ read_preferences()
}
/* Read ~/.clipit/actions into the treeview */
static void
read_actions()
static void read_actions()
{
/* Open the file for reading */
gchar* path = g_build_filename(g_get_home_dir(), ACTIONS_FILE, NULL);
@ -243,8 +239,7 @@ read_actions()
}
/* Save the actions treeview to ~/.local/share/clipit/actions */
static void
save_actions()
static void save_actions()
{
/* Check config and data directories */
check_dirs();
@ -298,8 +293,7 @@ save_actions()
}
/* Called when clipboard checks are pressed */
static void
check_toggled(GtkToggleButton *togglebutton, gpointer user_data)
static void check_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
if (gtk_toggle_button_get_active((GtkToggleButton*)copy_check) &&
gtk_toggle_button_get_active((GtkToggleButton*)primary_check))
@ -317,8 +311,7 @@ check_toggled(GtkToggleButton *togglebutton, gpointer user_data)
}
/* Called when Add... button is clicked */
static void
add_action(GtkButton *button, gpointer user_data)
static void add_action(GtkButton *button, gpointer user_data)
{
/* Append new item */
GtkTreeIter row_iter;
@ -334,8 +327,7 @@ add_action(GtkButton *button, gpointer user_data)
}
/* Called when Remove button is clicked */
static void
remove_action(GtkButton *button, gpointer user_data)
static void remove_action(GtkButton *button, gpointer user_data)
{
GtkTreeIter sel_iter;
/* Check if selected */
@ -356,8 +348,7 @@ remove_action(GtkButton *button, gpointer user_data)
}
/* Called when Up button is clicked */
static void
move_action_up(GtkButton *button, gpointer user_data)
static void move_action_up(GtkButton *button, gpointer user_data)
{
GtkTreeIter sel_iter;
/* Check if selected */
@ -378,8 +369,7 @@ move_action_up(GtkButton *button, gpointer user_data)
}
/* Called when Down button is clicked */
static void
move_action_down(GtkButton *button, gpointer user_data)
static void move_action_down(GtkButton *button, gpointer user_data)
{
GtkTreeIter sel_iter;
/* Check if selected */
@ -395,8 +385,7 @@ move_action_down(GtkButton *button, gpointer user_data)
}
/* Called when delete key is pressed */
static void
delete_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
static void delete_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
{
/* Check if DEL key was pressed (keyval: 65535) */
if (event->keyval == 65535)
@ -404,8 +393,7 @@ delete_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
}
/* Called when a cell is edited */
static void
edit_action(GtkCellRendererText *renderer, gchar *path,
static void edit_action(GtkCellRendererText *renderer, gchar *path,
gchar *new_text, gpointer cell)
{
GtkTreeIter sel_iter;
@ -420,8 +408,7 @@ edit_action(GtkCellRendererText *renderer, gchar *path,
/* exclude Functions */
/* Read ~/.clipit/excludes into the treeview */
static void
read_excludes()
static void read_excludes()
{
/* Open the file for reading */
gchar* path = g_build_filename(g_get_home_dir(), EXCLUDES_FILE, NULL);
@ -454,8 +441,7 @@ read_excludes()
}
/* Save the actions treeview to ~/.local/share/clipit/excludes */
static void
save_excludes()
static void save_excludes()
{
/* Check config and data directories */
check_dirs();
@ -503,8 +489,7 @@ save_excludes()
}
/* Called when Add... button is clicked */
static void
add_exclude(GtkButton *button, gpointer user_data)
static void add_exclude(GtkButton *button, gpointer user_data)
{
/* Append new item */
GtkTreeIter row_iter;
@ -520,8 +505,7 @@ add_exclude(GtkButton *button, gpointer user_data)
}
/* Called when Remove button is clicked */
static void
remove_exclude(GtkButton *button, gpointer user_data)
static void remove_exclude(GtkButton *button, gpointer user_data)
{
GtkTreeIter sel_iter;
/* Check if selected */
@ -542,8 +526,7 @@ remove_exclude(GtkButton *button, gpointer user_data)
}
/* Called when a cell is edited */
static void
edit_exclude(GtkCellRendererText *renderer, gchar *path,
static void edit_exclude(GtkCellRendererText *renderer, gchar *path,
gchar *new_text, gpointer cell)
{
GtkTreeIter sel_iter;
@ -556,8 +539,7 @@ edit_exclude(GtkCellRendererText *renderer, gchar *path,
}
/* Shows the preferences dialog on the given tab */
void
show_preferences(gint tab)
void show_preferences(gint tab)
{
/* Declare some variables */
GtkWidget *frame, *label,

View File

@ -56,11 +56,9 @@ G_BEGIN_DECLS
#define PREFERENCES_FILE ".config/clipit/clipitrc"
#define THEMES_FOLDER ".config/clipit/themes"
void
read_preferences();
void read_preferences();
void
show_preferences(gint tab);
void show_preferences(gint tab);
G_END_DECLS

View File

@ -68,8 +68,7 @@ is_hyperlink(gchar* text)
}
/* Returns TRUE if text should be excluded from history */
gboolean
is_excluded(gchar* text)
gboolean is_excluded(gchar *text)
{
/* Open the file for reading */
gchar *path = g_build_filename(g_get_home_dir(), EXCLUDES_FILE, NULL);
@ -106,11 +105,47 @@ is_excluded(gchar* text)
return FALSE;
}
/* Ellipsize a string according to the settings */
GString *ellipsize_string(GString *string)
{
if (string->len > prefs.item_length)
{
switch (prefs.ellipsize)
{
case PANGO_ELLIPSIZE_START:
string = g_string_erase(string, 0, string->len-(prefs.item_length));
string = g_string_prepend(string, "...");
break;
case PANGO_ELLIPSIZE_MIDDLE:
string = g_string_erase(string, (prefs.item_length/2), string->len-(prefs.item_length));
string = g_string_insert(string, (string->len/2), "...");
break;
case PANGO_ELLIPSIZE_END:
string = g_string_truncate(string, prefs.item_length);
string = g_string_append(string, "...");
break;
}
}
return string;
}
/* Remove newlines from string */
GString *remove_newlines_string(GString *string)
{
int i = 0;
while (i < string->len)
{
if (string->str[i] == '\n')
g_string_overwrite(string, i, " ");
i++;
}
return string;
}
/* Parses the program arguments. Returns TRUE if program needs
* to exit after parsing is complete
*/
gboolean
parse_options(int argc, char* argv[])
gboolean parse_options(int argc, char* argv[])
{
/* Declare argument options and argument variables */
gboolean icon = FALSE, daemon = FALSE,
@ -207,8 +242,6 @@ parse_options(int argc, char* argv[])
/* Check if anything was piped in */
if (piped_string->len > 0)
{
/* Truncate new line character */
/* g_string_truncate(piped_string, (piped_string->len - 1)); */
/* Copy to clipboard */
gtk_clipboard_set_text(clip, piped_string->str, -1);
gtk_clipboard_store(clip);

View File

@ -27,14 +27,15 @@ G_BEGIN_DECLS
#define CONFIG_DIR ".local/share/clipit"
#define DATA_DIR ".config/clipit"
void
check_dirs();
void check_dirs();
gboolean
is_hyperlink(gchar* link);
gboolean is_hyperlink(gchar* link);
gboolean
parse_options(int argc, char* argv[]);
GString *ellipsize_string(GString *string);
GString *remove_newlines_string(GString *string);
gboolean parse_options(int argc, char* argv[]);
G_END_DECLS