+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
+
2012-02-05 [colin] 3.8.0cvs26
* src/main.c
( cvs diff -u -r 1.1.4.29 -r 1.1.4.30 src/gtk/progressdialog.c; ) > 3.8.0cvs24.patchset
( cvs diff -u -r 1.49.2.140 -r 1.49.2.141 src/procmime.c; ) > 3.8.0cvs25.patchset
( cvs diff -u -r 1.115.2.246 -r 1.115.2.247 src/main.c; cvs diff -u -r 1.274.2.342 -r 1.274.2.343 src/mainwindow.c; cvs diff -u -r 1.94.2.226 -r 1.94.2.227 src/messageview.c; cvs diff -u -r 1.19.2.27 -r 1.19.2.28 src/messageview.h; cvs diff -u -r 1.204.2.207 -r 1.204.2.208 src/prefs_common.c; cvs diff -u -r 1.103.2.136 -r 1.103.2.137 src/prefs_common.h; cvs diff -u -r 1.150.2.121 -r 1.150.2.122 src/procmsg.c; cvs diff -u -r 1.60.2.58 -r 1.60.2.59 src/procmsg.h; cvs diff -u -r 1.395.2.443 -r 1.395.2.444 src/summaryview.c; cvs diff -u -r 1.68.2.58 -r 1.68.2.59 src/summaryview.h; ) > 3.8.0cvs26.patchset
+( cvs diff -u -r 1.60.2.78 -r 1.60.2.79 src/prefs_actions.c; cvs diff -u -r 1.5.2.8 -r 1.5.2.9 src/prefs_actions.h; cvs diff -u -r 1.30.2.69 -r 1.30.2.70 src/prefs_toolbar.c; cvs diff -u -r 1.5.2.12 -r 1.5.2.13 src/prefs_toolbar.h; cvs diff -u -r 1.43.2.125 -r 1.43.2.126 src/toolbar.c; cvs diff -u -r 1.19.2.33 -r 1.19.2.34 src/toolbar.h; ) > 3.8.0cvs27.patchset
MICRO_VERSION=0
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=26
+EXTRA_VERSION=27
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
#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,
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;
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, "//")) {
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();
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;
+}
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__ */
#include "mainwindow.h"
#include "alertpanel.h"
#include "prefs_common.h"
+#include "prefs_actions.h"
#include "utils.h"
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);
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,
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__ */
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);
-
- 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)
+ i = prefs_actions_find_by_name(act->name);
+
+ 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), \
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__ */