2002-08-06 16:06:40 +02:00
|
|
|
/*
|
|
|
|
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
|
2015-02-19 01:19:01 +01:00
|
|
|
* Copyright (C) 2002-2015 Hiroyuki Yamamoto & the Claws Mail team
|
2002-08-06 16:06:40 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-07-11 18:38:12 +02:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2002-08-06 16:06:40 +02:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2007-07-11 18:38:12 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2015-02-19 01:19:01 +01:00
|
|
|
*
|
2002-08-06 16:06:40 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* General functions for accessing address book files.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
2012-07-07 09:09:39 +02:00
|
|
|
#include "claws-features.h"
|
2002-08-06 16:06:40 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
|
|
|
#include <glib.h>
|
2005-02-10 13:06:07 +01:00
|
|
|
#include <glib/gi18n.h>
|
2002-08-06 16:06:40 +02:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "stock_pixmap.h"
|
|
|
|
#include "manage_window.h"
|
2007-10-17 16:43:24 +02:00
|
|
|
#include "combobox.h"
|
2002-08-06 16:06:40 +02:00
|
|
|
#include "gtkutils.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "alertpanel.h"
|
|
|
|
#include "prefs_common.h"
|
2012-02-08 19:46:54 +01:00
|
|
|
#include "prefs_actions.h"
|
2002-08-06 16:06:40 +02:00
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
#include "toolbar.h"
|
|
|
|
#include "prefs_toolbar.h"
|
2003-01-12 02:01:26 +01:00
|
|
|
#include "prefswindow.h"
|
|
|
|
#include "prefs_gtk.h"
|
2009-11-17 16:15:15 +01:00
|
|
|
#include "plugin.h"
|
2012-09-08 22:23:12 +02:00
|
|
|
#include "messageview.h"
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
enum
|
2002-08-10 20:54:27 +02:00
|
|
|
{
|
2005-01-16 19:18:27 +01:00
|
|
|
SET_ICON = 0,
|
|
|
|
SET_FILENAME = 1,
|
|
|
|
SET_TEXT = 2,
|
|
|
|
SET_EVENT = 3,
|
2015-02-19 01:19:01 +01:00
|
|
|
SET_ICON_TEXT = 4, /*!< "icon" text (separator) */
|
2005-01-16 19:18:27 +01:00
|
|
|
SET_ICON_IS_TEXT = 5, /*!< icon is text representation */
|
|
|
|
N_SET_COLUMNS
|
|
|
|
};
|
2002-08-10 20:54:27 +02:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
ITEM_FUNCTION = 0,
|
|
|
|
ITEM_USER_ACTION = 1,
|
2011-02-10 19:36:30 +01:00
|
|
|
ITEM_PLUGIN = 2,
|
|
|
|
ITEM_SEPARATOR = 3,
|
2007-10-06 19:34:01 +02:00
|
|
|
};
|
|
|
|
|
2007-10-07 19:32:13 +02:00
|
|
|
static const gint ToolbarIcons[] =
|
|
|
|
{
|
|
|
|
STOCK_PIXMAP_ADDRESS_BOOK,
|
|
|
|
STOCK_PIXMAP_ADDRESS_SEARCH,
|
|
|
|
STOCK_PIXMAP_BOOK,
|
|
|
|
STOCK_PIXMAP_CATEGORY,
|
|
|
|
STOCK_PIXMAP_CHECK_SPELLING,
|
|
|
|
STOCK_PIXMAP_CLOSE,
|
|
|
|
STOCK_PIXMAP_DOWN_ARROW,
|
|
|
|
STOCK_PIXMAP_UP_ARROW,
|
|
|
|
STOCK_PIXMAP_EDIT_EXTERN,
|
|
|
|
STOCK_PIXMAP_ERROR,
|
|
|
|
STOCK_PIXMAP_EXEC,
|
|
|
|
STOCK_PIXMAP_GROUP,
|
|
|
|
STOCK_PIXMAP_INSERT_FILE,
|
|
|
|
STOCK_PIXMAP_INTERFACE,
|
|
|
|
STOCK_PIXMAP_JPILOT,
|
|
|
|
STOCK_PIXMAP_LDAP,
|
|
|
|
STOCK_PIXMAP_LINEWRAP_CURRENT,
|
|
|
|
STOCK_PIXMAP_LINEWRAP_ALL,
|
|
|
|
STOCK_PIXMAP_MAIL,
|
|
|
|
STOCK_PIXMAP_MAIL_ATTACH,
|
|
|
|
STOCK_PIXMAP_MAIL_COMPOSE,
|
|
|
|
STOCK_PIXMAP_MAIL_FORWARD,
|
|
|
|
STOCK_PIXMAP_MAIL_RECEIVE,
|
|
|
|
STOCK_PIXMAP_MAIL_RECEIVE_ALL,
|
|
|
|
STOCK_PIXMAP_MAIL_REPLY,
|
|
|
|
STOCK_PIXMAP_MAIL_REPLY_TO_ALL,
|
|
|
|
STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR,
|
2008-05-22 08:58:47 +02:00
|
|
|
STOCK_PIXMAP_MAIL_REPLY_TO_LIST,
|
2007-10-07 19:32:13 +02:00
|
|
|
STOCK_PIXMAP_MAIL_SEND,
|
|
|
|
STOCK_PIXMAP_MAIL_SEND_QUEUE,
|
|
|
|
STOCK_PIXMAP_MAIL_SIGN,
|
|
|
|
STOCK_PIXMAP_OPEN_MAIL,
|
|
|
|
STOCK_PIXMAP_NEWS_COMPOSE,
|
|
|
|
STOCK_PIXMAP_PASTE,
|
|
|
|
STOCK_PIXMAP_PREFERENCES,
|
|
|
|
STOCK_PIXMAP_PROPERTIES,
|
|
|
|
STOCK_PIXMAP_VCARD,
|
|
|
|
STOCK_PIXMAP_ONLINE,
|
|
|
|
STOCK_PIXMAP_OFFLINE,
|
|
|
|
STOCK_PIXMAP_NOTICE_WARN, /* small warning */
|
|
|
|
STOCK_PIXMAP_NOTICE_ERROR, /* small error */
|
|
|
|
STOCK_PIXMAP_NOTICE_NOTE, /* small message */
|
|
|
|
STOCK_PIXMAP_GO_FOLDERS,
|
|
|
|
STOCK_PIXMAP_MIME_TEXT_PLAIN,
|
|
|
|
STOCK_PIXMAP_MIME_TEXT_HTML,
|
2008-02-10 12:54:44 +01:00
|
|
|
STOCK_PIXMAP_MIME_TEXT_PATCH,
|
2007-10-07 19:32:13 +02:00
|
|
|
STOCK_PIXMAP_MIME_APPLICATION,
|
|
|
|
STOCK_PIXMAP_MIME_IMAGE,
|
|
|
|
STOCK_PIXMAP_MIME_AUDIO,
|
|
|
|
STOCK_PIXMAP_MIME_TEXT_ENRICHED,
|
|
|
|
STOCK_PIXMAP_MIME_UNKNOWN,
|
|
|
|
STOCK_PIXMAP_MIME_PDF,
|
|
|
|
STOCK_PIXMAP_MIME_PS,
|
|
|
|
STOCK_PIXMAP_MIME_TEXT_CALENDAR,
|
|
|
|
STOCK_PIXMAP_MIME_PGP_SIG,
|
|
|
|
STOCK_PIXMAP_PRINTER,
|
|
|
|
STOCK_PIXMAP_PRIVACY_SIGNED,
|
|
|
|
STOCK_PIXMAP_PRIVACY_PASSED,
|
|
|
|
STOCK_PIXMAP_PRIVACY_FAILED,
|
|
|
|
STOCK_PIXMAP_PRIVACY_UNKNOWN,
|
|
|
|
STOCK_PIXMAP_PRIVACY_EXPIRED,
|
|
|
|
STOCK_PIXMAP_PRIVACY_WARN,
|
|
|
|
STOCK_PIXMAP_PRIVACY_EMBLEM_SIGNED,
|
|
|
|
STOCK_PIXMAP_PRIVACY_EMBLEM_PASSED,
|
|
|
|
STOCK_PIXMAP_PRIVACY_EMBLEM_FAILED,
|
|
|
|
STOCK_PIXMAP_PRIVACY_EMBLEM_WARN,
|
|
|
|
STOCK_PIXMAP_MIME_MESSAGE,
|
|
|
|
STOCK_PIXMAP_SPAM_BTN,
|
|
|
|
STOCK_PIXMAP_HAM_BTN,
|
2008-04-30 22:57:52 +02:00
|
|
|
STOCK_PIXMAP_TRASH,
|
2008-05-22 08:58:47 +02:00
|
|
|
STOCK_PIXMAP_DELETE,
|
2008-07-07 19:44:20 +02:00
|
|
|
STOCK_PIXMAP_CANCEL,
|
2007-10-07 19:32:13 +02:00
|
|
|
STOCK_PIXMAP_EMPTY, /* last entry */
|
|
|
|
};
|
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
typedef struct _ToolbarPage
|
|
|
|
{
|
|
|
|
PrefsPage page;
|
|
|
|
|
|
|
|
GtkWidget *window; /* do not modify */
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2002-11-28 23:36:14 +01:00
|
|
|
ToolbarType source;
|
2007-10-06 19:34:01 +02:00
|
|
|
GList *combo_action_list; /* list of internal functions */
|
|
|
|
|
|
|
|
GtkWidget *list_view_set; /* toolbar items treeview */
|
|
|
|
GtkWidget *item_text_entry; /* item name */
|
|
|
|
GtkWidget *item_type_combo; /* item type selection widget */
|
|
|
|
GtkWidget *item_func_combo; /* item internal function widget */
|
|
|
|
GtkWidget *item_action_combo; /* item user action widget */
|
2009-11-17 16:15:15 +01:00
|
|
|
GtkWidget *item_plugin_combo; /* items registered by plugins */
|
2007-10-06 19:34:01 +02:00
|
|
|
GtkWidget *icon_button; /* item icon chooser widget */
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
GtkWidget *icon_chooser_win;
|
2007-10-08 20:39:29 +02:00
|
|
|
GtkWidget *icon_chooser_view;
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
gchar *item_icon_file; /* item icon file */
|
2002-09-22 16:37:58 +02:00
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
} ToolbarPage;
|
2002-08-06 16:06:40 +02:00
|
|
|
|
|
|
|
#define ERROR_MSG _("Selected Action already set.\nPlease choose another Action from List")
|
2007-10-06 19:34:01 +02:00
|
|
|
#define ERROR_MSG_NO_ICON _("Item has no icon defined.")
|
|
|
|
#define ERROR_MSG_NO_TEXT _("Item has no text defined.")
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2009-11-17 16:15:15 +01:00
|
|
|
typedef struct _ToolbarPluginItem ToolbarPluginItem;
|
|
|
|
struct _ToolbarPluginItem {
|
|
|
|
gchar *plugin;
|
|
|
|
gchar *item_name;
|
|
|
|
ToolbarPluginCallback cb;
|
|
|
|
gpointer cb_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* items registered by plugins */
|
2009-12-19 23:50:46 +01:00
|
|
|
static GHashTable *plugin_items_mainwin = NULL;
|
|
|
|
static GHashTable *plugin_items_compose = NULL;
|
|
|
|
static GHashTable *plugin_items_msgview = NULL;
|
2009-11-17 16:15:15 +01:00
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
static void prefs_toolbar_populate (ToolbarPage *prefs_toolbar);
|
2007-10-06 19:34:01 +02:00
|
|
|
|
2015-02-19 01:19:01 +01:00
|
|
|
static void get_action_name (const gchar *entry,
|
2007-10-06 19:34:01 +02:00
|
|
|
gchar **menu);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
static gboolean is_duplicate (ToolbarPage *prefs_toolbar,
|
|
|
|
gchar *chosen_action);
|
|
|
|
static void prefs_toolbar_save (PrefsPage *_page);
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
static void prefs_toolbar_register (GtkButton *button,
|
|
|
|
ToolbarPage *prefs_toolbar);
|
|
|
|
static void prefs_toolbar_substitute (GtkButton *button,
|
|
|
|
ToolbarPage *prefs_toolbar);
|
|
|
|
static void prefs_toolbar_delete (GtkButton *button,
|
|
|
|
ToolbarPage *prefs_toolbar);
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
static void prefs_toolbar_up (GtkButton *button,
|
|
|
|
ToolbarPage *prefs_toolbar);
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
static void prefs_toolbar_down (GtkButton *button,
|
|
|
|
ToolbarPage *prefs_toolbar);
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2007-10-06 23:14:37 +02:00
|
|
|
static void action_selection_changed (GtkComboBox *action_combo,
|
|
|
|
ToolbarPage *prefs_toolbar);
|
2011-02-10 19:36:30 +01:00
|
|
|
static void plugin_selection_changed (GtkComboBox *action_combo,
|
|
|
|
ToolbarPage *prefs_toolbar);
|
2007-10-06 23:14:37 +02:00
|
|
|
|
|
|
|
static void func_selection_changed (GtkComboBox *action_combo,
|
|
|
|
ToolbarPage *prefs_toolbar);
|
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
static void prefs_toolbar_create (ToolbarPage *prefs_toolbar);
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
static GtkWidget *create_set_list_view (ToolbarPage *prefs_toolbar);
|
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
static gboolean set_list_selected (GtkTreeSelection *selector,
|
2015-02-19 01:19:01 +01:00
|
|
|
GtkTreeModel *model,
|
2005-01-16 19:18:27 +01:00
|
|
|
GtkTreePath *path,
|
|
|
|
gboolean currently_selected,
|
|
|
|
ToolbarPage *prefs_toolbar);
|
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
static void icon_chooser_create (GtkButton *button,
|
2003-01-12 02:01:26 +01:00
|
|
|
ToolbarPage *prefs_toolbar);
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2009-12-19 23:50:46 +01:00
|
|
|
|
|
|
|
static GHashTable** get_plugin_hash_from_toolbar_type(ToolbarType toolbar_type)
|
|
|
|
{
|
2011-02-10 19:36:30 +01:00
|
|
|
if (toolbar_type == TOOLBAR_MAIN)
|
|
|
|
return &plugin_items_mainwin;
|
|
|
|
else if (toolbar_type == TOOLBAR_COMPOSE)
|
|
|
|
return &plugin_items_compose;
|
|
|
|
else if (toolbar_type == TOOLBAR_MSGVIEW)
|
|
|
|
return &plugin_items_msgview;
|
|
|
|
else
|
|
|
|
return NULL;
|
2009-12-19 23:50:46 +01:00
|
|
|
}
|
|
|
|
|
2007-01-20 20:54:05 +01:00
|
|
|
static void prefs_toolbar_create_widget(PrefsPage *_page, GtkWindow *window, gpointer data)
|
2002-08-06 16:06:40 +02:00
|
|
|
{
|
2003-01-12 02:01:26 +01:00
|
|
|
ToolbarPage *prefs_toolbar = (ToolbarPage *) _page;
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
prefs_toolbar->window = GTK_WIDGET(window);
|
2002-09-22 16:37:58 +02:00
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
toolbar_read_config_file(prefs_toolbar->source);
|
2002-09-22 16:37:58 +02:00
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
prefs_toolbar_create(prefs_toolbar);
|
|
|
|
prefs_toolbar_populate(prefs_toolbar);
|
2002-08-06 16:06:40 +02:00
|
|
|
}
|
|
|
|
|
2007-01-20 20:54:05 +01:00
|
|
|
static void prefs_toolbar_save(PrefsPage *_page)
|
2002-08-06 16:06:40 +02:00
|
|
|
{
|
2003-01-12 02:01:26 +01:00
|
|
|
ToolbarPage *prefs_toolbar = (ToolbarPage *) _page;
|
2005-01-16 19:18:27 +01:00
|
|
|
GtkTreeView *list_view = GTK_TREE_VIEW(prefs_toolbar->list_view_set);
|
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(list_view);
|
|
|
|
GtkTreeIter iter;
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
toolbar_clear_list(prefs_toolbar->source);
|
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
if (!gtk_tree_model_iter_n_children(model, NULL)
|
|
|
|
|| !gtk_tree_model_get_iter_first(model, &iter))
|
2003-01-12 02:01:26 +01:00
|
|
|
toolbar_set_default(prefs_toolbar->source);
|
|
|
|
else {
|
|
|
|
do {
|
2005-01-16 19:18:27 +01:00
|
|
|
ToolbarItem *item;
|
2015-02-19 01:19:01 +01:00
|
|
|
gchar *fname, *text, *event;
|
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
item = g_new0(ToolbarItem, 1);
|
|
|
|
|
|
|
|
gtk_tree_model_get(model, &iter,
|
|
|
|
SET_FILENAME, &fname,
|
|
|
|
SET_TEXT, &text,
|
|
|
|
SET_EVENT, &event,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
/* XXX: remember that G_TYPE_STRING returned by model
|
|
|
|
* is owned by caller of gtk_tree_model_get() */
|
|
|
|
item->file = fname;
|
|
|
|
item->text = text;
|
|
|
|
item->index = toolbar_ret_val_from_descr(event);
|
|
|
|
g_free(event);
|
2003-01-12 02:01:26 +01:00
|
|
|
|
|
|
|
toolbar_set_list_item(item, prefs_toolbar->source);
|
|
|
|
|
|
|
|
g_free(item->file);
|
|
|
|
g_free(item->text);
|
|
|
|
g_free(item);
|
2005-01-16 19:18:27 +01:00
|
|
|
} while (gtk_tree_model_iter_next(model, &iter));
|
2003-01-12 02:01:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
toolbar_save_config_file(prefs_toolbar->source);
|
|
|
|
|
2015-02-19 01:19:01 +01:00
|
|
|
if (prefs_toolbar->source == TOOLBAR_MAIN)
|
2009-09-07 21:43:07 +02:00
|
|
|
toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
|
2003-01-12 02:01:26 +01:00
|
|
|
else if (prefs_toolbar->source == TOOLBAR_COMPOSE)
|
2002-09-22 16:37:58 +02:00
|
|
|
compose_reflect_prefs_pixmap_theme();
|
2003-01-12 02:01:26 +01:00
|
|
|
else if (prefs_toolbar->source == TOOLBAR_MSGVIEW)
|
2002-12-24 15:29:16 +01:00
|
|
|
messageview_reflect_prefs_pixmap_theme();
|
2002-08-06 16:06:40 +02:00
|
|
|
}
|
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
static void prefs_toolbar_destroy_widget(PrefsPage *_page)
|
|
|
|
{
|
|
|
|
ToolbarPage *prefs_toolbar = (ToolbarPage *) _page;
|
|
|
|
|
|
|
|
g_list_free(prefs_toolbar->combo_action_list);
|
2003-01-16 19:35:59 +01:00
|
|
|
prefs_toolbar->combo_action_list = NULL;
|
2003-01-12 02:01:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void prefs_toolbar_set_displayed(ToolbarPage *prefs_toolbar)
|
2002-08-20 21:09:46 +02:00
|
|
|
{
|
|
|
|
GSList *cur;
|
2005-01-16 19:18:27 +01:00
|
|
|
GtkTreeView *list_view_set = GTK_TREE_VIEW(prefs_toolbar->list_view_set);
|
|
|
|
GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model
|
|
|
|
(list_view_set));
|
2003-01-12 02:01:26 +01:00
|
|
|
GSList *toolbar_list = toolbar_get_list(prefs_toolbar->source);
|
2005-01-16 19:18:27 +01:00
|
|
|
GtkTreeIter iter;
|
2002-08-20 21:09:46 +02:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
gtk_list_store_clear(store);
|
2002-08-20 21:09:46 +02:00
|
|
|
|
|
|
|
/* set currently active toolbar entries */
|
|
|
|
for (cur = toolbar_list; cur != NULL; cur = cur->next) {
|
|
|
|
ToolbarItem *item = (ToolbarItem*) cur->data;
|
2005-01-16 19:18:27 +01:00
|
|
|
|
|
|
|
gtk_list_store_append(store, &iter);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2002-12-24 15:29:16 +01:00
|
|
|
if (item->index != A_SEPARATOR) {
|
2005-01-16 19:18:27 +01:00
|
|
|
GdkPixbuf *pix;
|
2002-08-20 21:09:46 +02:00
|
|
|
StockPixmap icon = stock_pixmap_get_icon(item->file);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
stock_pixbuf_gdk(prefs_toolbar->window, icon, &pix);
|
|
|
|
|
2015-02-19 01:19:01 +01:00
|
|
|
gtk_list_store_set(store, &iter,
|
2005-01-16 19:18:27 +01:00
|
|
|
SET_ICON, pix,
|
|
|
|
SET_FILENAME, item->file,
|
|
|
|
SET_TEXT, item->text,
|
|
|
|
SET_EVENT, toolbar_ret_descr_from_val(item->index),
|
2015-02-19 01:19:01 +01:00
|
|
|
SET_ICON_TEXT, NULL,
|
2005-01-16 19:18:27 +01:00
|
|
|
SET_ICON_IS_TEXT, FALSE,
|
|
|
|
-1);
|
2002-08-20 21:09:46 +02:00
|
|
|
} else {
|
2005-01-16 19:18:27 +01:00
|
|
|
gtk_list_store_set(store, &iter,
|
|
|
|
SET_ICON, NULL,
|
|
|
|
SET_FILENAME, toolbar_ret_descr_from_val(A_SEPARATOR),
|
2015-02-19 01:19:01 +01:00
|
|
|
SET_TEXT, (const gchar *) "",
|
2005-01-16 19:18:27 +01:00
|
|
|
SET_EVENT, toolbar_ret_descr_from_val(A_SEPARATOR),
|
|
|
|
SET_ICON_TEXT, (const gchar *) SEPARATOR_PIXMAP,
|
|
|
|
SET_ICON_IS_TEXT, TRUE,
|
|
|
|
-1);
|
2002-08-20 21:09:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
/* select first */
|
|
|
|
gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
|
|
|
|
gtk_tree_selection_select_iter(gtk_tree_view_get_selection
|
|
|
|
(list_view_set),
|
2015-02-19 01:19:01 +01:00
|
|
|
&iter);
|
2002-08-20 21:09:46 +02:00
|
|
|
}
|
|
|
|
|
2009-11-17 16:15:15 +01:00
|
|
|
static void add_item_to_plugin_combo(gpointer key, gpointer data, gpointer combo_box)
|
|
|
|
{
|
2012-11-15 14:41:07 +01:00
|
|
|
#if !GTK_CHECK_VERSION(2, 24, 0)
|
2011-04-10 19:19:05 +02:00
|
|
|
gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), (const gchar*)key);
|
2012-11-15 14:41:07 +01:00
|
|
|
#else
|
|
|
|
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo_box), (const gchar*)key);
|
|
|
|
#endif
|
2009-11-17 16:15:15 +01:00
|
|
|
}
|
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
static void prefs_toolbar_populate(ToolbarPage *prefs_toolbar)
|
2002-08-06 16:06:40 +02:00
|
|
|
{
|
2007-10-17 16:43:24 +02:00
|
|
|
GSList *cur;
|
2007-10-06 19:34:01 +02:00
|
|
|
gchar *act, *act_name;
|
2009-12-19 23:50:46 +01:00
|
|
|
GHashTable **hash;
|
2007-10-06 19:34:01 +02:00
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
prefs_toolbar->combo_action_list = toolbar_get_action_items(prefs_toolbar->source);
|
2013-06-11 14:39:45 +02:00
|
|
|
#if !GTK_CHECK_VERSION(2, 24, 0)
|
2007-10-17 16:43:24 +02:00
|
|
|
combobox_set_popdown_strings(GTK_COMBO_BOX(prefs_toolbar->item_func_combo),
|
|
|
|
prefs_toolbar->combo_action_list);
|
2013-06-11 14:39:45 +02:00
|
|
|
#else
|
|
|
|
combobox_set_popdown_strings(GTK_COMBO_BOX_TEXT(prefs_toolbar->item_func_combo),
|
|
|
|
prefs_toolbar->combo_action_list);
|
|
|
|
#endif
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2002-08-06 16:06:40 +02:00
|
|
|
/* get currently defined sylpheed actions */
|
|
|
|
if (prefs_common.actions_list != NULL) {
|
2007-10-17 16:43:24 +02:00
|
|
|
for (cur = prefs_common.actions_list; cur != NULL; cur = cur->next) {
|
|
|
|
act = (gchar *)cur->data;
|
2007-10-06 19:34:01 +02:00
|
|
|
get_action_name(act, &act_name);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2012-11-15 14:41:07 +01:00
|
|
|
#if !GTK_CHECK_VERSION(2, 24, 0)
|
2011-04-10 19:19:05 +02:00
|
|
|
gtk_combo_box_append_text(
|
|
|
|
GTK_COMBO_BOX(prefs_toolbar->item_action_combo),
|
2012-11-15 14:41:07 +01:00
|
|
|
#else
|
|
|
|
gtk_combo_box_text_append_text(
|
|
|
|
GTK_COMBO_BOX_TEXT(prefs_toolbar->item_action_combo),
|
|
|
|
#endif
|
2007-10-06 19:34:01 +02:00
|
|
|
act_name);
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
g_free(act_name);
|
2015-02-19 01:19:01 +01:00
|
|
|
}
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2011-02-10 19:36:30 +01:00
|
|
|
} else
|
|
|
|
combobox_set_sensitive(GTK_COMBO_BOX(prefs_toolbar->item_type_combo),
|
|
|
|
ITEM_USER_ACTION, FALSE);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2009-11-17 16:15:15 +01:00
|
|
|
/* items registered by plugins */
|
2009-12-19 23:50:46 +01:00
|
|
|
hash = get_plugin_hash_from_toolbar_type(prefs_toolbar->source);
|
2011-02-10 19:36:30 +01:00
|
|
|
if (hash && *hash)
|
2015-02-19 01:19:01 +01:00
|
|
|
g_hash_table_foreach(*hash, add_item_to_plugin_combo,
|
2011-02-10 19:36:30 +01:00
|
|
|
prefs_toolbar->item_plugin_combo);
|
|
|
|
else
|
|
|
|
combobox_set_sensitive(GTK_COMBO_BOX(prefs_toolbar->item_type_combo),
|
|
|
|
ITEM_PLUGIN, FALSE);
|
2009-11-17 16:15:15 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(prefs_toolbar->item_func_combo), 0);
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(prefs_toolbar->item_action_combo), 0);
|
2009-11-17 16:15:15 +01:00
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(prefs_toolbar->item_plugin_combo), 0);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
prefs_toolbar_set_displayed(prefs_toolbar);
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
toolbar_clear_list(prefs_toolbar->source);
|
2002-08-06 16:06:40 +02:00
|
|
|
}
|
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
static gboolean is_duplicate(ToolbarPage *prefs_toolbar, gchar *chosen_action)
|
2002-08-06 16:06:40 +02:00
|
|
|
{
|
2005-01-16 19:18:27 +01:00
|
|
|
GtkTreeView *list_view_set = GTK_TREE_VIEW
|
|
|
|
(prefs_toolbar->list_view_set);
|
2015-02-19 01:19:01 +01:00
|
|
|
GtkTreeModel *model_set = gtk_tree_view_get_model(list_view_set);
|
2002-08-06 16:06:40 +02:00
|
|
|
gchar *entry;
|
2005-01-16 19:18:27 +01:00
|
|
|
GtkTreeIter iter;
|
|
|
|
gboolean result;
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_val_if_fail(chosen_action != NULL, TRUE);
|
2005-01-16 19:18:27 +01:00
|
|
|
|
|
|
|
if (!gtk_tree_model_iter_n_children(model_set, NULL))
|
2002-08-06 16:06:40 +02:00
|
|
|
return FALSE;
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
if (!gtk_tree_model_get_iter_first(model_set, &iter))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
result = FALSE;
|
2002-08-06 16:06:40 +02:00
|
|
|
do {
|
2005-01-16 19:18:27 +01:00
|
|
|
gtk_tree_model_get(model_set, &iter,
|
2015-02-19 01:19:01 +01:00
|
|
|
SET_EVENT, &entry,
|
2005-01-16 19:18:27 +01:00
|
|
|
-1);
|
2015-02-19 01:19:01 +01:00
|
|
|
if (g_utf8_collate(chosen_action, entry) == 0)
|
2005-01-16 19:18:27 +01:00
|
|
|
result = TRUE;
|
2015-02-19 01:19:01 +01:00
|
|
|
g_free(entry);
|
2005-01-16 19:18:27 +01:00
|
|
|
} while (!result && gtk_tree_model_iter_next(model_set, &iter));
|
|
|
|
|
|
|
|
return result;
|
2002-08-06 16:06:40 +02:00
|
|
|
}
|
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
static void prefs_toolbar_default(GtkButton *button, ToolbarPage *prefs_toolbar)
|
2002-08-06 16:06:40 +02:00
|
|
|
{
|
2003-01-12 02:01:26 +01:00
|
|
|
toolbar_clear_list(prefs_toolbar->source);
|
|
|
|
toolbar_set_default(prefs_toolbar->source);
|
|
|
|
prefs_toolbar_set_displayed(prefs_toolbar);
|
2002-08-20 21:09:46 +02:00
|
|
|
}
|
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
/*!
|
|
|
|
*\return String that should be freed by caller.
|
|
|
|
*/
|
2004-11-15 11:28:16 +01:00
|
|
|
static void get_action_name(const gchar *entry, gchar **menu)
|
2002-08-06 16:06:40 +02:00
|
|
|
{
|
|
|
|
gchar *act, *act_p;
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-07-09 21:16:10 +02:00
|
|
|
*menu = NULL;
|
2002-08-06 16:06:40 +02:00
|
|
|
|
|
|
|
if (prefs_common.actions_list != NULL) {
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2002-08-14 21:29:09 +02:00
|
|
|
act = g_strdup(entry);
|
2002-08-06 16:06:40 +02:00
|
|
|
act_p = strstr(act, ": ");
|
|
|
|
if (act_p != NULL)
|
|
|
|
act_p[0] = 0x00;
|
|
|
|
/* freed by calling func */
|
|
|
|
*menu = act;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
static void prefs_toolbar_register(GtkButton *button, ToolbarPage *prefs_toolbar)
|
2002-08-06 16:06:40 +02:00
|
|
|
{
|
2005-01-16 19:18:27 +01:00
|
|
|
GtkTreeView *list_view_set = GTK_TREE_VIEW(prefs_toolbar->list_view_set);
|
2007-10-06 19:34:01 +02:00
|
|
|
gint item_type = gtk_combo_box_get_active(GTK_COMBO_BOX(prefs_toolbar->item_type_combo));
|
2005-01-16 19:18:27 +01:00
|
|
|
GtkListStore *store_set;
|
|
|
|
GtkTreeIter iter;
|
2002-08-08 08:11:08 +02:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
store_set = GTK_LIST_STORE(gtk_tree_view_get_model(list_view_set));
|
|
|
|
|
|
|
|
/* SEPARATOR or other ? */
|
2007-10-06 19:34:01 +02:00
|
|
|
if (item_type == ITEM_SEPARATOR) {
|
2005-01-16 19:18:27 +01:00
|
|
|
gtk_list_store_append(store_set, &iter);
|
|
|
|
gtk_list_store_set(store_set, &iter,
|
|
|
|
SET_ICON, NULL,
|
2007-10-06 19:34:01 +02:00
|
|
|
SET_FILENAME, prefs_toolbar->item_icon_file,
|
2005-01-16 19:18:27 +01:00
|
|
|
SET_TEXT, NULL,
|
|
|
|
SET_EVENT, toolbar_ret_descr_from_val(A_SEPARATOR),
|
|
|
|
SET_ICON_TEXT, (const gchar *) SEPARATOR_PIXMAP,
|
|
|
|
SET_ICON_IS_TEXT, TRUE,
|
|
|
|
-1);
|
2002-08-06 16:06:40 +02:00
|
|
|
} else {
|
2005-01-16 19:18:27 +01:00
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
gchar *event, *text;
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2007-10-07 11:43:00 +02:00
|
|
|
if (prefs_toolbar->item_icon_file == NULL) {
|
|
|
|
alertpanel_error(ERROR_MSG_NO_ICON);
|
|
|
|
return;
|
|
|
|
}
|
2015-02-19 01:19:01 +01:00
|
|
|
stock_pixbuf_gdk(prefs_toolbar->window,
|
2007-10-06 19:34:01 +02:00
|
|
|
stock_pixmap_get_icon(prefs_toolbar->item_icon_file),
|
2005-01-16 19:18:27 +01:00
|
|
|
&pixbuf);
|
2007-10-06 19:34:01 +02:00
|
|
|
if(pixbuf == NULL) {
|
|
|
|
alertpanel_error(ERROR_MSG_NO_ICON);
|
|
|
|
return;
|
|
|
|
}
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
if (item_type == ITEM_FUNCTION) {
|
2012-11-15 14:41:07 +01:00
|
|
|
#if !GTK_CHECK_VERSION(2, 24, 0)
|
2011-04-10 19:19:05 +02:00
|
|
|
event = gtk_combo_box_get_active_text(GTK_COMBO_BOX(
|
2012-11-15 14:41:07 +01:00
|
|
|
#else
|
|
|
|
event = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(
|
|
|
|
#endif
|
2011-04-10 19:19:05 +02:00
|
|
|
prefs_toolbar->item_func_combo));
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
if (is_duplicate(prefs_toolbar, event)) {
|
|
|
|
alertpanel_error(ERROR_MSG);
|
|
|
|
g_free(event);
|
|
|
|
return;
|
|
|
|
}
|
2009-11-17 16:15:15 +01:00
|
|
|
} else if(item_type == ITEM_PLUGIN)
|
|
|
|
event = toolbar_ret_descr_from_val(A_CLAWS_PLUGINS);
|
|
|
|
else
|
2007-11-07 10:21:19 +01:00
|
|
|
event = toolbar_ret_descr_from_val(A_CLAWS_ACTIONS);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
text = gtk_editable_get_chars(
|
|
|
|
GTK_EDITABLE(prefs_toolbar->item_text_entry), 0 , -1);
|
2005-01-16 19:18:27 +01:00
|
|
|
|
2007-07-09 21:16:10 +02:00
|
|
|
if (text != NULL) {
|
|
|
|
gtk_list_store_append(store_set, &iter);
|
|
|
|
gtk_list_store_set(store_set, &iter,
|
|
|
|
SET_ICON, pixbuf,
|
2007-10-06 19:34:01 +02:00
|
|
|
SET_FILENAME, prefs_toolbar->item_icon_file,
|
2007-07-09 21:16:10 +02:00
|
|
|
SET_TEXT, text,
|
|
|
|
SET_EVENT, event,
|
|
|
|
SET_ICON_TEXT, NULL,
|
|
|
|
SET_ICON_IS_TEXT, FALSE,
|
|
|
|
-1);
|
2007-10-06 19:34:01 +02:00
|
|
|
} else {
|
|
|
|
alertpanel_error(ERROR_MSG_NO_TEXT);
|
|
|
|
return;
|
2007-07-09 21:16:10 +02:00
|
|
|
}
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
g_free(text);
|
2009-11-17 16:15:15 +01:00
|
|
|
if((item_type != ITEM_USER_ACTION) && (item_type != ITEM_PLUGIN))
|
2007-10-06 19:34:01 +02:00
|
|
|
g_free(event);
|
2002-08-06 16:06:40 +02:00
|
|
|
}
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
gtk_tree_selection_select_iter(gtk_tree_view_get_selection
|
|
|
|
(list_view_set),
|
|
|
|
&iter);
|
2002-08-06 16:06:40 +02:00
|
|
|
}
|
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
static void prefs_toolbar_substitute(GtkButton *button, ToolbarPage *prefs_toolbar)
|
2002-08-06 16:06:40 +02:00
|
|
|
{
|
2005-01-16 19:18:27 +01:00
|
|
|
GtkTreeView *list_view_set = GTK_TREE_VIEW(prefs_toolbar->list_view_set);
|
|
|
|
GtkListStore *store_set = GTK_LIST_STORE(gtk_tree_view_get_model(list_view_set));
|
2007-10-06 19:34:01 +02:00
|
|
|
gint item_type = gtk_combo_box_get_active(GTK_COMBO_BOX(prefs_toolbar->item_type_combo));
|
2005-01-16 19:18:27 +01:00
|
|
|
GtkTreeSelection *sel_set;
|
|
|
|
GtkTreeIter iter_set;
|
|
|
|
|
|
|
|
if (!gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store_set), NULL))
|
2002-08-24 11:54:27 +02:00
|
|
|
return;
|
2015-02-19 01:19:01 +01:00
|
|
|
|
|
|
|
sel_set = gtk_tree_view_get_selection(list_view_set);
|
2005-01-16 19:18:27 +01:00
|
|
|
if (!gtk_tree_selection_get_selected(sel_set, NULL, &iter_set))
|
2002-08-24 11:54:27 +02:00
|
|
|
return;
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
if (item_type == ITEM_SEPARATOR) {
|
2015-02-19 01:19:01 +01:00
|
|
|
gtk_list_store_set(store_set, &iter_set,
|
2005-01-16 19:18:27 +01:00
|
|
|
SET_ICON, NULL,
|
|
|
|
SET_TEXT, NULL,
|
|
|
|
SET_EVENT, toolbar_ret_descr_from_val(A_SEPARATOR),
|
2007-10-06 19:34:01 +02:00
|
|
|
SET_FILENAME, prefs_toolbar->item_icon_file,
|
2005-01-16 19:18:27 +01:00
|
|
|
SET_ICON_TEXT, (const gchar *) SEPARATOR_PIXMAP,
|
|
|
|
SET_ICON_IS_TEXT, TRUE,
|
|
|
|
-1);
|
|
|
|
} else {
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
gchar *icon_event, *set_event, *text;
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2007-10-07 11:43:00 +02:00
|
|
|
if (prefs_toolbar->item_icon_file == NULL) {
|
|
|
|
alertpanel_error(ERROR_MSG_NO_ICON);
|
|
|
|
return;
|
|
|
|
}
|
2015-02-19 01:19:01 +01:00
|
|
|
stock_pixbuf_gdk(prefs_toolbar->window,
|
2007-10-06 19:34:01 +02:00
|
|
|
stock_pixmap_get_icon(prefs_toolbar->item_icon_file),
|
|
|
|
&pixbuf);
|
|
|
|
if(pixbuf == NULL) {
|
|
|
|
alertpanel_error(ERROR_MSG_NO_ICON);
|
|
|
|
return;
|
|
|
|
}
|
2002-08-08 08:11:08 +02:00
|
|
|
|
2015-02-19 01:19:01 +01:00
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(store_set), &iter_set,
|
2005-01-16 19:18:27 +01:00
|
|
|
SET_EVENT, &set_event,
|
|
|
|
-1);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
if (item_type == ITEM_FUNCTION) {
|
2012-11-15 14:41:07 +01:00
|
|
|
#if !GTK_CHECK_VERSION(2, 24, 0)
|
2011-04-10 19:19:05 +02:00
|
|
|
icon_event = gtk_combo_box_get_active_text(GTK_COMBO_BOX(
|
2012-11-15 14:41:07 +01:00
|
|
|
#else
|
|
|
|
icon_event = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(
|
|
|
|
#endif
|
2011-04-10 19:19:05 +02:00
|
|
|
prefs_toolbar->item_func_combo));
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
if (is_duplicate(prefs_toolbar, icon_event)
|
|
|
|
&& g_utf8_collate(icon_event, set_event) != 0){
|
|
|
|
alertpanel_error(ERROR_MSG);
|
|
|
|
g_free(icon_event);
|
|
|
|
g_free(set_event);
|
|
|
|
return;
|
|
|
|
}
|
2009-11-17 16:15:15 +01:00
|
|
|
} else if(item_type == ITEM_PLUGIN)
|
|
|
|
icon_event = toolbar_ret_descr_from_val(A_CLAWS_PLUGINS);
|
|
|
|
else
|
2007-11-07 10:21:19 +01:00
|
|
|
icon_event = toolbar_ret_descr_from_val(A_CLAWS_ACTIONS);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
text = gtk_editable_get_chars(
|
|
|
|
GTK_EDITABLE(prefs_toolbar->item_text_entry), 0 , -1);
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
/* change the row */
|
2007-07-09 21:16:10 +02:00
|
|
|
if (text != NULL) {
|
|
|
|
gtk_list_store_set(store_set, &iter_set,
|
|
|
|
SET_ICON, pixbuf,
|
2007-10-06 19:34:01 +02:00
|
|
|
SET_FILENAME, prefs_toolbar->item_icon_file,
|
2007-07-09 21:16:10 +02:00
|
|
|
SET_TEXT, text,
|
|
|
|
SET_EVENT, icon_event,
|
|
|
|
SET_ICON_TEXT, NULL,
|
|
|
|
SET_ICON_IS_TEXT, FALSE,
|
|
|
|
-1);
|
2015-02-19 01:19:01 +01:00
|
|
|
} else
|
2007-10-06 19:34:01 +02:00
|
|
|
alertpanel_error(ERROR_MSG_NO_TEXT);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
g_free(text);
|
2007-10-06 19:34:01 +02:00
|
|
|
g_free(set_event);
|
2009-11-17 16:15:15 +01:00
|
|
|
if((item_type != ITEM_USER_ACTION) && (item_type != ITEM_PLUGIN))
|
|
|
|
g_free(icon_event);
|
2002-08-06 16:06:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
static void prefs_toolbar_delete(GtkButton *button, ToolbarPage *prefs_toolbar)
|
2002-08-06 16:06:40 +02:00
|
|
|
{
|
2005-01-16 19:18:27 +01:00
|
|
|
GtkTreeView *list_view_set = GTK_TREE_VIEW(prefs_toolbar->list_view_set);
|
2007-10-06 19:34:01 +02:00
|
|
|
GtkTreeModel *store_set = gtk_tree_view_get_model(list_view_set);
|
|
|
|
GtkTreeIter iter_set;
|
2015-02-19 01:19:01 +01:00
|
|
|
GtkTreePath *path;
|
2005-01-16 19:18:27 +01:00
|
|
|
|
|
|
|
if (!gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store_set), NULL))
|
2002-08-24 11:54:27 +02:00
|
|
|
return;
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection
|
|
|
|
(list_view_set),
|
|
|
|
NULL,
|
|
|
|
&iter_set))
|
2015-02-19 01:19:01 +01:00
|
|
|
return;
|
2007-10-06 19:34:01 +02:00
|
|
|
|
|
|
|
/* select prev list item, if deleted was first select next */
|
|
|
|
path = gtk_tree_model_get_path(store_set, &iter_set);
|
|
|
|
gtk_tree_path_prev(path);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_list_store_remove(GTK_LIST_STORE(store_set), &iter_set);
|
|
|
|
|
|
|
|
gtk_tree_selection_select_path(
|
|
|
|
gtk_tree_view_get_selection(list_view_set),
|
|
|
|
path);
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_tree_path_free(path);
|
2002-08-06 16:06:40 +02:00
|
|
|
}
|
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
static void prefs_toolbar_up(GtkButton *button, ToolbarPage *prefs_toolbar)
|
2002-08-06 16:06:40 +02:00
|
|
|
{
|
2005-01-16 19:18:27 +01:00
|
|
|
GtkTreePath *prev, *sel;
|
|
|
|
GtkTreeIter isel;
|
2005-09-14 10:11:20 +02:00
|
|
|
GtkListStore *store = NULL;
|
2005-09-17 09:59:36 +02:00
|
|
|
GtkTreeModel *model = NULL;
|
2005-01-16 19:18:27 +01:00
|
|
|
GtkTreeIter iprev;
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
if (!gtk_tree_selection_get_selected
|
|
|
|
(gtk_tree_view_get_selection
|
|
|
|
(GTK_TREE_VIEW(prefs_toolbar->list_view_set)),
|
2015-02-19 01:19:01 +01:00
|
|
|
&model,
|
2005-01-16 19:18:27 +01:00
|
|
|
&isel))
|
|
|
|
return;
|
2005-09-17 09:59:36 +02:00
|
|
|
store = (GtkListStore *)model;
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
sel = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &isel);
|
|
|
|
if (!sel)
|
|
|
|
return;
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
/* no move if we're at row 0... */
|
|
|
|
prev = gtk_tree_path_copy(sel);
|
|
|
|
if (!gtk_tree_path_prev(prev)) {
|
|
|
|
gtk_tree_path_free(prev);
|
|
|
|
gtk_tree_path_free(sel);
|
|
|
|
return;
|
2002-09-22 16:37:58 +02:00
|
|
|
}
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
gtk_tree_model_get_iter(GTK_TREE_MODEL(store),
|
|
|
|
&iprev, prev);
|
|
|
|
gtk_tree_path_free(sel);
|
|
|
|
gtk_tree_path_free(prev);
|
|
|
|
|
|
|
|
gtk_list_store_swap(store, &iprev, &isel);
|
2002-08-06 16:06:40 +02:00
|
|
|
}
|
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
static void prefs_toolbar_down(GtkButton *button, ToolbarPage *prefs_toolbar)
|
2002-08-06 16:06:40 +02:00
|
|
|
{
|
2005-09-14 10:11:20 +02:00
|
|
|
GtkListStore *store = NULL;
|
2005-09-17 09:59:36 +02:00
|
|
|
GtkTreeModel *model = NULL;
|
2005-01-16 19:18:27 +01:00
|
|
|
GtkTreeIter next, sel;
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
if (!gtk_tree_selection_get_selected
|
|
|
|
(gtk_tree_view_get_selection
|
|
|
|
(GTK_TREE_VIEW(prefs_toolbar->list_view_set)),
|
2005-09-17 09:59:36 +02:00
|
|
|
&model,
|
2005-01-16 19:18:27 +01:00
|
|
|
&sel))
|
|
|
|
return;
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2005-09-17 09:59:36 +02:00
|
|
|
store = (GtkListStore *)model;
|
2005-01-16 19:18:27 +01:00
|
|
|
next = sel;
|
2015-02-19 01:19:01 +01:00
|
|
|
if (!gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &next))
|
2005-01-16 19:18:27 +01:00
|
|
|
return;
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
gtk_list_store_swap(store, &next, &sel);
|
2002-08-06 16:06:40 +02:00
|
|
|
}
|
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
static void item_type_changed(GtkComboBox *item_type_combo,
|
|
|
|
ToolbarPage *prefs_toolbar)
|
2002-08-06 16:06:40 +02:00
|
|
|
{
|
2007-10-06 19:34:01 +02:00
|
|
|
gint active = gtk_combo_box_get_active(item_type_combo);
|
|
|
|
|
|
|
|
switch(active) {
|
|
|
|
case ITEM_FUNCTION:
|
|
|
|
gtk_widget_show(prefs_toolbar->item_func_combo);
|
|
|
|
gtk_widget_hide(prefs_toolbar->item_action_combo);
|
2009-11-17 16:15:15 +01:00
|
|
|
gtk_widget_hide(prefs_toolbar->item_plugin_combo);
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_combo_box_set_active(
|
|
|
|
GTK_COMBO_BOX(prefs_toolbar->item_func_combo), 0);
|
|
|
|
gtk_button_set_label(GTK_BUTTON(prefs_toolbar->icon_button), "");
|
|
|
|
gtk_widget_set_sensitive(prefs_toolbar->item_text_entry, TRUE);
|
|
|
|
gtk_widget_set_sensitive(prefs_toolbar->item_func_combo, TRUE);
|
|
|
|
gtk_widget_set_sensitive(prefs_toolbar->icon_button, TRUE);
|
2007-10-06 23:14:37 +02:00
|
|
|
|
|
|
|
func_selection_changed(GTK_COMBO_BOX(prefs_toolbar->item_func_combo),
|
|
|
|
prefs_toolbar);
|
2007-10-06 19:34:01 +02:00
|
|
|
break;
|
|
|
|
case ITEM_USER_ACTION:
|
|
|
|
gtk_widget_show(prefs_toolbar->item_action_combo);
|
|
|
|
gtk_widget_hide(prefs_toolbar->item_func_combo);
|
2009-11-17 16:15:15 +01:00
|
|
|
gtk_widget_hide(prefs_toolbar->item_plugin_combo);
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_combo_box_set_active(
|
|
|
|
GTK_COMBO_BOX(prefs_toolbar->item_action_combo), 0);
|
|
|
|
gtk_button_set_label(GTK_BUTTON(prefs_toolbar->icon_button), "");
|
|
|
|
gtk_widget_set_sensitive(prefs_toolbar->item_text_entry, FALSE);
|
|
|
|
gtk_widget_set_sensitive(prefs_toolbar->item_action_combo, TRUE);
|
|
|
|
gtk_widget_set_sensitive(prefs_toolbar->icon_button, TRUE);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 23:14:37 +02:00
|
|
|
action_selection_changed(GTK_COMBO_BOX(prefs_toolbar->item_action_combo),
|
2015-02-19 01:19:01 +01:00
|
|
|
prefs_toolbar);
|
2007-10-06 19:34:01 +02:00
|
|
|
break;
|
|
|
|
case ITEM_SEPARATOR:
|
|
|
|
gtk_button_set_label(GTK_BUTTON(prefs_toolbar->icon_button), _("None"));
|
|
|
|
gtk_button_set_image(GTK_BUTTON(prefs_toolbar->icon_button), NULL);
|
2007-10-07 11:43:00 +02:00
|
|
|
g_free(prefs_toolbar->item_icon_file);
|
|
|
|
prefs_toolbar->item_icon_file = NULL;
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_combo_box_set_active(
|
|
|
|
GTK_COMBO_BOX(prefs_toolbar->item_func_combo), -1);
|
|
|
|
gtk_combo_box_set_active(
|
|
|
|
GTK_COMBO_BOX(prefs_toolbar->item_action_combo), -1);
|
2011-02-10 19:36:30 +01:00
|
|
|
gtk_combo_box_set_active(
|
|
|
|
GTK_COMBO_BOX(prefs_toolbar->item_plugin_combo), -1);
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_entry_set_text(GTK_ENTRY(prefs_toolbar->item_text_entry), "");
|
|
|
|
gtk_widget_set_sensitive(prefs_toolbar->item_action_combo, FALSE);
|
|
|
|
gtk_widget_set_sensitive(prefs_toolbar->item_text_entry, FALSE);
|
2009-11-17 16:15:15 +01:00
|
|
|
gtk_widget_set_sensitive(prefs_toolbar->item_plugin_combo, FALSE);
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_widget_set_sensitive(prefs_toolbar->item_func_combo, FALSE);
|
|
|
|
gtk_widget_set_sensitive(prefs_toolbar->icon_button, FALSE);
|
|
|
|
break;
|
2009-11-17 16:15:15 +01:00
|
|
|
case ITEM_PLUGIN:
|
2011-02-10 19:36:30 +01:00
|
|
|
gtk_widget_show(prefs_toolbar->item_plugin_combo);
|
|
|
|
gtk_widget_hide(prefs_toolbar->item_func_combo);
|
|
|
|
gtk_widget_hide(prefs_toolbar->item_action_combo);
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(prefs_toolbar->item_plugin_combo), 0);
|
|
|
|
gtk_button_set_label(GTK_BUTTON(prefs_toolbar->icon_button), "");
|
|
|
|
gtk_widget_set_sensitive(prefs_toolbar->item_text_entry, FALSE);
|
|
|
|
gtk_widget_set_sensitive(prefs_toolbar->item_plugin_combo, TRUE);
|
|
|
|
gtk_widget_set_sensitive(prefs_toolbar->icon_button, TRUE);
|
|
|
|
plugin_selection_changed(GTK_COMBO_BOX(prefs_toolbar->item_plugin_combo), prefs_toolbar);
|
|
|
|
break;
|
2002-08-06 16:06:40 +02:00
|
|
|
}
|
2002-08-20 21:09:46 +02:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void action_selection_changed(GtkComboBox *action_combo,
|
|
|
|
ToolbarPage *prefs_toolbar)
|
|
|
|
{
|
2012-11-15 14:41:07 +01:00
|
|
|
#if !GTK_CHECK_VERSION(2, 24, 0)
|
2011-04-10 19:19:05 +02:00
|
|
|
gchar *text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(
|
2012-11-15 14:41:07 +01:00
|
|
|
#else
|
|
|
|
gchar *text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(
|
|
|
|
#endif
|
2007-10-06 19:34:01 +02:00
|
|
|
prefs_toolbar->item_action_combo));
|
2007-10-06 20:32:04 +02:00
|
|
|
|
|
|
|
if(text != NULL) { /* action */
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_entry_set_text(GTK_ENTRY(prefs_toolbar->item_text_entry), text);
|
2007-10-06 20:32:04 +02:00
|
|
|
g_free(text);
|
2015-02-19 01:19:01 +01:00
|
|
|
}
|
2007-10-06 20:32:04 +02:00
|
|
|
}
|
|
|
|
|
2009-11-17 16:15:15 +01:00
|
|
|
static void plugin_selection_changed(GtkComboBox *action_combo,
|
|
|
|
ToolbarPage *prefs_toolbar)
|
|
|
|
{
|
2012-11-15 14:41:07 +01:00
|
|
|
#if !GTK_CHECK_VERSION(2, 24, 0)
|
2011-04-10 19:19:05 +02:00
|
|
|
gchar *text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(prefs_toolbar->item_plugin_combo));
|
2012-11-15 14:41:07 +01:00
|
|
|
#else
|
|
|
|
gchar *text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(prefs_toolbar->item_plugin_combo));
|
|
|
|
#endif
|
2009-11-17 16:15:15 +01:00
|
|
|
|
2011-02-10 19:36:30 +01:00
|
|
|
if (text != NULL) { /* action */
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(prefs_toolbar->item_text_entry), text);
|
|
|
|
g_free(text);
|
|
|
|
}
|
2009-11-17 16:15:15 +01:00
|
|
|
}
|
|
|
|
|
2007-10-06 20:32:04 +02:00
|
|
|
static void func_selection_changed(GtkComboBox *action_combo,
|
|
|
|
ToolbarPage *prefs_toolbar)
|
|
|
|
{
|
2012-11-15 14:41:07 +01:00
|
|
|
#if !GTK_CHECK_VERSION(2, 24, 0)
|
2011-04-10 19:19:05 +02:00
|
|
|
gchar *text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(
|
2012-11-15 14:41:07 +01:00
|
|
|
#else
|
|
|
|
gchar *text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(
|
|
|
|
#endif
|
2007-10-06 20:32:04 +02:00
|
|
|
prefs_toolbar->item_func_combo));
|
|
|
|
|
|
|
|
if(text != NULL) { /* action */
|
|
|
|
int action = -1;
|
|
|
|
action = toolbar_ret_val_from_descr(text);
|
|
|
|
if (action >= 0)
|
2015-02-19 01:19:01 +01:00
|
|
|
gtk_entry_set_text(GTK_ENTRY(prefs_toolbar->item_text_entry),
|
2007-10-06 20:32:04 +02:00
|
|
|
toolbar_get_short_text(action));
|
|
|
|
g_free(text);
|
2007-10-07 10:58:46 +02:00
|
|
|
if (action >= 0) {
|
|
|
|
StockPixmap stockp = toolbar_get_icon(action);
|
|
|
|
if (stockp >= 0) {
|
|
|
|
g_free(prefs_toolbar->item_icon_file);
|
|
|
|
prefs_toolbar->item_icon_file = g_strdup(stock_pixmap_get_name(stockp));
|
|
|
|
|
|
|
|
gtk_button_set_image(GTK_BUTTON(prefs_toolbar->icon_button),
|
|
|
|
stock_pixmap_widget(prefs_toolbar->window, stockp));
|
|
|
|
}
|
|
|
|
}
|
2015-02-19 01:19:01 +01:00
|
|
|
}
|
2002-08-06 16:06:40 +02:00
|
|
|
}
|
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
static void prefs_toolbar_create(ToolbarPage *prefs_toolbar)
|
2002-08-06 16:06:40 +02:00
|
|
|
{
|
|
|
|
GtkWidget *main_vbox;
|
2007-10-06 19:34:01 +02:00
|
|
|
GtkWidget *toolbar_item_hbox;
|
|
|
|
GtkWidget *icon_vbox;
|
|
|
|
GtkWidget *icon_label;
|
|
|
|
GtkWidget *icon_button;
|
|
|
|
GtkWidget *icon_hbox;
|
|
|
|
GtkWidget *item_type_combo;
|
2011-02-10 19:36:30 +01:00
|
|
|
GtkListStore *item_type_model;
|
|
|
|
GtkTreeIter iter;
|
2007-10-06 19:34:01 +02:00
|
|
|
GtkWidget *item_action_combo;
|
2009-11-17 16:15:15 +01:00
|
|
|
GtkWidget *item_plugin_combo;
|
2007-10-06 19:34:01 +02:00
|
|
|
GtkWidget *item_func_combo;
|
2002-08-06 16:06:40 +02:00
|
|
|
GtkWidget *reg_hbox;
|
|
|
|
GtkWidget *arrow;
|
|
|
|
GtkWidget *btn_hbox;
|
2008-05-07 10:18:24 +02:00
|
|
|
#ifdef GENERIC_UMPC
|
2007-03-31 17:45:12 +02:00
|
|
|
GtkWidget *hbox;
|
|
|
|
#endif
|
2002-08-06 16:06:40 +02:00
|
|
|
GtkWidget *reg_btn;
|
|
|
|
GtkWidget *subst_btn;
|
|
|
|
GtkWidget *del_btn;
|
2003-04-18 17:31:31 +02:00
|
|
|
GtkWidget *default_btn;
|
2002-08-06 16:06:40 +02:00
|
|
|
GtkWidget *vbox_frame;
|
2002-08-20 21:09:46 +02:00
|
|
|
GtkWidget *table;
|
2002-08-06 16:06:40 +02:00
|
|
|
GtkWidget *label_icon_text;
|
2007-10-06 19:34:01 +02:00
|
|
|
GtkWidget *item_text_entry;
|
|
|
|
GtkWidget *vbox_toolbar_items;
|
2002-08-06 16:06:40 +02:00
|
|
|
GtkWidget *hbox_bottom;
|
2005-01-16 19:18:27 +01:00
|
|
|
GtkWidget *scrolledwindow_list_view_set;
|
|
|
|
GtkWidget *list_view_set;
|
2007-10-06 19:34:01 +02:00
|
|
|
GtkWidget *label;
|
2002-08-11 15:16:51 +02:00
|
|
|
|
|
|
|
GtkWidget *btn_vbox;
|
2002-08-06 16:06:40 +02:00
|
|
|
GtkWidget *up_btn;
|
|
|
|
GtkWidget *down_btn;
|
2005-12-07 23:57:15 +01:00
|
|
|
|
2002-08-14 15:15:46 +02:00
|
|
|
debug_print("Creating custom toolbar window...\n");
|
2002-08-10 15:09:22 +02:00
|
|
|
|
2002-08-14 21:29:09 +02:00
|
|
|
main_vbox = gtk_vbox_new(FALSE, 0);
|
|
|
|
gtk_widget_show(main_vbox);
|
2005-12-07 23:57:15 +01:00
|
|
|
|
2015-02-19 01:19:01 +01:00
|
|
|
PACK_FRAME (main_vbox, vbox_frame, _("Toolbar item"))
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(vbox_frame), 8);
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_widget_show(vbox_frame);
|
2002-08-20 21:09:46 +02:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
toolbar_item_hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
gtk_widget_show(toolbar_item_hbox);
|
|
|
|
gtk_container_add(GTK_CONTAINER (vbox_frame), toolbar_item_hbox);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
table = gtk_table_new (3, 3, FALSE);
|
|
|
|
gtk_box_pack_start(GTK_BOX(toolbar_item_hbox), table,
|
|
|
|
TRUE, TRUE, 0);
|
2002-08-20 21:09:46 +02:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (table), 8);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 8);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 8);
|
2007-10-06 19:34:01 +02:00
|
|
|
|
|
|
|
/* toolbar item type */
|
|
|
|
label = gtk_label_new(_("Item type"));
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
|
|
|
|
gtk_widget_show(label);
|
|
|
|
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
|
|
|
|
(GtkAttachOptions) (GTK_FILL),
|
2015-02-19 01:19:01 +01:00
|
|
|
(GtkAttachOptions) (0), 0, 0);
|
|
|
|
|
2011-02-10 19:36:30 +01:00
|
|
|
item_type_combo = gtkut_sc_combobox_create(NULL, TRUE);
|
|
|
|
item_type_model = GTK_LIST_STORE(gtk_combo_box_get_model(
|
|
|
|
GTK_COMBO_BOX(item_type_combo)));
|
|
|
|
COMBOBOX_ADD(item_type_model, _("Internal Function"), ITEM_FUNCTION);
|
|
|
|
COMBOBOX_ADD(item_type_model, _("User Action"), ITEM_USER_ACTION);
|
|
|
|
COMBOBOX_ADD(item_type_model, _("Plugins"), ITEM_PLUGIN);
|
2015-02-19 01:19:01 +01:00
|
|
|
COMBOBOX_ADD(item_type_model, _("Separator"), ITEM_SEPARATOR);
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_widget_set_size_request(item_type_combo, 200, -1);
|
|
|
|
gtk_table_attach(GTK_TABLE(table), item_type_combo, 1, 3, 0, 1,
|
|
|
|
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
|
|
(GtkAttachOptions) (0), 0, 0);
|
|
|
|
|
2002-08-06 16:06:40 +02:00
|
|
|
/* available actions */
|
2007-10-06 19:34:01 +02:00
|
|
|
label = gtk_label_new(_("Event executed on click"));
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
|
2007-10-06 19:43:32 +02:00
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
|
2002-08-20 21:09:46 +02:00
|
|
|
(GtkAttachOptions) (GTK_FILL),
|
|
|
|
(GtkAttachOptions) (0), 0, 0);
|
|
|
|
|
2012-11-15 14:41:07 +01:00
|
|
|
#if !GTK_CHECK_VERSION(2, 24, 0)
|
2011-04-10 19:19:05 +02:00
|
|
|
item_action_combo = gtk_combo_box_new_text();
|
2012-11-15 14:41:07 +01:00
|
|
|
#else
|
|
|
|
item_action_combo = gtk_combo_box_text_new();
|
|
|
|
#endif
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_widget_set_size_request(item_action_combo, 200, -1);
|
2007-10-06 19:43:32 +02:00
|
|
|
gtk_table_attach (GTK_TABLE (table), item_action_combo, 1, 3, 1, 2,
|
2002-08-20 21:09:46 +02:00
|
|
|
(GtkAttachOptions) (GTK_FILL),
|
|
|
|
(GtkAttachOptions) (0), 0, 0);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
/* available internal functions */
|
2012-11-15 14:41:07 +01:00
|
|
|
#if !GTK_CHECK_VERSION(2, 24, 0)
|
2011-04-10 19:19:05 +02:00
|
|
|
item_func_combo = gtk_combo_box_new_text();
|
2012-11-15 14:41:07 +01:00
|
|
|
#else
|
|
|
|
item_func_combo = gtk_combo_box_text_new();
|
|
|
|
#endif
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_widget_set_size_request(item_func_combo, 200, -1);
|
2007-10-06 19:43:32 +02:00
|
|
|
gtk_table_attach (GTK_TABLE (table), item_func_combo, 1, 3, 1, 2,
|
2007-10-06 19:34:01 +02:00
|
|
|
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
|
|
(GtkAttachOptions) (0), 0, 0);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2009-11-17 16:15:15 +01:00
|
|
|
/* plugin-registered items */
|
2012-11-15 14:41:07 +01:00
|
|
|
#if !GTK_CHECK_VERSION(2, 24, 0)
|
2011-04-10 19:19:05 +02:00
|
|
|
item_plugin_combo = gtk_combo_box_new_text();
|
2012-11-15 14:41:07 +01:00
|
|
|
#else
|
|
|
|
item_plugin_combo = gtk_combo_box_text_new();
|
|
|
|
#endif
|
2009-11-17 16:15:15 +01:00
|
|
|
gtk_widget_set_size_request(item_plugin_combo, 200, -1);
|
2011-02-10 19:36:30 +01:00
|
|
|
gtk_table_attach(GTK_TABLE(table), item_plugin_combo, 1, 3, 1, 2,
|
|
|
|
(GtkAttachOptions) (GTK_FILL),
|
|
|
|
(GtkAttachOptions) (0), 0, 0);
|
2009-11-17 16:15:15 +01:00
|
|
|
|
2007-10-06 19:43:32 +02:00
|
|
|
/* toolbar item description */
|
|
|
|
label_icon_text = gtk_label_new(_("Toolbar text"));
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(label_icon_text), 0, 0.5);
|
|
|
|
gtk_widget_show (label_icon_text);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label_icon_text, 0, 1, 2, 3,
|
|
|
|
(GtkAttachOptions) (GTK_FILL),
|
|
|
|
(GtkAttachOptions) (0), 0, 0);
|
|
|
|
|
|
|
|
item_text_entry = gtk_entry_new();
|
|
|
|
gtk_table_attach (GTK_TABLE (table), item_text_entry, 1, 3, 2, 3,
|
|
|
|
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
|
|
(GtkAttachOptions) (0), 0, 0);
|
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
icon_vbox = gtk_vbox_new(FALSE, VBOX_BORDER);
|
|
|
|
gtk_widget_show(icon_vbox);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
icon_label = gtk_label_new(_("Icon"));
|
|
|
|
gtk_widget_set_size_request(icon_label, 100, -1);
|
|
|
|
gtk_box_pack_start(GTK_BOX(icon_vbox), icon_label, FALSE, FALSE, 0);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
icon_hbox = gtk_hbox_new(FALSE, 0);
|
|
|
|
gtk_widget_show(icon_hbox);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
label = gtk_label_new("");
|
|
|
|
gtk_box_pack_start(GTK_BOX(icon_hbox), label, TRUE, TRUE, 0);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
icon_button = gtk_button_new();
|
|
|
|
gtk_widget_show(icon_button);
|
|
|
|
gtk_widget_set_size_request(icon_button, 50, 50);
|
|
|
|
g_signal_connect(G_OBJECT(icon_button), "clicked",
|
|
|
|
G_CALLBACK(icon_chooser_create), prefs_toolbar);
|
|
|
|
gtk_box_pack_start(GTK_BOX(icon_hbox), icon_button, FALSE, FALSE, 8);
|
|
|
|
|
|
|
|
label = gtk_label_new("");
|
2015-02-19 01:19:01 +01:00
|
|
|
gtk_box_pack_start(GTK_BOX(icon_hbox), label, TRUE, TRUE, 0);
|
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_box_pack_start(GTK_BOX(icon_vbox), icon_hbox, FALSE, FALSE, 0);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_box_pack_start(GTK_BOX(toolbar_item_hbox), icon_vbox, FALSE, FALSE, 0);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2002-08-06 16:06:40 +02:00
|
|
|
/* register / substitute / delete */
|
2002-08-14 21:29:09 +02:00
|
|
|
reg_hbox = gtk_hbox_new(FALSE, 4);
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vbox), reg_hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(reg_hbox), 10);
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2002-08-14 21:29:09 +02:00
|
|
|
arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
|
|
|
|
gtk_box_pack_start(GTK_BOX(reg_hbox), arrow, FALSE, FALSE, 0);
|
2005-05-05 10:18:20 +02:00
|
|
|
gtk_widget_set_size_request(arrow, -1, 16);
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2002-08-14 21:29:09 +02:00
|
|
|
btn_hbox = gtk_hbox_new(TRUE, 4);
|
|
|
|
gtk_box_pack_start(GTK_BOX(reg_hbox), btn_hbox, FALSE, FALSE, 0);
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2013-08-14 09:51:16 +02:00
|
|
|
reg_btn = gtk_button_new_with_mnemonic (_("A_dd"));
|
|
|
|
gtk_button_set_image(GTK_BUTTON(reg_btn),
|
|
|
|
gtk_image_new_from_stock(GTK_STOCK_ADD,GTK_ICON_SIZE_BUTTON));
|
2002-08-14 21:29:09 +02:00
|
|
|
gtk_box_pack_start(GTK_BOX(btn_hbox), reg_btn, FALSE, TRUE, 0);
|
2004-05-25 10:39:41 +02:00
|
|
|
g_signal_connect(G_OBJECT(reg_btn), "clicked",
|
2015-02-19 01:19:01 +01:00
|
|
|
G_CALLBACK(prefs_toolbar_register),
|
2004-05-25 10:39:41 +02:00
|
|
|
prefs_toolbar);
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2013-08-14 09:51:16 +02:00
|
|
|
subst_btn = gtkut_get_replace_btn(_("_Replace"));
|
2002-08-14 21:29:09 +02:00
|
|
|
gtk_box_pack_start(GTK_BOX(btn_hbox), subst_btn, FALSE, TRUE, 0);
|
2004-05-25 10:39:41 +02:00
|
|
|
g_signal_connect(G_OBJECT(subst_btn), "clicked",
|
|
|
|
G_CALLBACK(prefs_toolbar_substitute),
|
|
|
|
prefs_toolbar);
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2013-08-14 09:51:16 +02:00
|
|
|
del_btn = gtk_button_new_with_mnemonic (_("Re_move"));
|
|
|
|
gtk_button_set_image(GTK_BUTTON(del_btn),
|
|
|
|
gtk_image_new_from_stock(GTK_STOCK_REMOVE,GTK_ICON_SIZE_BUTTON));
|
2002-08-14 21:29:09 +02:00
|
|
|
gtk_box_pack_start(GTK_BOX(btn_hbox), del_btn, FALSE, TRUE, 0);
|
2004-05-25 10:39:41 +02:00
|
|
|
g_signal_connect(G_OBJECT(del_btn), "clicked",
|
2015-02-19 01:19:01 +01:00
|
|
|
G_CALLBACK(prefs_toolbar_delete),
|
2004-05-25 10:39:41 +02:00
|
|
|
prefs_toolbar);
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2005-12-05 12:03:59 +01:00
|
|
|
default_btn = gtk_button_new_with_label(_(" Use default "));
|
2008-05-07 10:18:24 +02:00
|
|
|
#ifndef GENERIC_UMPC
|
2003-04-18 17:31:31 +02:00
|
|
|
gtk_box_pack_end(GTK_BOX(reg_hbox), default_btn, FALSE, TRUE, 0);
|
2007-03-31 17:45:12 +02:00
|
|
|
#else
|
|
|
|
hbox = gtk_hbox_new(FALSE, 0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), default_btn, FALSE, FALSE, 0);
|
|
|
|
#endif
|
2004-05-25 10:39:41 +02:00
|
|
|
g_signal_connect(G_OBJECT(default_btn), "clicked",
|
2015-02-19 01:19:01 +01:00
|
|
|
G_CALLBACK(prefs_toolbar_default),
|
2004-05-25 10:39:41 +02:00
|
|
|
prefs_toolbar);
|
2003-04-18 17:31:31 +02:00
|
|
|
|
2002-08-06 16:06:40 +02:00
|
|
|
/* currently active toolbar items */
|
2007-10-06 19:34:01 +02:00
|
|
|
vbox_toolbar_items = gtk_vbox_new(FALSE, VBOX_BORDER);
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vbox), vbox_toolbar_items, TRUE, TRUE, 0);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2002-08-14 21:29:09 +02:00
|
|
|
hbox_bottom = gtk_hbox_new(FALSE, 0);
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_container_add(GTK_CONTAINER(vbox_toolbar_items), hbox_bottom);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
scrolledwindow_list_view_set = gtk_scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox_bottom), scrolledwindow_list_view_set, TRUE, TRUE, 0);
|
2015-02-19 01:19:01 +01:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(scrolledwindow_list_view_set), 8);
|
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow_list_view_set),
|
2002-08-06 16:06:40 +02:00
|
|
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
2006-01-13 15:11:22 +01:00
|
|
|
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow_list_view_set),
|
|
|
|
GTK_SHADOW_IN);
|
2002-08-10 20:54:27 +02:00
|
|
|
|
2015-02-19 01:19:01 +01:00
|
|
|
list_view_set = create_set_list_view(prefs_toolbar);
|
2005-01-16 19:18:27 +01:00
|
|
|
gtk_widget_show(list_view_set);
|
|
|
|
gtk_container_add(GTK_CONTAINER(scrolledwindow_list_view_set), list_view_set);
|
2005-05-05 10:18:20 +02:00
|
|
|
gtk_widget_set_size_request(list_view_set, 225, 120);
|
2002-08-14 21:29:09 +02:00
|
|
|
|
2015-02-19 01:19:01 +01:00
|
|
|
btn_vbox = gtk_vbox_new(FALSE, 0);
|
2002-08-14 21:29:09 +02:00
|
|
|
gtk_widget_show(btn_vbox);
|
2015-02-19 01:19:01 +01:00
|
|
|
gtk_box_pack_start(GTK_BOX(hbox_bottom), btn_vbox, FALSE, FALSE, 0);
|
2002-08-14 21:29:09 +02:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
up_btn = gtk_button_new_from_stock(GTK_STOCK_GO_UP);
|
2002-08-14 21:29:09 +02:00
|
|
|
gtk_widget_show(up_btn);
|
2015-02-19 01:19:01 +01:00
|
|
|
gtk_box_pack_start(GTK_BOX(btn_vbox), up_btn, FALSE, FALSE, 4);
|
2002-08-14 21:29:09 +02:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
down_btn = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN);
|
2002-08-14 21:29:09 +02:00
|
|
|
gtk_widget_show(down_btn);
|
|
|
|
gtk_box_pack_start(GTK_BOX(btn_vbox), down_btn, FALSE, FALSE, 0);
|
2015-02-19 01:19:01 +01:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(btn_vbox), 8);
|
2002-08-06 16:06:40 +02:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
g_signal_connect(G_OBJECT(item_type_combo), "changed",
|
|
|
|
G_CALLBACK(item_type_changed), prefs_toolbar);
|
|
|
|
g_signal_connect(G_OBJECT(item_action_combo), "changed",
|
|
|
|
G_CALLBACK(action_selection_changed), prefs_toolbar);
|
2011-02-10 19:36:30 +01:00
|
|
|
g_signal_connect(G_OBJECT(item_plugin_combo), "changed",
|
|
|
|
G_CALLBACK(plugin_selection_changed), prefs_toolbar);
|
2007-10-06 20:32:04 +02:00
|
|
|
g_signal_connect(G_OBJECT(item_func_combo), "changed",
|
|
|
|
G_CALLBACK(func_selection_changed), prefs_toolbar);
|
2004-05-25 10:39:41 +02:00
|
|
|
g_signal_connect(G_OBJECT(up_btn), "clicked",
|
|
|
|
G_CALLBACK(prefs_toolbar_up), prefs_toolbar);
|
|
|
|
g_signal_connect(G_OBJECT(down_btn), "clicked",
|
|
|
|
G_CALLBACK(prefs_toolbar_down), prefs_toolbar);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
gtk_widget_show_all(main_vbox);
|
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
prefs_toolbar->list_view_set = list_view_set;
|
2007-10-06 19:34:01 +02:00
|
|
|
prefs_toolbar->item_text_entry = item_text_entry;
|
|
|
|
prefs_toolbar->item_type_combo = item_type_combo;
|
|
|
|
prefs_toolbar->item_func_combo = item_func_combo;
|
|
|
|
prefs_toolbar->item_action_combo= item_action_combo;
|
2009-11-17 16:15:15 +01:00
|
|
|
prefs_toolbar->item_plugin_combo= item_plugin_combo;
|
2007-10-06 19:34:01 +02:00
|
|
|
prefs_toolbar->icon_button = icon_button;
|
|
|
|
prefs_toolbar->item_icon_file = NULL;
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
prefs_toolbar->page.widget = main_vbox;
|
|
|
|
}
|
|
|
|
|
|
|
|
ToolbarPage *prefs_toolbar_mainwindow;
|
|
|
|
ToolbarPage *prefs_toolbar_composewindow;
|
|
|
|
ToolbarPage *prefs_toolbar_messageview;
|
|
|
|
|
2015-02-19 01:19:01 +01:00
|
|
|
static void toolbar_unregister_plugin_item_real(GHashTable *hash,
|
|
|
|
const gchar *plugin_name,
|
2011-02-10 19:36:30 +01:00
|
|
|
const gchar *item_name)
|
2009-11-17 16:15:15 +01:00
|
|
|
{
|
2011-02-10 19:36:30 +01:00
|
|
|
gchar *key;
|
2009-11-17 16:15:15 +01:00
|
|
|
|
2011-02-10 19:36:30 +01:00
|
|
|
if (!hash)
|
|
|
|
return;
|
2009-11-17 16:15:15 +01:00
|
|
|
|
2011-02-10 19:36:30 +01:00
|
|
|
key = g_strdup_printf(plugin_name, "/", item_name, NULL);
|
|
|
|
g_hash_table_remove(hash, key);
|
|
|
|
g_free(key);
|
2009-11-17 16:15:15 +01:00
|
|
|
}
|
|
|
|
|
2015-02-19 01:19:01 +01:00
|
|
|
void prefs_toolbar_unregister_plugin_item(ToolbarType toolbar_type,
|
|
|
|
const gchar *plugin_name,
|
2011-02-10 19:36:30 +01:00
|
|
|
const gchar *item_name)
|
2009-11-17 16:15:15 +01:00
|
|
|
{
|
2011-02-10 19:36:30 +01:00
|
|
|
GHashTable **hash;
|
|
|
|
hash = get_plugin_hash_from_toolbar_type(toolbar_type);
|
|
|
|
if (hash)
|
|
|
|
toolbar_unregister_plugin_item_real(*hash, plugin_name, item_name);
|
2009-12-19 23:50:46 +01:00
|
|
|
}
|
|
|
|
|
2015-02-19 01:19:01 +01:00
|
|
|
static void prefs_toolbar_execute_plugin_item_real(gpointer parent,
|
2011-02-10 19:36:30 +01:00
|
|
|
GHashTable *hash, const gchar *id)
|
2009-12-19 23:50:46 +01:00
|
|
|
{
|
2011-02-10 19:36:30 +01:00
|
|
|
ToolbarPluginItem *value;
|
|
|
|
GSList *walk;
|
|
|
|
gboolean found;
|
|
|
|
|
|
|
|
if (!hash) {
|
|
|
|
debug_print("No plugin registered toolbar items yet\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
value = g_hash_table_lookup(hash, id);
|
|
|
|
if (!value) {
|
|
|
|
debug_print("Could not find plugin toolbar item with id %s\n", id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if corresponding plugin is currently loaded */
|
|
|
|
found = FALSE;
|
|
|
|
for (walk = plugin_get_list(); walk; walk = walk->next) {
|
|
|
|
const gchar *plugin_name;
|
|
|
|
Plugin *plugin = walk->data;
|
|
|
|
plugin_name = plugin_get_name(plugin);
|
|
|
|
if (!strcmp(plugin_name, value->plugin)) {
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
debug_print("Plugin '%s' is currently not loaded, cannot execute toolbar action\n", value->plugin);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
value->cb(parent, value->item_name, value->cb_data);
|
2009-12-19 23:50:46 +01:00
|
|
|
}
|
|
|
|
|
2015-02-19 01:19:01 +01:00
|
|
|
void prefs_toolbar_execute_plugin_item(gpointer parent,
|
2011-02-10 19:36:30 +01:00
|
|
|
ToolbarType toolbar_type, const gchar *id)
|
2009-12-19 23:50:46 +01:00
|
|
|
{
|
2011-02-10 19:36:30 +01:00
|
|
|
GHashTable **hash;
|
|
|
|
hash = get_plugin_hash_from_toolbar_type(toolbar_type);
|
|
|
|
if (hash)
|
|
|
|
prefs_toolbar_execute_plugin_item_real(parent, *hash, id);
|
2009-11-17 16:15:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void destroy_plugin_item_hash_value(ToolbarPluginItem *item)
|
|
|
|
{
|
|
|
|
g_free(item->plugin);
|
|
|
|
g_free(item->item_name);
|
|
|
|
g_free(item);
|
|
|
|
}
|
|
|
|
|
2015-02-19 01:19:01 +01:00
|
|
|
static void prefs_toolbar_register_plugin_item_real(GHashTable **hash,
|
|
|
|
const gchar *plugin_name,
|
|
|
|
const gchar *item_name,
|
|
|
|
ToolbarPluginCallback cb,
|
2011-02-10 19:36:30 +01:00
|
|
|
gpointer cb_data)
|
2009-11-17 16:15:15 +01:00
|
|
|
{
|
2011-02-10 19:36:30 +01:00
|
|
|
gchar *key;
|
|
|
|
ToolbarPluginItem *value;
|
|
|
|
|
|
|
|
cm_return_if_fail(plugin_name && item_name);
|
|
|
|
|
|
|
|
if (!*hash) {
|
2015-02-19 01:19:01 +01:00
|
|
|
*hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
|
2011-02-10 19:36:30 +01:00
|
|
|
(GDestroyNotify) destroy_plugin_item_hash_value);
|
|
|
|
if (!*hash)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
key = g_strconcat(plugin_name, "/", item_name, NULL);
|
|
|
|
value = g_new0(ToolbarPluginItem, 1);
|
|
|
|
value->plugin = g_strdup(plugin_name);
|
|
|
|
value->item_name = g_strdup(item_name);
|
|
|
|
value->cb = cb;
|
|
|
|
value->cb_data = cb_data;
|
|
|
|
g_hash_table_insert(*hash, key, value);
|
2009-12-19 23:50:46 +01:00
|
|
|
}
|
|
|
|
|
2015-02-19 01:19:01 +01:00
|
|
|
void prefs_toolbar_register_plugin_item(ToolbarType toolbar_type,
|
|
|
|
const gchar *plugin_name,
|
|
|
|
const gchar *item_name,
|
|
|
|
ToolbarPluginCallback cb,
|
2011-02-10 19:36:30 +01:00
|
|
|
gpointer cb_data)
|
2009-12-19 23:50:46 +01:00
|
|
|
{
|
2011-02-10 19:36:30 +01:00
|
|
|
GHashTable **hash;
|
|
|
|
hash = get_plugin_hash_from_toolbar_type(toolbar_type);
|
|
|
|
if(hash)
|
2015-02-19 01:19:01 +01:00
|
|
|
prefs_toolbar_register_plugin_item_real(hash, plugin_name,
|
2011-02-10 19:36:30 +01:00
|
|
|
item_name, cb, cb_data);
|
2009-11-17 16:15:15 +01:00
|
|
|
}
|
|
|
|
|
2003-05-13 13:15:22 +02:00
|
|
|
void prefs_toolbar_init(void)
|
2003-01-12 02:01:26 +01:00
|
|
|
{
|
|
|
|
ToolbarPage *page;
|
2004-08-06 13:34:34 +02:00
|
|
|
static gchar *mainpath[3], *messagepath[3], *composepath[3];
|
|
|
|
|
2008-11-30 05:21:55 +01:00
|
|
|
mainpath[0] = _("Toolbars");
|
2004-08-06 13:34:34 +02:00
|
|
|
mainpath[1] = _("Main Window");
|
|
|
|
mainpath[2] = NULL;
|
2003-01-12 02:01:26 +01:00
|
|
|
|
|
|
|
page = g_new0(ToolbarPage, 1);
|
2004-08-06 13:34:34 +02:00
|
|
|
page->page.path = mainpath;
|
2003-01-12 02:01:26 +01:00
|
|
|
page->page.create_widget = prefs_toolbar_create_widget;
|
|
|
|
page->page.destroy_widget = prefs_toolbar_destroy_widget;
|
|
|
|
page->page.save_page = prefs_toolbar_save;
|
|
|
|
page->source = TOOLBAR_MAIN;
|
2005-05-31 21:00:21 +02:00
|
|
|
page->page.weight = 50.0;
|
2003-01-12 02:01:26 +01:00
|
|
|
prefs_gtk_register_page((PrefsPage *) page);
|
|
|
|
prefs_toolbar_mainwindow = page;
|
|
|
|
|
2008-11-30 05:21:55 +01:00
|
|
|
messagepath[0] = _("Toolbars");
|
2004-08-06 13:34:34 +02:00
|
|
|
messagepath[1] = _("Message Window");
|
|
|
|
messagepath[2] = NULL;
|
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
page = g_new0(ToolbarPage, 1);
|
2004-08-06 13:34:34 +02:00
|
|
|
page->page.path = messagepath;
|
2003-01-12 02:01:26 +01:00
|
|
|
page->page.create_widget = prefs_toolbar_create_widget;
|
|
|
|
page->page.destroy_widget = prefs_toolbar_destroy_widget;
|
|
|
|
page->page.save_page = prefs_toolbar_save;
|
2003-01-16 19:35:59 +01:00
|
|
|
page->source = TOOLBAR_MSGVIEW;
|
2005-05-31 21:00:21 +02:00
|
|
|
page->page.weight = 45.0;
|
2003-01-12 02:01:26 +01:00
|
|
|
prefs_gtk_register_page((PrefsPage *) page);
|
2003-01-16 19:35:59 +01:00
|
|
|
prefs_toolbar_messageview = page;
|
2003-01-12 02:01:26 +01:00
|
|
|
|
2008-11-30 05:21:55 +01:00
|
|
|
composepath[0] = _("Toolbars");
|
2004-08-06 13:34:34 +02:00
|
|
|
composepath[1] = _("Compose Window");
|
|
|
|
composepath[2] = NULL;
|
|
|
|
|
2003-01-12 02:01:26 +01:00
|
|
|
page = g_new0(ToolbarPage, 1);
|
2004-08-06 13:34:34 +02:00
|
|
|
page->page.path = composepath;
|
2003-01-12 02:01:26 +01:00
|
|
|
page->page.create_widget = prefs_toolbar_create_widget;
|
|
|
|
page->page.destroy_widget = prefs_toolbar_destroy_widget;
|
|
|
|
page->page.save_page = prefs_toolbar_save;
|
2003-01-16 19:35:59 +01:00
|
|
|
page->source = TOOLBAR_COMPOSE;
|
2005-05-31 21:00:21 +02:00
|
|
|
page->page.weight = 40.0;
|
2003-01-12 02:01:26 +01:00
|
|
|
prefs_gtk_register_page((PrefsPage *) page);
|
2003-01-16 19:35:59 +01:00
|
|
|
prefs_toolbar_composewindow = page;
|
2003-01-12 02:01:26 +01:00
|
|
|
}
|
|
|
|
|
2003-05-13 13:15:22 +02:00
|
|
|
void prefs_toolbar_done(void)
|
2003-01-12 02:01:26 +01:00
|
|
|
{
|
|
|
|
prefs_gtk_unregister_page((PrefsPage *) prefs_toolbar_mainwindow);
|
2007-10-06 19:34:01 +02:00
|
|
|
g_free(prefs_toolbar_mainwindow->item_icon_file);
|
2003-01-12 02:01:26 +01:00
|
|
|
g_free(prefs_toolbar_mainwindow);
|
|
|
|
prefs_gtk_unregister_page((PrefsPage *) prefs_toolbar_composewindow);
|
2007-10-06 19:34:01 +02:00
|
|
|
g_free(prefs_toolbar_composewindow->item_icon_file);
|
2003-01-12 02:01:26 +01:00
|
|
|
g_free(prefs_toolbar_composewindow);
|
|
|
|
prefs_gtk_unregister_page((PrefsPage *) prefs_toolbar_messageview);
|
2007-10-06 19:34:01 +02:00
|
|
|
g_free(prefs_toolbar_messageview->item_icon_file);
|
2003-01-12 02:01:26 +01:00
|
|
|
g_free(prefs_toolbar_messageview);
|
2002-08-06 16:06:40 +02:00
|
|
|
}
|
2005-01-16 19:18:27 +01:00
|
|
|
|
2015-02-19 01:19:01 +01:00
|
|
|
void prefs_toolbar_update_action_btns(void)
|
2012-02-08 19:46:54 +01:00
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
static void set_visible_if_not_text(GtkTreeViewColumn *col,
|
|
|
|
GtkCellRenderer *renderer,
|
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
gboolean is_text;
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
|
|
|
|
gtk_tree_model_get(model, iter, SET_ICON_IS_TEXT, &is_text, -1);
|
|
|
|
if (is_text) {
|
2015-02-19 01:19:01 +01:00
|
|
|
g_object_set(renderer, "visible", FALSE, NULL);
|
2005-01-16 19:18:27 +01:00
|
|
|
} else {
|
|
|
|
pixbuf = NULL;
|
2015-02-19 01:19:01 +01:00
|
|
|
gtk_tree_model_get(model, iter,
|
2005-01-16 19:18:27 +01:00
|
|
|
SET_ICON, &pixbuf,
|
|
|
|
-1);
|
|
|
|
/* note getting a pixbuf from a tree model increases
|
|
|
|
* its refcount ... */
|
|
|
|
g_object_unref(pixbuf);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
g_object_set(renderer, "visible", TRUE, NULL);
|
|
|
|
g_object_set(renderer, "pixbuf", pixbuf, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *create_set_list_view(ToolbarPage *prefs_toolbar)
|
|
|
|
{
|
|
|
|
GtkTreeView *list_view;
|
|
|
|
GtkListStore *store;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
GtkTreeSelection *selector;
|
|
|
|
|
2015-02-19 01:19:01 +01:00
|
|
|
store = gtk_list_store_new(N_SET_COLUMNS,
|
2005-01-16 19:18:27 +01:00
|
|
|
GDK_TYPE_PIXBUF,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_BOOLEAN,
|
|
|
|
-1);
|
|
|
|
list_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)));
|
|
|
|
g_object_unref(G_OBJECT(store));
|
|
|
|
|
|
|
|
column = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_column_set_title(column, _("Icon"));
|
|
|
|
renderer = gtk_cell_renderer_pixbuf_new();
|
|
|
|
gtk_tree_view_column_pack_start(column, renderer, FALSE);
|
2008-05-22 08:58:47 +02:00
|
|
|
gtk_tree_view_set_reorderable(list_view, TRUE);
|
2015-02-19 01:19:01 +01:00
|
|
|
/* tell pixbuf renderer it is only visible if
|
2005-01-16 19:18:27 +01:00
|
|
|
* the icon is not represented by text */
|
|
|
|
gtk_tree_view_column_set_cell_data_func(column, renderer,
|
|
|
|
set_visible_if_not_text,
|
|
|
|
NULL, NULL);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
gtk_tree_view_column_pack_start(column, renderer, FALSE);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
/* tell the text renderer it is only visible if the icon
|
|
|
|
* is represented by an image */
|
|
|
|
gtk_tree_view_column_set_attributes(column, renderer,
|
|
|
|
"visible", SET_ICON_IS_TEXT,
|
|
|
|
"text", SET_ICON_TEXT,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gtk_tree_view_append_column(list_view, column);
|
|
|
|
|
|
|
|
column = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_column_set_title(column, _("Icon text"));
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
gtk_tree_view_column_pack_start(column, renderer, FALSE);
|
|
|
|
gtk_tree_view_column_set_attributes(column, renderer,
|
|
|
|
"text", SET_TEXT,
|
|
|
|
NULL);
|
|
|
|
gtk_tree_view_append_column(list_view, column);
|
|
|
|
|
|
|
|
column = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_column_set_title(column, _("Mapped event"));
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
gtk_tree_view_column_pack_start(column, renderer, FALSE);
|
|
|
|
gtk_tree_view_column_set_attributes(column, renderer,
|
|
|
|
"text", SET_EVENT,
|
|
|
|
NULL);
|
|
|
|
gtk_tree_view_append_column(list_view, column);
|
|
|
|
|
|
|
|
/* various other tree view attributes */
|
2006-09-06 11:14:40 +02:00
|
|
|
gtk_tree_view_set_rules_hint(list_view, prefs_common.use_stripes_everywhere);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
selector = gtk_tree_view_get_selection(list_view);
|
|
|
|
gtk_tree_selection_set_mode(selector, GTK_SELECTION_BROWSE);
|
|
|
|
gtk_tree_selection_set_select_function
|
|
|
|
(selector, (GtkTreeSelectionFunc) set_list_selected,
|
|
|
|
prefs_toolbar, NULL);
|
|
|
|
|
2015-02-19 01:19:01 +01:00
|
|
|
return GTK_WIDGET(list_view);
|
2005-01-16 19:18:27 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean set_list_selected(GtkTreeSelection *selector,
|
2015-02-19 01:19:01 +01:00
|
|
|
GtkTreeModel *model,
|
2005-01-16 19:18:27 +01:00
|
|
|
GtkTreePath *path,
|
|
|
|
gboolean currently_selected,
|
|
|
|
ToolbarPage *prefs_toolbar)
|
|
|
|
{
|
2007-10-06 19:34:01 +02:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
GtkTreeIter iter;
|
2007-10-06 19:34:01 +02:00
|
|
|
gchar *icon_text, *icon_file, *descr;
|
2005-01-16 19:18:27 +01:00
|
|
|
GList *cur;
|
2007-10-06 19:34:01 +02:00
|
|
|
GSList *cur2;
|
2005-01-16 19:18:27 +01:00
|
|
|
gint item_num;
|
2007-10-06 19:34:01 +02:00
|
|
|
GdkPixbuf *pix;
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2006-02-22 20:25:38 +01:00
|
|
|
if (currently_selected || !gtk_tree_model_get_iter(model, &iter, path))
|
2005-01-16 19:18:27 +01:00
|
|
|
return TRUE;
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
gtk_tree_model_get(model, &iter,
|
2007-10-06 19:34:01 +02:00
|
|
|
SET_ICON, &pix,
|
2005-01-16 19:18:27 +01:00
|
|
|
SET_TEXT, &icon_text,
|
|
|
|
SET_EVENT, &descr,
|
2007-10-06 19:34:01 +02:00
|
|
|
SET_FILENAME, &icon_file,
|
2005-01-16 19:18:27 +01:00
|
|
|
-1);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
g_free(prefs_toolbar->item_icon_file);
|
|
|
|
prefs_toolbar->item_icon_file = icon_file;
|
|
|
|
gtk_button_set_image(GTK_BUTTON(prefs_toolbar->icon_button),
|
|
|
|
gtk_image_new_from_pixbuf(pix));
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
if (g_utf8_collate(toolbar_ret_descr_from_val(A_SEPARATOR), descr) == 0) {
|
|
|
|
gtk_button_set_label(GTK_BUTTON(prefs_toolbar->icon_button),
|
|
|
|
_("None"));
|
2007-10-07 11:43:00 +02:00
|
|
|
g_free(prefs_toolbar->item_icon_file);
|
|
|
|
prefs_toolbar->item_icon_file = NULL;
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(prefs_toolbar->item_type_combo),
|
|
|
|
ITEM_SEPARATOR);
|
|
|
|
g_free(icon_text);
|
|
|
|
g_free(descr);
|
2005-01-16 19:18:27 +01:00
|
|
|
|
2006-02-22 20:25:38 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_button_set_label(GTK_BUTTON(prefs_toolbar->icon_button), "");
|
2015-02-19 01:19:01 +01:00
|
|
|
gtk_entry_set_text(GTK_ENTRY(prefs_toolbar->item_text_entry),
|
2007-10-06 19:34:01 +02:00
|
|
|
icon_text);
|
|
|
|
|
2007-11-07 10:21:19 +01:00
|
|
|
if (g_utf8_collate(toolbar_ret_descr_from_val(A_CLAWS_ACTIONS), descr) == 0) {
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(
|
|
|
|
prefs_toolbar->item_type_combo), ITEM_USER_ACTION);
|
|
|
|
|
|
|
|
for(cur2 = prefs_common.actions_list, item_num = 0; cur2 != NULL;
|
|
|
|
cur2 = cur2->next) {
|
|
|
|
gchar *item_string;
|
|
|
|
get_action_name((gchar *)cur2->data, &item_string);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
if(g_utf8_collate(item_string, icon_text) == 0) {
|
|
|
|
gtk_combo_box_set_active(
|
|
|
|
GTK_COMBO_BOX(prefs_toolbar->item_action_combo),
|
|
|
|
item_num);
|
|
|
|
g_free(item_string);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
item_num++;
|
|
|
|
g_free(item_string);
|
|
|
|
}
|
|
|
|
}
|
2009-11-17 16:15:15 +01:00
|
|
|
|
2007-10-17 16:43:24 +02:00
|
|
|
gtk_widget_show(prefs_toolbar->item_action_combo);
|
|
|
|
gtk_widget_hide(prefs_toolbar->item_func_combo);
|
2009-11-17 16:15:15 +01:00
|
|
|
gtk_widget_hide(prefs_toolbar->item_plugin_combo);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
g_free(icon_text);
|
|
|
|
g_free(descr);
|
2006-02-22 20:25:38 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2009-11-17 16:15:15 +01:00
|
|
|
|
2011-02-10 19:36:30 +01:00
|
|
|
if (g_utf8_collate(toolbar_ret_descr_from_val(A_CLAWS_PLUGINS), descr) == 0) {
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(prefs_toolbar->item_type_combo), ITEM_PLUGIN);
|
2009-11-17 16:15:15 +01:00
|
|
|
|
2011-02-10 19:36:30 +01:00
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(prefs_toolbar->item_plugin_combo), 0);
|
2009-11-17 16:15:15 +01:00
|
|
|
|
2011-02-10 19:36:30 +01:00
|
|
|
gtk_widget_show(prefs_toolbar->item_plugin_combo);
|
|
|
|
gtk_widget_hide(prefs_toolbar->item_func_combo);
|
|
|
|
gtk_widget_hide(prefs_toolbar->item_action_combo);
|
2009-11-17 16:15:15 +01:00
|
|
|
|
2011-02-10 19:36:30 +01:00
|
|
|
g_free(descr);
|
|
|
|
g_free(icon_text);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
/* scan combo list for selected description an set combo item accordingly */
|
2015-02-19 01:19:01 +01:00
|
|
|
for (cur = prefs_toolbar->combo_action_list, item_num = 0; cur != NULL;
|
2005-01-16 19:18:27 +01:00
|
|
|
cur = cur->next) {
|
|
|
|
gchar *item_str = (gchar*)cur->data;
|
|
|
|
if (g_utf8_collate(item_str, descr) == 0) {
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_combo_box_set_active(
|
|
|
|
GTK_COMBO_BOX(prefs_toolbar->item_func_combo),
|
|
|
|
item_num);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2005-01-16 19:18:27 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
item_num++;
|
|
|
|
}
|
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(
|
|
|
|
prefs_toolbar->item_type_combo),ITEM_FUNCTION);
|
2007-10-17 16:43:24 +02:00
|
|
|
gtk_widget_hide(prefs_toolbar->item_action_combo);
|
|
|
|
gtk_widget_show(prefs_toolbar->item_func_combo);
|
2005-01-16 19:18:27 +01:00
|
|
|
|
|
|
|
g_free(icon_text);
|
|
|
|
g_free(descr);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2007-10-06 19:34:01 +02:00
|
|
|
|
|
|
|
static void icon_chooser_ok_clicked(GtkButton *button,
|
|
|
|
ToolbarPage *prefs_toolbar)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
2007-10-08 20:39:29 +02:00
|
|
|
GList *list;
|
2007-10-06 19:34:01 +02:00
|
|
|
GdkPixbuf *pix;
|
|
|
|
gchar *icon_file;
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(prefs_toolbar != NULL);
|
2007-10-08 20:39:29 +02:00
|
|
|
|
|
|
|
model = gtk_icon_view_get_model(GTK_ICON_VIEW(prefs_toolbar->icon_chooser_view));
|
|
|
|
list = gtk_icon_view_get_selected_items(GTK_ICON_VIEW(prefs_toolbar->icon_chooser_view));
|
|
|
|
if(list == NULL)
|
|
|
|
return;
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-08 20:39:29 +02:00
|
|
|
if(!gtk_tree_model_get_iter(model, &iter, (GtkTreePath *)list->data)) {
|
|
|
|
gtk_tree_path_free(list->data);
|
|
|
|
g_list_free(list);
|
2007-10-06 19:34:01 +02:00
|
|
|
return;
|
2007-10-08 20:39:29 +02:00
|
|
|
}
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_tree_model_get(model, &iter,
|
|
|
|
SET_ICON, &pix,
|
|
|
|
SET_FILENAME, &icon_file,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
g_free(prefs_toolbar->item_icon_file);
|
|
|
|
prefs_toolbar->item_icon_file = icon_file;
|
|
|
|
gtk_button_set_image(GTK_BUTTON(prefs_toolbar->icon_button),
|
|
|
|
gtk_image_new_from_pixbuf(pix));
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_widget_destroy(prefs_toolbar->icon_chooser_win);
|
|
|
|
prefs_toolbar->icon_chooser_win = NULL;
|
2007-10-08 20:39:29 +02:00
|
|
|
prefs_toolbar->icon_chooser_view = NULL;
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-08 20:39:29 +02:00
|
|
|
gtk_tree_path_free(list->data);
|
|
|
|
g_list_free(list);
|
2007-10-06 19:34:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void icon_chooser_cancel_clicked(GtkButton *button,
|
|
|
|
ToolbarPage *prefs_toolbar)
|
|
|
|
{
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(prefs_toolbar != NULL);
|
2007-10-06 19:34:01 +02:00
|
|
|
|
|
|
|
gtk_widget_destroy(prefs_toolbar->icon_chooser_win);
|
|
|
|
prefs_toolbar->icon_chooser_win = NULL;
|
2007-10-08 20:39:29 +02:00
|
|
|
prefs_toolbar->icon_chooser_view = NULL;
|
2007-10-06 19:34:01 +02:00
|
|
|
}
|
|
|
|
|
2007-10-07 10:58:46 +02:00
|
|
|
static gboolean icon_chooser_key_pressed(GtkWidget *widget, GdkEventKey *event,
|
|
|
|
ToolbarPage *prefs_toolbar)
|
|
|
|
{
|
2011-10-07 11:17:51 +02:00
|
|
|
if (event && event->keyval == GDK_KEY_Escape) {
|
2007-10-07 10:58:46 +02:00
|
|
|
icon_chooser_cancel_clicked(NULL, prefs_toolbar);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-10-08 20:39:29 +02:00
|
|
|
static gboolean icon_list_key_pressed(GtkWidget *widget, GdkEventKey *event,
|
|
|
|
ToolbarPage *prefs_toolbar)
|
|
|
|
{
|
|
|
|
if (event) {
|
2011-10-07 11:17:51 +02:00
|
|
|
if (event->keyval == GDK_KEY_KP_Enter ||
|
|
|
|
event->keyval == GDK_KEY_Return ||
|
|
|
|
event->keyval == GDK_KEY_space) {
|
2007-10-08 20:39:29 +02:00
|
|
|
icon_chooser_ok_clicked(NULL, prefs_toolbar);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean ok_cb(gpointer data)
|
|
|
|
{
|
|
|
|
ToolbarPage *prefs_toolbar = (ToolbarPage *)data;
|
|
|
|
icon_chooser_ok_clicked(NULL, prefs_toolbar);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean icon_list_button_release(GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
ToolbarPage *prefs_toolbar )
|
|
|
|
{
|
2014-06-06 16:14:26 +02:00
|
|
|
static guint id = 0;
|
|
|
|
if (id > 0) {
|
2007-10-08 20:39:29 +02:00
|
|
|
g_source_remove(id);
|
2014-06-06 16:14:26 +02:00
|
|
|
id = 0;
|
2007-10-08 20:39:29 +02:00
|
|
|
}
|
|
|
|
id = g_timeout_add(100, ok_cb, prefs_toolbar);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean icon_window_button_press(GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
ToolbarPage *prefs_toolbar )
|
|
|
|
{
|
2012-09-12 11:23:13 +02:00
|
|
|
GtkWidget *event_widget;
|
2007-10-08 20:39:29 +02:00
|
|
|
gboolean restore = TRUE;
|
|
|
|
|
|
|
|
/* Test where mouse was clicked */
|
|
|
|
event_widget = gtk_get_event_widget((GdkEvent *)event);
|
|
|
|
if (event_widget != widget) {
|
|
|
|
while (event_widget) {
|
|
|
|
if (event_widget == widget)
|
|
|
|
return FALSE;
|
|
|
|
else if (event_widget == prefs_toolbar->icon_chooser_win) {
|
|
|
|
restore = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2011-10-07 11:08:57 +02:00
|
|
|
event_widget = gtk_widget_get_parent(event_widget);
|
2007-10-08 20:39:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (restore) {
|
|
|
|
icon_chooser_cancel_clicked(NULL, prefs_toolbar);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void icon_chooser_activated(GtkTreeView *treeview, GtkTreePath *path,
|
|
|
|
ToolbarPage *prefs_toolbar)
|
2007-10-07 10:58:46 +02:00
|
|
|
{
|
|
|
|
icon_chooser_ok_clicked(NULL, prefs_toolbar);
|
|
|
|
}
|
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
static void icon_chooser_create(GtkButton *button, ToolbarPage *prefs_toolbar)
|
|
|
|
{
|
2011-10-07 11:08:57 +02:00
|
|
|
GtkAllocation allocation;
|
2007-10-08 20:39:29 +02:00
|
|
|
GtkWidget *icon_chooser_win;
|
2007-10-06 19:34:01 +02:00
|
|
|
GtkWidget *scrollwin;
|
2007-10-08 20:39:29 +02:00
|
|
|
GtkWidget *icon_view;
|
2007-10-06 19:34:01 +02:00
|
|
|
GtkListStore *store;
|
|
|
|
GtkTreeIter iter;
|
2007-10-08 20:39:29 +02:00
|
|
|
gint i, x, y;
|
2015-02-19 01:19:01 +01:00
|
|
|
|
|
|
|
store = gtk_list_store_new(2,
|
2007-10-06 19:34:01 +02:00
|
|
|
GDK_TYPE_PIXBUF,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
-1);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_list_store_clear(store);
|
|
|
|
|
2007-10-07 19:32:13 +02:00
|
|
|
for (i = 0; ToolbarIcons[i] != STOCK_PIXMAP_EMPTY; i++) {
|
2007-10-06 19:34:01 +02:00
|
|
|
GdkPixbuf *pixbuf;
|
2007-10-07 19:32:13 +02:00
|
|
|
stock_pixbuf_gdk(prefs_toolbar->window, ToolbarIcons[i], &pixbuf);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_list_store_append(store, &iter);
|
|
|
|
gtk_list_store_set(store, &iter,
|
|
|
|
SET_ICON, pixbuf,
|
2007-10-07 19:32:13 +02:00
|
|
|
SET_FILENAME, stock_pixmap_get_name((StockPixmap) ToolbarIcons[i]),
|
2007-10-06 19:34:01 +02:00
|
|
|
-1);
|
|
|
|
}
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
icon_chooser_win = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefs_toolbar");
|
|
|
|
gtk_window_set_title(GTK_WINDOW(icon_chooser_win), _("Toolbar item icon"));
|
2007-10-08 20:39:29 +02:00
|
|
|
gtk_window_set_decorated(GTK_WINDOW(icon_chooser_win), FALSE);
|
2011-10-07 11:08:57 +02:00
|
|
|
gdk_window_get_origin(gtk_widget_get_window(
|
2015-02-19 01:19:01 +01:00
|
|
|
GTK_WIDGET(prefs_toolbar->icon_button)),
|
2007-10-08 20:39:29 +02:00
|
|
|
&x, &y);
|
2011-10-07 11:08:57 +02:00
|
|
|
gtk_widget_get_allocation(GTK_WIDGET(prefs_toolbar->icon_button), &allocation);
|
|
|
|
x += allocation.x;
|
|
|
|
y += allocation.y;
|
2007-10-08 20:39:29 +02:00
|
|
|
y += 50;
|
|
|
|
x -= 300-50;
|
|
|
|
gtk_window_move(GTK_WINDOW(icon_chooser_win), x, y);
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_window_set_resizable(GTK_WINDOW(icon_chooser_win), FALSE);
|
2007-10-08 20:50:06 +02:00
|
|
|
gtk_widget_set_size_request(icon_chooser_win, 300, 320);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
scrollwin = gtk_scrolled_window_new(NULL, NULL);
|
2007-10-08 20:39:29 +02:00
|
|
|
gtk_container_add(GTK_CONTAINER(icon_chooser_win), scrollwin);
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_widget_show(scrollwin);
|
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin),
|
2007-10-08 20:39:29 +02:00
|
|
|
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwin),
|
|
|
|
GTK_SHADOW_OUT);
|
2007-10-06 19:34:01 +02:00
|
|
|
|
2007-10-08 20:39:29 +02:00
|
|
|
icon_view = gtk_icon_view_new_with_model(GTK_TREE_MODEL(store));
|
|
|
|
gtk_icon_view_set_selection_mode(GTK_ICON_VIEW(icon_view), GTK_SELECTION_SINGLE);
|
|
|
|
gtk_icon_view_set_pixbuf_column(GTK_ICON_VIEW(icon_view), SET_ICON);
|
|
|
|
gtk_container_add(GTK_CONTAINER(scrollwin), GTK_WIDGET(icon_view));
|
2007-10-06 19:34:01 +02:00
|
|
|
|
2007-10-07 10:58:46 +02:00
|
|
|
g_signal_connect(G_OBJECT(icon_chooser_win), "key_press_event",
|
|
|
|
G_CALLBACK(icon_chooser_key_pressed), prefs_toolbar);
|
2007-10-08 20:39:29 +02:00
|
|
|
g_signal_connect(G_OBJECT(icon_view), "item-activated",
|
|
|
|
G_CALLBACK(icon_chooser_activated), prefs_toolbar);
|
|
|
|
g_signal_connect(G_OBJECT(icon_chooser_win),
|
|
|
|
"button-press-event",
|
|
|
|
G_CALLBACK(icon_window_button_press),
|
|
|
|
prefs_toolbar );
|
|
|
|
g_signal_connect(G_OBJECT(icon_view),
|
|
|
|
"button-release-event",
|
|
|
|
G_CALLBACK(icon_list_button_release),
|
|
|
|
prefs_toolbar );
|
|
|
|
g_signal_connect(G_OBJECT(icon_view), "key_press_event",
|
|
|
|
G_CALLBACK(icon_list_key_pressed), prefs_toolbar);
|
2007-10-07 10:58:46 +02:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_widget_show_all(icon_chooser_win);
|
2007-10-08 20:39:29 +02:00
|
|
|
gtk_widget_grab_focus(GTK_WIDGET(icon_view));
|
2015-07-10 11:15:11 +02:00
|
|
|
manage_window_set_transient(GTK_WINDOW(icon_chooser_win));
|
2007-10-06 19:34:01 +02:00
|
|
|
gtk_window_set_modal(GTK_WINDOW(icon_chooser_win), TRUE);
|
2015-02-19 01:19:01 +01:00
|
|
|
|
2007-10-06 19:34:01 +02:00
|
|
|
prefs_toolbar->icon_chooser_win = icon_chooser_win;
|
2007-10-08 20:39:29 +02:00
|
|
|
prefs_toolbar->icon_chooser_view = icon_view;
|
2007-10-06 19:34:01 +02:00
|
|
|
}
|