#include "defs.h"
#include <glib.h>
+#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
-#include "intl.h"
#include "prefs_gtk.h"
#include "inc.h"
#include "utils.h"
#include "prefs_actions.h"
#include "action.h"
#include "description_window.h"
+#include "gtkutils.h"
enum {
PREFS_ACTIONS_STRING, /*!< string pointer managed by list store,
GtkWidget *actions_list_view;
} actions;
+static int modified = FALSE;
+
/* widget creating functions */
static void prefs_actions_create (MainWindow *mainwin);
static void prefs_actions_set_dialog (void);
G_CALLBACK(prefs_actions_substitute_cb),
NULL);
- del_btn = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
+ del_btn = gtk_button_new_from_stock(GTK_STOCK_DELETE);
gtk_widget_show(del_btn);
gtk_box_pack_start(GTK_BOX(btn_hbox), del_btn, FALSE, TRUE, 0);
g_signal_connect(G_OBJECT(del_btn), "clicked",
debug_print("Reading actions configurations...\n");
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACTIONS_RC, NULL);
- if ((fp = fopen(rcpath, "rb")) == NULL) {
+ if ((fp = g_fopen(rcpath, "rb")) == NULL) {
if (ENOENT != errno) FILE_OP_ERROR(rcpath, "fopen");
g_free(rcpath);
return;
static void prefs_actions_set_list(void)
{
- gchar *action;
GtkTreeIter iter;
GtkListStore *store;
}
strncpy(action, entry_text, PREFSBUFSIZE - 1);
+
+ while (strstr(action, "//")) {
+ char *to_move = strstr(action, "//")+1;
+ char *where = strstr(action, "//");
+ int old_len = strlen(action);
+ memmove(where, to_move, strlen(to_move));
+ action[old_len-1] = '\0';
+ }
+
g_strstrip(action);
/* Keep space for the ': ' delimiter */
static void prefs_actions_register_cb(GtkWidget *w, gpointer data)
{
prefs_actions_clist_set_row(NULL);
+ modified = FALSE;
}
static void prefs_actions_substitute_cb(GtkWidget *w, gpointer data)
gtk_tree_path_free(path_sel);
gtk_tree_path_free(path_new);
+ modified = FALSE;
}
static void prefs_actions_delete_cb(GtkWidget *w, gpointer data)
{
GtkTreePath *prev, *sel, *try;
GtkTreeIter isel;
- GtkListStore *store;
+ GtkListStore *store = NULL;
GtkTreeIter iprev;
if (!gtk_tree_selection_get_selected
(gtk_tree_view_get_selection
(GTK_TREE_VIEW(actions.actions_list_view)),
- (GtkTreeModel **) &store,
+ (GtkTreeModel **)(GtkListStore *) store,
&isel))
return;
static void prefs_actions_down(GtkWidget *w, gpointer data)
{
- GtkListStore *store;
+ GtkListStore *store = NULL;
GtkTreeIter next, sel;
GtkTreePath *try;
if (!gtk_tree_selection_get_selected
(gtk_tree_view_get_selection
(GTK_TREE_VIEW(actions.actions_list_view)),
- (GtkTreeModel **) &store,
+ (GtkTreeModel **)(GtkListStore *) store,
&sel))
return;
{
if (event && event->keyval == GDK_Escape)
prefs_actions_cancel(widget, data);
+ else {
+ GtkWidget *focused = gtkut_get_focused_child(
+ GTK_CONTAINER(widget));
+ if (focused && GTK_IS_EDITABLE(focused)) {
+ modified = TRUE;
+ }
+ }
return FALSE;
}
static void prefs_actions_cancel(GtkWidget *w, gpointer data)
{
+ if (modified && alertpanel(_("Entry not saved"),
+ _("The entry was not saved. Close anyway?"),
+ GTK_STOCK_YES, GTK_STOCK_NO, NULL) != G_ALERTDEFAULT) {
+ return;
+ }
+ modified = FALSE;
prefs_actions_read_config();
gtk_widget_hide(actions.window);
inc_unlock();
MessageView *msgview;
Compose *compose;
+ if (modified && alertpanel(_("Entry not saved"),
+ _("The entry was not saved. Close anyway?"),
+ GTK_STOCK_YES, GTK_STOCK_NO, NULL) != G_ALERTDEFAULT) {
+ return;
+ }
+ modified = FALSE;
prefs_actions_write_config();
/* Update mainwindow actions menu */
list_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(model));
g_object_unref(model);
- gtk_tree_view_set_rules_hint(list_view, TRUE);
+ gtk_tree_view_set_rules_hint(list_view, prefs_common.enable_rules_hint);
selector = gtk_tree_view_get_selection(list_view);
gtk_tree_selection_set_mode(selector, GTK_SELECTION_BROWSE);
if (cmd && cmd[2])
ENTRY_SET_TEXT(actions.cmd_entry, &cmd[2]);
else
- return;
+ return TRUE;
*cmd = 0x00;
ENTRY_SET_TEXT(actions.name_entry, buf);