[Commits] prefs_actions.c 1.60.2.78 1.60.2.79 prefs_actions.h 1.5.2.8 1.5.2.9 prefs_toolbar.c 1.30.2.69 1.30.2.70 prefs_toolbar.h 1.5.2.12 1.5.2.13 toolbar.c 1.43.2.125 1.43.2.126 toolbar.h 1.19.2.33 1.19.2.34
pawel at claws-mail.org
pawel at claws-mail.org
Wed Feb 8 19:46:55 CET 2012
Update of /home/claws-mail/claws/src
In directory srv:/tmp/cvs-serv12356/src
Modified Files:
Tag: gtk2
prefs_actions.c prefs_actions.h prefs_toolbar.c
prefs_toolbar.h toolbar.c toolbar.h
Log Message:
2012-02-08 [pawel] 3.8.0cvs27
* src/prefs_actions.c
* src/prefs_actions.h
* src/prefs_toolbar.c
* src/prefs_toolbar.h
* src/toolbar.c
* src/toolbar.h
- Implement automatic removal of toolbar action buttons when
associated action is removed
- Don't allow creation of two actions with the same name,
before all executions/removals were performed on first action
with duplicated name in linked list which wasn't always
correct behaviour
Index: toolbar.c
===================================================================
RCS file: /home/claws-mail/claws/src/toolbar.c,v
retrieving revision 1.43.2.125
retrieving revision 1.43.2.126
diff -u -d -r1.43.2.125 -r1.43.2.126
--- toolbar.c 10 Jan 2012 08:20:30 -0000 1.43.2.125
+++ toolbar.c 8 Feb 2012 18:46:53 -0000 1.43.2.126
@@ -812,40 +812,52 @@
gpointer data,
gint source)
{
- GSList *cur, *lop;
- gchar *action, *action_p;
- gboolean found = FALSE;
+ GSList *cur;
gint i = 0;
for (cur = action_list; cur != NULL; cur = cur->next) {
ToolbarClawsActions *act = (ToolbarClawsActions*)cur->data;
if (widget == act->widget) {
-
- for (lop = prefs_common.actions_list; lop != NULL; lop = lop->next) {
- action = g_strdup((gchar*)lop->data);
+ i = prefs_actions_find_by_name(act->name);
- action_p = strstr(action, ": ");
- action_p[0] = 0x00;
- if (g_utf8_collate(act->name, action) == 0) {
- found = TRUE;
- g_free(action);
- break;
- } else
- i++;
- g_free(action);
- }
- if (found)
+ if (i != -1)
break;
}
}
- if (found)
+ if (i != -1)
actions_execute(data, i, widget, source);
else
g_warning ("Error: did not find Claws Action to execute");
}
+gboolean toolbar_check_action_btns(ToolbarType type)
+{
+ GSList *temp, *curr, *list = toolbar_config[type].item_list;
+ gboolean modified = FALSE;
+
+ curr = list;
+ while (curr != NULL) {
+ ToolbarItem *toolbar_item = (ToolbarItem *) curr->data;
+ temp = curr;
+ curr = curr->next;
+
+ if (toolbar_item->index != A_CLAWS_ACTIONS)
+ continue;
+
+ if (prefs_actions_find_by_name(toolbar_item->text) == -1) {
+ list = g_slist_delete_link(list, temp);
+ g_free(toolbar_item->file);
+ g_free(toolbar_item->text);
+ g_free(toolbar_item);
+ modified = TRUE;
+ }
+ }
+
+ return modified;
+}
+
#if !(GTK_CHECK_VERSION(2,12,0))
#define CLAWS_SET_TOOL_ITEM_TIP(widget,tip) { \
gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(widget), GTK_TOOLTIPS(toolbar_tips), \
Index: toolbar.h
===================================================================
RCS file: /home/claws-mail/claws/src/toolbar.h,v
retrieving revision 1.19.2.33
retrieving revision 1.19.2.34
diff -u -d -r1.19.2.33 -r1.19.2.34
--- toolbar.h 16 Feb 2011 07:16:17 -0000 1.19.2.33
+++ toolbar.h 8 Feb 2012 18:46:53 -0000 1.19.2.34
@@ -264,4 +264,5 @@
LearnButtonType learn_btn_type);
const gchar *toolbar_get_short_text (int action);
int toolbar_get_icon (int action);
+gboolean toolbar_check_action_btns (ToolbarType type);
#endif /* __CUSTOM_TOOLBAR_H__ */
Index: prefs_actions.h
===================================================================
RCS file: /home/claws-mail/claws/src/prefs_actions.h,v
retrieving revision 1.5.2.8
retrieving revision 1.5.2.9
diff -u -d -r1.5.2.8 -r1.5.2.9
--- prefs_actions.h 24 Nov 2011 16:50:11 -0000 1.5.2.8
+++ prefs_actions.h 8 Feb 2012 18:46:53 -0000 1.5.2.9
@@ -27,5 +27,6 @@
void prefs_actions_open (MainWindow *mainwin);
void prefs_actions_rename_path (const gchar *old_path,
const gchar *new_path);
+gint prefs_actions_find_by_name (const gchar *name);
#endif /* __PREFS_ACTIONS_H__ */
Index: prefs_toolbar.c
===================================================================
RCS file: /home/claws-mail/claws/src/prefs_toolbar.c,v
retrieving revision 1.30.2.69
retrieving revision 1.30.2.70
diff -u -d -r1.30.2.69 -r1.30.2.70
--- prefs_toolbar.c 7 Oct 2011 09:17:50 -0000 1.30.2.69
+++ prefs_toolbar.c 8 Feb 2012 18:46:53 -0000 1.30.2.70
@@ -41,6 +41,7 @@
#include "mainwindow.h"
#include "alertpanel.h"
#include "prefs_common.h"
+#include "prefs_actions.h"
#include "utils.h"
@@ -291,7 +292,6 @@
item->index = toolbar_ret_val_from_descr(event);
g_free(event);
- /* TODO: save A_CLAWS_ACTIONS only if they are still active */
toolbar_set_list_item(item, prefs_toolbar->source);
g_free(item->file);
@@ -1266,6 +1266,24 @@
g_free(prefs_toolbar_messageview);
}
+void prefs_toolbar_update_action_btns(void)
+{
+ if (toolbar_check_action_btns(TOOLBAR_MAIN)) {
+ toolbar_save_config_file(TOOLBAR_MAIN);
+ toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
+ }
+
+ if (toolbar_check_action_btns(TOOLBAR_COMPOSE)) {
+ toolbar_save_config_file(TOOLBAR_COMPOSE);
+ compose_reflect_prefs_pixmap_theme();
+ }
+
+ if (toolbar_check_action_btns(TOOLBAR_MSGVIEW)) {
+ toolbar_save_config_file(TOOLBAR_MSGVIEW);
+ messageview_reflect_prefs_pixmap_theme();
+ }
+}
+
static void set_visible_if_not_text(GtkTreeViewColumn *col,
GtkCellRenderer *renderer,
GtkTreeModel *model,
Index: prefs_actions.c
===================================================================
RCS file: /home/claws-mail/claws/src/prefs_actions.c,v
retrieving revision 1.60.2.78
retrieving revision 1.60.2.79
diff -u -d -r1.60.2.78 -r1.60.2.79
--- prefs_actions.c 24 Nov 2011 16:50:11 -0000 1.60.2.78
+++ prefs_actions.c 8 Feb 2012 18:46:53 -0000 1.60.2.79
@@ -49,6 +49,7 @@
#include "filtering.h"
#include "prefs_filtering_action.h"
#include "matcher_parser.h"
+#include "prefs_toolbar.h"
enum {
PREFS_ACTIONS_STRING, /*!< string pointer managed by list store,
@@ -585,7 +586,7 @@
static gint prefs_actions_clist_set_row(gint row)
{
const gchar *entry_text;
- gint len;
+ gint len, action_nb;
gchar action[PREFSBUFSIZE];
gchar *new_action;
GtkListStore *store;
@@ -609,6 +610,12 @@
return -1;
}
+ action_nb = prefs_actions_find_by_name(entry_text);
+ if ((action_nb != -1) && ((row == -1) || (row != action_nb + 1))) {
+ alertpanel_error(_("There is action with this name already."));
+ return -1;
+ }
+
strncpy(action, entry_text, PREFSBUFSIZE - 1);
while (strstr(action, "//")) {
@@ -949,6 +956,9 @@
compose_update_actions_menu(compose);
}
+ /* Update toolbars */
+ prefs_toolbar_update_action_btns();
+
gtk_widget_hide(actions.window);
gtk_window_set_modal(GTK_WINDOW(actions.window), FALSE);
inc_unlock();
@@ -1364,3 +1374,26 @@
g_strfreev(tokens);
}
}
+
+gint prefs_actions_find_by_name(const gchar *name)
+{
+ GSList *act = prefs_common.actions_list;
+ gchar *action_name, *action_p;
+ gint action_nb = 0;
+
+ for (; act != NULL; act = act->next) {
+ action_name = g_strdup((gchar *)act->data);
+ action_p = strstr(action_name, ": ");
+ action_p[0] = 0x00;
+
+ if (g_utf8_collate(name, action_name) == 0) {
+ g_free(action_name);
+ return action_nb;
+ }
+
+ g_free(action_name);
+ action_nb++;
+ }
+
+ return -1;
+}
Index: prefs_toolbar.h
===================================================================
RCS file: /home/claws-mail/claws/src/prefs_toolbar.h,v
retrieving revision 1.5.2.12
retrieving revision 1.5.2.13
diff -u -d -r1.5.2.12 -r1.5.2.13
--- prefs_toolbar.h 16 Feb 2011 07:16:14 -0000 1.5.2.12
+++ prefs_toolbar.h 8 Feb 2012 18:46:53 -0000 1.5.2.13
@@ -31,5 +31,6 @@
void prefs_toolbar_register_plugin_item(ToolbarType toolbar_type, const gchar *plugin_name, const gchar *item_name, ToolbarPluginCallback cb, gpointer cb_data);
void prefs_toolbar_unregister_plugin_item(ToolbarType toolbar_type, const gchar *plugin_name, const gchar *item_name);
void prefs_toolbar_execute_plugin_item(gpointer parent, ToolbarType toolbar_type, const gchar *id);
+void prefs_toolbar_update_action_btns(void);
#endif /* __PREFS_CUSTOM_TOOLBAR_H__ */
More information about the Commits
mailing list