wmail: fixed config typo.
[dockapps.git] / wmcliphist / wmcliphist.h
blob6562cd4c6047185758081808e43b7b4167ff6a0b
1 #ifndef _WMCLIPHIST_H_
2 #define _WMCLIPHIST_H_
5 #define _GNU_SOURCE
7 #include <signal.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <unistd.h>
12 #include <ctype.h>
13 #include <errno.h>
14 #include <sys/stat.h>
16 #include <fcntl.h>
17 #include <regex.h>
19 #include <gtk/gtk.h>
20 #include <gdk/gdk.h>
21 #include <gdk/gdkx.h>
23 #include "debug.h"
26 #define VERSION 0x0003
27 #define DEF_LOCKED_COLOR "red"
28 #define DEF_MENUKEY "Control+Alt+V"
29 #define DEF_PREV_ITEM_KEY "Control+Alt+C"
30 #define DEF_EXEC_ITEM_KEY "Control+Alt+E"
31 #define DEF_CLIPBOARD_STR "PRIMARY"
32 #define DEF_CLIPBOARD GDK_SELECTION_PRIMARY
33 #define MAX_ITEM_LENGTH 40
36 /* ==========================================================================
37 * CLIPBOARD FUNCTIONS
40 /* history item */
41 typedef struct {
42 GtkWidget *menu_item;
43 gint locked;
44 gchar *content;
45 GtkWidget *menu;
46 } HISTORY_ITEM;
49 /* number of items to keep (may be overriden from command line) */
50 extern gint num_items_to_keep;
52 /* when true, clipboard will be automatically taken up by wmcliphist */
53 extern gint auto_take_up;
55 /* number of items kept */
56 extern gint num_items;
58 /* list of clipboard history items */
59 extern GList *history_items;
61 /* selected item */
62 extern HISTORY_ITEM *selected;
64 /* current number of locked items */
65 extern gint locked_count;
68 /* which clipboard to use */
69 extern gchar clipboard_str[32];
70 extern GdkAtom clipboard;
72 #ifdef DEBUG
73 #define dump_history_list(header) dump_history_list_fn(header)
74 #else
75 #define dump_history_list(header)
76 #endif
80 * get clipboard content - partialy inspired by Downloader for X
82 gboolean
83 my_get_xselection(GtkWidget *window, GdkEvent *event);
86 * clipboard conversion - inspired by Downloader for X too :)
88 gboolean
89 time_conv_select();
92 * handles request for selection from other apps
94 gint
95 selection_handle(GtkWidget *widget,
96 GtkSelectionData *selection_data,
97 guint info,
98 guint time_stamp,
99 gpointer data);
102 /* ==========================================================================
103 * RC CONFIG
106 /* action record */
107 typedef struct {
108 regex_t expression;
109 enum {
110 ACT_EXEC,
111 ACT_SUBMENU,
112 ACT_IGNORE
113 } action;
114 char *command;
115 GtkWidget *menu_item;
116 GtkWidget *submenu;
117 } ACTION;
120 extern GList *action_list;
124 * returns config/data file name in user's home
126 char *
127 rcconfig_get_name(char *append);
130 * read and parse rcconfig
133 rcconfig_get(char *fname);
136 * free rcconfig data
138 void
139 rcconfig_free();
143 /* ==========================================================================
144 * GUI
147 /* error codes */
148 #define E_BASE 10000
149 #define E_OPEN (E_BASE | 1)
150 #define E_INVALID (E_BASE | 2)
151 #define E_REMOVE (E_BASE | 3)
152 #define E_TOO_MUCH (E_BASE | 4)
153 #define E_WRITE (E_BASE | 5)
154 #define E_RENAME (E_BASE | 6)
158 * process new history item
160 void
161 process_item(char *content, gint locked, gboolean exec);
165 /* ==========================================================================
166 * HISTORY FUNCTIONS
170 * autosave period
172 extern int autosave_period;
175 * confirm actions?
177 extern int confirm_exec;
180 * Exec immediately when item is captured?
182 extern int exec_immediately;
185 * move supplied item to begin
187 void
188 move_item_to_begin(HISTORY_ITEM *item);
191 * Execute an item.
193 void
194 exec_item(char *content, ACTION *action);
197 * loads history from file
200 history_load(gboolean dump_only);
203 * store history to file
206 history_save();
209 * free history data
211 void
212 history_free();
215 * autosave timer function
217 gboolean
218 history_autosave();
221 /* ==========================================================================
222 * HOTKEYS
225 /* hotkeys */
226 extern gchar menukey_str[32];
227 extern guint menukey;
228 extern gchar prev_item_key_str[32];
229 extern gchar exec_item_key_str[32];
232 * Exec on hotkey?
234 extern int exec_hotkey;
237 * initialize hotkeys
239 void
240 hotkeys_init();
243 * disable hotkeys
245 void
246 hotkeys_done();
250 /* ==========================================================================
251 * GUI
254 /* color of locked item */
255 extern gchar locked_color_str[32];
256 extern GdkRGBA locked_color;
257 extern gint submenu_count;
260 * Exec on middle click?
262 extern int exec_middleclick;
264 /* main window widget */
265 extern GtkWidget *main_window;
267 /* dock icon widget */
268 extern GtkWidget *dock_app;
270 /* clipboard history menu */
271 extern GtkWidget *menu_hist;
272 extern GtkWidget *menu_title;
274 /* application menu */
275 extern GtkWidget *menu_app;
276 extern GtkWidget *menu_app_clip_ignore;
277 extern GtkWidget *menu_app_clip_lock;
278 extern GtkWidget *menu_app_exit;
279 extern GtkWidget *menu_app_save;
281 /* button */
282 extern GtkWidget *button;
284 /* event */
285 extern GtkWidget *event;
287 /* pixmap */
288 extern GtkWidget *pixmap;
291 * dock button click response
293 gboolean
294 button_press(GtkWidget *widget, GdkEvent *event, gpointer data);
297 * checks, if there is already such item in menu,
298 * in which case it moves it to the begining
300 HISTORY_ITEM *
301 menu_item_exists(gchar *content, GtkWidget *submenu);
304 * add new item to menu
306 HISTORY_ITEM *
307 menu_item_add(gchar *content, gint locked, GtkWidget *target_menu);
311 * application main menu handler
313 gboolean
314 menu_app_item_click(GtkWidget *menuitem, gpointer data);
318 * open dialog with specified message andbuttons
319 * and return number of button pressed
321 gint
322 show_message(gchar *message, char *title,
323 char *b1_text, char *b2_text, char *b3_text);
327 /* ==========================================================================
328 * UTILITIES
330 gchar *
331 from_utf8(gchar *string);
333 #endif