* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "main.h"
#include "bar-keywords.h"
+#include <cstdio>
+#include <cstring>
+
+#include <gdk/gdk.h>
+#include <glib-object.h>
+
+#include "bar.h"
+#include "compat.h"
+#include "debug.h"
+#include "dnd.h"
#include "filedata.h"
+#include "intl.h"
+#include "layout.h"
+#include "main-defines.h"
#include "metadata.h"
+#include "misc.h"
+#include "options.h"
+#include "rcfile.h"
+#include "secure-save.h"
+#include "typedefs.h"
#include "ui-fileops.h"
+#include "ui-menu.h"
#include "ui-misc.h"
#include "ui-utildlg.h"
-#include "bar.h"
-#include "ui-menu.h"
-#include "rcfile.h"
-#include "layout.h"
-#include "dnd.h"
-#include "secure-save.h"
-static void bar_pane_keywords_changed(GtkTextBuffer *buffer, gpointer data);
+namespace
+{
+
+GtkListStore *keyword_store = nullptr;
-static void autocomplete_keywords_list_load(const gchar *path);
-static GtkListStore *keyword_store = nullptr;
-static gboolean autocomplete_keywords_list_save(gchar *path);
-static gboolean autocomplete_activate_cb(GtkWidget *widget, gpointer data);
+void bar_pane_keywords_changed(GtkTextBuffer *buffer, gpointer data);
+
+void autocomplete_keywords_list_load(const gchar *path);
+gboolean autocomplete_keywords_list_save(gchar *path);
+gboolean autocomplete_activate_cb(GtkWidget *widget, gpointer data);
/*
*-------------------------------------------------------------------
*-------------------------------------------------------------------
*/
-
-GList *keyword_list_pull(GtkWidget *text_widget)
-{
- GList *list;
- gchar *text;
-
- text = text_widget_text_pull(text_widget);
- list = string_to_keywords_list(text);
-
- g_free(text);
-
- return list;
-}
-
-static GList *keyword_list_pull_selected(GtkWidget *text_widget)
+GList *keyword_list_pull_selected(GtkWidget *text_widget)
{
GList *list;
gchar *text;
}
/* the "changed" signal should be blocked before calling this */
-static void keyword_list_push(GtkWidget *textview, GList *list)
+void keyword_list_push(GtkWidget *textview, GList *list)
{
GtkTextBuffer *buffer;
- GtkTextIter start, end;
+ GtkTextIter start;
+ GtkTextIter end;
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
gtk_text_buffer_get_bounds(buffer, &start, &end);
FILTER_KEYWORD_COLUMN_COUNT
};
-static GType filter_keyword_column_types[] = {G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN};
+GType filter_keyword_column_types[] = {G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN};
struct PaneKeywordsData
{
};
-static void bar_pane_keywords_write(PaneKeywordsData *pkd)
+void bar_pane_keywords_write(PaneKeywordsData *pkd)
{
GList *list;
return FALSE;
}
-static void bar_keyword_tree_sync(PaneKeywordsData *pkd)
+void bar_keyword_tree_sync(PaneKeywordsData *pkd)
{
GtkTreeModel *model;
if (pkd->collapse_unchecked) gtk_tree_model_foreach(model, bar_keyword_tree_collapse_if_unset_cb, pkd);
}
-static void bar_pane_keywords_update(PaneKeywordsData *pkd)
+void bar_pane_keywords_update(PaneKeywordsData *pkd)
{
GList *keywords = nullptr;
GList *orig_keywords = nullptr;
- GList *work1, *work2;
+ GList *work1;
+ GList *work2;
GtkTextBuffer *keyword_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pkd->keyword_view));
keywords = metadata_read_list(pkd->fd, KEYWORD_KEY, METADATA_PLAIN);
g_free(path_string);
}
-static void bar_pane_keywords_entry_write_config(gchar *entry, GString *outstr, gint indent)
+void bar_pane_keywords_entry_write_config(gchar *entry, GString *outstr, gint indent)
{
struct {
gchar *path;
WRITE_STRING("/>");
}
-static void bar_pane_keywords_write_config(GtkWidget *pane, GString *outstr, gint indent)
+void bar_pane_keywords_write_config(GtkWidget *pane, GString *outstr, gint indent)
{
PaneKeywordsData *pkd;
GList *path_expanded = nullptr;
- gint w, h;
+ gint w;
+ gint h;
pkd = static_cast<PaneKeywordsData *>(g_object_get_data(G_OBJECT(pane), "pane_data"));
if (!pkd) return;
return FALSE;
}
-static void bar_pane_keywords_keyword_toggle(GtkCellRendererToggle *, const gchar *path, gpointer data)
+void bar_pane_keywords_keyword_toggle(GtkCellRendererToggle *, const gchar *path, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
GtkTreeModel *model;
return !keyword_is_hidden_in(keyword_tree, iter, filter);
}
-static void bar_pane_keywords_set_selection(PaneKeywordsData *pkd, gboolean append)
+void bar_pane_keywords_set_selection(PaneKeywordsData *pkd, gboolean append)
{
GList *keywords = nullptr;
GList *list = nullptr;
g_list_free_full(keywords, g_free);
}
-static void bar_pane_keywords_sel_add_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_sel_add_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
bar_pane_keywords_set_selection(pkd, TRUE);
}
-static void bar_pane_keywords_sel_replace_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_sel_replace_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
bar_pane_keywords_set_selection(pkd, FALSE);
}
-static void bar_pane_keywords_populate_popup_cb(GtkTextView *, GtkMenu *menu, gpointer data)
+void bar_pane_keywords_populate_popup_cb(GtkTextView *, GtkMenu *menu, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
}
-static void bar_pane_keywords_notify_cb(FileData *fd, NotifyType type, gpointer data)
+void bar_pane_keywords_notify_cb(FileData *fd, NotifyType type, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE | NOTIFY_METADATA)) && fd == pkd->fd)
}
}
-static gboolean bar_pane_keywords_changed_idle_cb(gpointer data)
+gboolean bar_pane_keywords_changed_idle_cb(gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
return G_SOURCE_REMOVE;
}
-static void bar_pane_keywords_changed(GtkTextBuffer *, gpointer data)
+void bar_pane_keywords_changed(GtkTextBuffer *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
*-------------------------------------------------------------------
*/
-
-static GtkTargetEntry bar_pane_keywords_drag_types[] = {
+// @todo Use std::array
+constexpr GtkTargetEntry bar_pane_keywords_drag_types[] = {
{ const_cast<gchar *>(TARGET_APP_KEYWORD_PATH_STRING), GTK_TARGET_SAME_WIDGET, TARGET_APP_KEYWORD_PATH },
{ const_cast<gchar *>("text/plain"), 0, TARGET_TEXT_PLAIN }
};
-static gint n_keywords_drag_types = 2;
-
+constexpr gint n_keywords_drag_types = 2;
-static GtkTargetEntry bar_pane_keywords_drop_types[] = {
+// @todo Use std::array
+constexpr GtkTargetEntry bar_pane_keywords_drop_types[] = {
{ const_cast<gchar *>(TARGET_APP_KEYWORD_PATH_STRING), GTK_TARGET_SAME_WIDGET, TARGET_APP_KEYWORD_PATH },
{ const_cast<gchar *>("text/plain"), 0, TARGET_TEXT_PLAIN }
};
-static gint n_keywords_drop_types = 2;
+constexpr gint n_keywords_drop_types = 2;
-static void bar_pane_keywords_dnd_get(GtkWidget *tree_view, GdkDragContext *,
+void bar_pane_keywords_dnd_get(GtkWidget *tree_view, GdkDragContext *,
GtkSelectionData *selection_data, guint info,
guint, gpointer)
{
}
}
-static void bar_pane_keywords_dnd_begin(GtkWidget *tree_view, GdkDragContext *context, gpointer)
+void bar_pane_keywords_dnd_begin(GtkWidget *tree_view, GdkDragContext *context, gpointer)
{
GtkTreeIter iter;
GtkTreeModel *model;
}
-static void bar_pane_keywords_dnd_end(GtkWidget *, GdkDragContext *, gpointer)
+void bar_pane_keywords_dnd_end(GtkWidget *, GdkDragContext *, gpointer)
{
}
-static gboolean bar_pane_keywords_dnd_can_move(GtkTreeModel *keyword_tree, GtkTreeIter *src_kw_iter, GtkTreeIter *dest_kw_iter)
+gboolean bar_pane_keywords_dnd_can_move(GtkTreeModel *keyword_tree, GtkTreeIter *src_kw_iter, GtkTreeIter *dest_kw_iter)
{
gchar *src_name;
GtkTreeIter parent;
return TRUE;
}
-static gboolean bar_pane_keywords_dnd_skip_existing(GtkTreeModel *keyword_tree, GtkTreeIter *dest_kw_iter, GList **keywords)
+gboolean bar_pane_keywords_dnd_skip_existing(GtkTreeModel *keyword_tree, GtkTreeIter *dest_kw_iter, GList **keywords)
{
/* we have to find at least one keyword that does not already exist as a sibling of dest_kw_iter */
GList *work = *keywords;
return !!*keywords;
}
-static void bar_pane_keywords_dnd_receive(GtkWidget *tree_view, GdkDragContext *,
+void bar_pane_keywords_dnd_receive(GtkWidget *tree_view, GdkDragContext *,
gint x, gint y,
GtkSelectionData *selection_data, guint info,
guint, gpointer data)
bar_keyword_tree_sync(pkd);
}
-static gint bar_pane_keywords_dnd_motion(GtkWidget *tree_view, GdkDragContext *context,
+gint bar_pane_keywords_dnd_motion(GtkWidget *tree_view, GdkDragContext *context,
gint x, gint y, guint time, gpointer)
{
GtkTreePath *tpath = nullptr;
*-------------------------------------------------------------------
*/
-static void bar_pane_keywords_edit_destroy_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_edit_destroy_cb(GtkWidget *, gpointer data)
{
auto cdd = static_cast<ConfDialogData *>(data);
gtk_tree_path_free(cdd->click_tpath);
}
-static void bar_pane_keywords_edit_cancel_cb(GenericDialog *, gpointer)
+void bar_pane_keywords_edit_cancel_cb(GenericDialog *, gpointer)
{
}
-static void bar_pane_keywords_edit_ok_cb(GenericDialog *, gpointer data)
+void bar_pane_keywords_edit_ok_cb(GenericDialog *, gpointer data)
{
auto cdd = static_cast<ConfDialogData *>(data);
PaneKeywordsData *pkd = cdd->pkd;
g_list_free_full(keywords, g_free);
}
-static void bar_pane_keywords_conf_set_helper(GtkWidget *, gpointer data)
+void bar_pane_keywords_conf_set_helper(GtkWidget *, gpointer data)
{
auto cdd = static_cast<ConfDialogData *>(data);
cdd->is_keyword = FALSE;
}
-static void bar_pane_keywords_conf_set_kw(GtkWidget *, gpointer data)
+void bar_pane_keywords_conf_set_kw(GtkWidget *, gpointer data)
{
auto cdd = static_cast<ConfDialogData *>(data);
cdd->is_keyword = TRUE;
-static void bar_pane_keywords_edit_dialog(PaneKeywordsData *pkd, gboolean edit_existing)
+void bar_pane_keywords_edit_dialog(PaneKeywordsData *pkd, gboolean edit_existing)
{
ConfDialogData *cdd;
GenericDialog *gd;
gboolean is_keyword = TRUE;
- if (edit_existing && pkd->click_tpath)
+ if (edit_existing && pkd->click_tpath)
{
GtkTreeModel *model;
GtkTreeIter iter;
model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
- if (gtk_tree_model_get_iter(model, &iter, pkd->click_tpath))
+ if (gtk_tree_model_get_iter(model, &iter, pkd->click_tpath))
{
gtk_tree_model_get(model, &iter, FILTER_KEYWORD_COLUMN_NAME, &name,
FILTER_KEYWORD_COLUMN_IS_KEYWORD, &is_keyword, -1);
pref_table_label(table, 0, 0, _("Keyword:"), GTK_ALIGN_END);
cdd->edit_widget = gtk_entry_new();
gtk_widget_set_size_request(cdd->edit_widget, 300, -1);
- if (name) gtk_entry_set_text(GTK_ENTRY(cdd->edit_widget), name);
- gtk_table_attach_defaults(GTK_TABLE(table), cdd->edit_widget, 1, 2, 0, 1);
+ if (name) gq_gtk_entry_set_text(GTK_ENTRY(cdd->edit_widget), name);
+ gq_gtk_grid_attach_default(GTK_GRID(table), cdd->edit_widget, 1, 2, 0, 1);
/* here could eventually be a text view instead of entry */
generic_dialog_attach_default(gd, cdd->edit_widget);
gtk_widget_show(cdd->edit_widget);
}
-
-
/*
*-------------------------------------------------------------------
* popup menu
*-------------------------------------------------------------------
*/
-static void bar_pane_keywords_edit_dialog_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_edit_dialog_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
bar_pane_keywords_edit_dialog(pkd, TRUE);
}
-static void bar_pane_keywords_add_dialog_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_add_dialog_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
bar_pane_keywords_edit_dialog(pkd, FALSE);
}
-static void bar_pane_keywords_connect_mark_cb(GtkWidget *menu_widget, gpointer data)
+void bar_pane_keywords_connect_mark_cb(GtkWidget *menu_widget, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
meta_data_connect_mark_with_keyword(keyword_tree, &kw_iter, mark);
}
-static void bar_pane_keywords_disconnect_marks_ok_cb(GenericDialog *, gpointer)
+void bar_pane_keywords_disconnect_marks_ok_cb(GenericDialog *, gpointer)
{
keyword_tree_disconnect_marks();
}
-static void dummy_cancel_cb(GenericDialog *, gpointer)
+void dummy_cancel_cb(GenericDialog *, gpointer)
{
/* no op, only so cancel button appears */
}
-static void bar_pane_keywords_disconnect_marks_cb(GtkWidget *menu_widget, gpointer data)
+void bar_pane_keywords_disconnect_marks_cb(GtkWidget *menu_widget, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
GenericDialog *gd;
- GString *message = g_string_new("");
-
- message = g_string_append(message, _("This will disconnect all Marks Keywords connections"));
gd = generic_dialog_new(_("Marks Keywords"),
"marks_keywords", menu_widget, TRUE, dummy_cancel_cb, pkd);
generic_dialog_add_message(gd, GQ_ICON_DIALOG_WARNING,
- "Disconnect all Marks Keywords connections?", message->str, TRUE);
+ _("Disconnect all Marks Keywords connections?"), _("This will disconnect all Marks Keywords connections"), TRUE);
generic_dialog_add_button(gd, GQ_ICON_OK, "OK", bar_pane_keywords_disconnect_marks_ok_cb, TRUE);
gtk_widget_show(gd->dialog);
-
- g_string_free(message, TRUE);
}
-static void bar_pane_keywords_delete_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_delete_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
GtkTreeModel *model;
keyword_delete(GTK_TREE_STORE(keyword_tree), &kw_iter);
}
-static void bar_pane_keywords_hide_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_hide_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
GtkTreeModel *model;
keyword_hide_in(GTK_TREE_STORE(keyword_tree), &kw_iter, model);
}
-static void bar_pane_keywords_show_all_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_show_all_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
GtkTreeModel *model;
bar_keyword_tree_sync(pkd);
}
-static void bar_pane_keywords_revert_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_revert_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
GList *work;
bar_keyword_tree_sync(pkd);
}
-static void bar_pane_keywords_expand_checked_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_expand_checked_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
GtkTreeModel *model;
gtk_tree_model_foreach(model, bar_keyword_tree_expand_if_set_cb, pkd);
}
-static void bar_pane_keywords_collapse_all_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_collapse_all_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
bar_keyword_tree_sync(pkd);
}
-static void bar_pane_keywords_revert_hidden_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_revert_hidden_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
GtkTreeModel *model;
bar_keyword_tree_sync(pkd);
}
-static void bar_pane_keywords_collapse_unchecked_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_collapse_unchecked_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
GtkTreeModel *model;
gtk_tree_model_foreach(model, bar_keyword_tree_collapse_if_unset_cb, pkd);
}
-static void bar_pane_keywords_hide_unchecked_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_hide_unchecked_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
GtkTreeModel *model;
bar_keyword_tree_sync(pkd);
}
-static void bar_pane_keywords_expand_checked_toggle_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_expand_checked_toggle_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
pkd->expand_checked = !pkd->expand_checked;
bar_keyword_tree_sync(pkd);
}
-static void bar_pane_keywords_collapse_unchecked_toggle_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_collapse_unchecked_toggle_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
pkd->collapse_unchecked = !pkd->collapse_unchecked;
bar_keyword_tree_sync(pkd);
}
-static void bar_pane_keywords_hide_unchecked_toggle_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_hide_unchecked_toggle_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
pkd->hide_unchecked = !pkd->hide_unchecked;
/**
* @brief Callback for adding selected keyword to all selected images.
*/
-static void bar_pane_keywords_add_to_selected_cb(GtkWidget *, gpointer data)
+void bar_pane_keywords_add_to_selected_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
GtkTreeIter iter; /* This is the iter which initial holds the current keyword */
GtkTreeIter child_iter;
GtkTreeModel *model;
GtkTreeModel *keyword_tree;
- GList *list, *work;
+ GList *list;
+ GList *work;
GList *keywords = nullptr;
GtkTextBuffer *keyword_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pkd->keyword_view));
g_list_free_full(keywords, g_free);
}
-static void bar_pane_keywords_menu_popup(GtkWidget *, PaneKeywordsData *pkd, gint x, gint y)
+void bar_pane_keywords_menu_popup(GtkWidget *, PaneKeywordsData *pkd, gint x, gint y)
{
GtkWidget *menu;
GtkWidget *item;
gtk_menu_popup_at_pointer(GTK_MENU(menu), nullptr);
}
-
-static gboolean bar_pane_keywords_menu_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
+gboolean bar_pane_keywords_menu_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
if (bevent->button == MOUSE_BUTTON_RIGHT)
*-------------------------------------------------------------------
*/
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-function"
-void bar_pane_keywords_close_unused(GtkWidget *bar)
-{
- PaneKeywordsData *pkd;
-
- pkd = static_cast<PaneKeywordsData *>(g_object_get_data(G_OBJECT(bar), "pane_data"));
- if (!pkd) return;
-
- g_free(pkd->pane.id);
- gtk_widget_destroy(pkd->widget);
-}
-#pragma GCC diagnostic pop
-
-static void bar_pane_keywords_destroy(GtkWidget *, gpointer data)
+void bar_pane_keywords_destroy(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
gchar *path;
}
-static GtkWidget *bar_pane_keywords_new(const gchar *id, const gchar *title, const gchar *key, gboolean expanded, gint height)
+GtkWidget *bar_pane_keywords_new(const gchar *id, const gchar *title, const gchar *key, gboolean expanded, gint height)
{
PaneKeywordsData *pkd;
- GtkWidget *hbox, *vbox;
+ GtkWidget *hbox;
+ GtkWidget *vbox;
GtkWidget *scrolled;
GtkTextBuffer *buffer;
GtkTreeModel *store;
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP);
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
pkd->widget = vbox;
g_object_set_data(G_OBJECT(pkd->widget), "pane_data", pkd);
gtk_widget_set_size_request(pkd->widget, -1, height);
gtk_widget_show(hbox);
- scrolled = gtk_scrolled_window_new(nullptr, nullptr);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
+ scrolled = gq_gtk_scrolled_window_new(nullptr, nullptr);
+ gq_gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0);
gtk_widget_show(scrolled);
pkd->keyword_view = gtk_text_view_new();
- gtk_container_add(GTK_CONTAINER(scrolled), pkd->keyword_view);
+ gq_gtk_container_add(GTK_WIDGET(scrolled), pkd->keyword_view);
g_signal_connect(G_OBJECT(pkd->keyword_view), "populate-popup",
G_CALLBACK(bar_pane_keywords_populate_popup_cb), pkd);
gtk_widget_show(pkd->keyword_view);
if (options->show_predefined_keyword_tree)
{
- scrolled = gtk_scrolled_window_new(nullptr, nullptr);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
+ scrolled = gq_gtk_scrolled_window_new(nullptr, nullptr);
+ gq_gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0);
gtk_widget_show(scrolled);
}
pkd->autocomplete = gtk_entry_new();
- gtk_box_pack_end(GTK_BOX(vbox), pkd->autocomplete, FALSE, FALSE, 0);
+ gq_gtk_box_pack_end(GTK_BOX(vbox), pkd->autocomplete, FALSE, FALSE, 0);
gtk_widget_show(pkd->autocomplete);
gtk_widget_show(vbox);
- gtk_widget_set_tooltip_text(pkd->autocomplete, "Keyword autocomplete");
+ gtk_widget_set_tooltip_text(pkd->autocomplete, _("Keyword autocomplete"));
path = g_build_filename(get_rc_dir(), "keywords", NULL);
autocomplete_keywords_list_load(path);
if (options->show_predefined_keyword_tree)
{
- gtk_container_add(GTK_CONTAINER(scrolled), pkd->keyword_treeview);
+ gq_gtk_container_add(GTK_WIDGET(scrolled), pkd->keyword_treeview);
gtk_widget_show(pkd->keyword_treeview);
}
return pkd->widget;
}
-GtkWidget *bar_pane_keywords_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
-{
- gchar *id = g_strdup("keywords");
- gchar *title = nullptr;
- gchar *key = g_strdup(COMMENT_KEY);
- gboolean expanded = TRUE;
- gint height = 200;
- GtkWidget *ret;
-
- while (*attribute_names)
- {
- const gchar *option = *attribute_names++;
- const gchar *value = *attribute_values++;
-
- if (READ_CHAR_FULL("id", id)) continue;
- if (READ_CHAR_FULL("title", title)) continue;
- if (READ_CHAR_FULL("key", key)) continue;
- if (READ_BOOL_FULL("expanded", expanded)) continue;
- if (READ_INT_FULL("height", height)) continue;
-
-
- log_printf("unknown attribute %s = %s\n", option, value);
- }
-
- options->info_keywords.height = height;
- bar_pane_translate_title(PANE_KEYWORDS, id, &title);
- ret = bar_pane_keywords_new(id, title, key, expanded, height);
- g_free(id);
- g_free(title);
- g_free(key);
- return ret;
-}
-
-void bar_pane_keywords_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values)
-{
- PaneKeywordsData *pkd;
-
- pkd = static_cast<PaneKeywordsData *>(g_object_get_data(G_OBJECT(pane), "pane_data"));
- if (!pkd) return;
-
- gchar *title = nullptr;
-
- while (*attribute_names)
- {
- const gchar *option = *attribute_names++;
- const gchar *value = *attribute_values++;
-
- if (READ_CHAR_FULL("title", title)) continue;
- if (READ_CHAR_FULL("key", pkd->key)) continue;
- if (READ_BOOL_FULL("expanded", pkd->pane.expanded)) continue;
- if (READ_CHAR_FULL("id", pkd->pane.id)) continue;
-
-
- log_printf("unknown attribute %s = %s\n", option, value);
- }
-
- if (title)
- {
- bar_pane_translate_title(PANE_KEYWORDS, pkd->pane.id, &title);
- gtk_label_set_text(GTK_LABEL(pkd->pane.title), title);
- g_free(title);
- }
-
- bar_update_expander(pane);
- bar_pane_keywords_update(pkd);
-}
-
-
-void bar_pane_keywords_entry_add_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values)
-{
- PaneKeywordsData *pkd;
- gchar *path = nullptr;
- GtkTreePath *tree_path;
-
- pkd = static_cast<PaneKeywordsData *>(g_object_get_data(G_OBJECT(pane), "pane_data"));
- if (!pkd) return;
-
- while (*attribute_names)
- {
- const gchar *option = *attribute_names++;
- const gchar *value = *attribute_values++;
-
- if (READ_CHAR_FULL("path", path))
- {
- tree_path = gtk_tree_path_new_from_string(path);
- gtk_tree_view_expand_to_path(GTK_TREE_VIEW(pkd->keyword_treeview), tree_path);
- gtk_tree_path_free(tree_path);
- pkd->expanded_rows = g_list_append(pkd->expanded_rows, g_strdup(path));
- continue;
- }
- log_printf("unknown attribute %s = %s\n", option, value);
- }
-}
-
/*
*-----------------------------------------------------------------------------
* Autocomplete keywords
*-----------------------------------------------------------------------------
*/
-static gboolean autocomplete_activate_cb(GtkWidget *, gpointer data)
+gboolean autocomplete_activate_cb(GtkWidget *, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
gchar *entry_text;
gboolean found = FALSE;
gchar *string;
- entry_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(pkd->autocomplete)));
+ entry_text = g_strdup(gq_gtk_entry_get_text(GTK_ENTRY(pkd->autocomplete)));
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pkd->keyword_view));
kw_split = strtok(entry_text, ",");
}
g_free(entry_text);
- entry_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(pkd->autocomplete)));
+ entry_text = g_strdup(gq_gtk_entry_get_text(GTK_ENTRY(pkd->autocomplete)));
- gtk_entry_set_text(GTK_ENTRY(pkd->autocomplete), "");
+ gq_gtk_entry_set_text(GTK_ENTRY(pkd->autocomplete), "");
valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(keyword_store), &iter_t);
while (valid)
gpointer)
{
gint ret = 0;
- gchar *name1, *name2;
+ gchar *name1;
+ gchar *name2;
gtk_tree_model_get(model, a, 0, &name1, -1);
gtk_tree_model_get(model, b, 0, &name2, -1);
return ret;
}
-static void autocomplete_keywords_list_load(const gchar *path)
+void autocomplete_keywords_list_load(const gchar *path)
{
FILE *f;
gchar s_buf[1024];
fclose(f);
}
-static gboolean autocomplete_keywords_list_save(gchar *path)
+gboolean autocomplete_keywords_list_save(gchar *path)
{
SecureSaveInfo *ssi;
gchar *pathl;
return (secure_close(ssi) == 0);
}
+} // namespace
+
+/*
+ *-------------------------------------------------------------------
+ * init
+ *-------------------------------------------------------------------
+ */
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-function"
+void bar_pane_keywords_close_unused(GtkWidget *bar)
+{
+ PaneKeywordsData *pkd;
+
+ pkd = static_cast<PaneKeywordsData *>(g_object_get_data(G_OBJECT(bar), "pane_data"));
+ if (!pkd) return;
+
+ g_free(pkd->pane.id);
+ g_object_unref(pkd->widget);
+}
+#pragma GCC diagnostic pop
+
+GtkWidget *bar_pane_keywords_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
+{
+ gchar *id = g_strdup("keywords");
+ gchar *title = nullptr;
+ gchar *key = g_strdup(COMMENT_KEY);
+ gboolean expanded = TRUE;
+ gint height = 200;
+ GtkWidget *ret;
+
+ while (*attribute_names)
+ {
+ const gchar *option = *attribute_names++;
+ const gchar *value = *attribute_values++;
+
+ if (READ_CHAR_FULL("id", id)) continue;
+ if (READ_CHAR_FULL("title", title)) continue;
+ if (READ_CHAR_FULL("key", key)) continue;
+ if (READ_BOOL_FULL("expanded", expanded)) continue;
+ if (READ_INT_FULL("height", height)) continue;
+
+
+ log_printf("unknown attribute %s = %s\n", option, value);
+ }
+
+ options->info_keywords.height = height;
+ bar_pane_translate_title(PANE_KEYWORDS, id, &title);
+ ret = bar_pane_keywords_new(id, title, key, expanded, height);
+ g_free(id);
+ g_free(title);
+ g_free(key);
+ return ret;
+}
+
+void bar_pane_keywords_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values)
+{
+ PaneKeywordsData *pkd;
+
+ pkd = static_cast<PaneKeywordsData *>(g_object_get_data(G_OBJECT(pane), "pane_data"));
+ if (!pkd) return;
+
+ gchar *title = nullptr;
+
+ while (*attribute_names)
+ {
+ const gchar *option = *attribute_names++;
+ const gchar *value = *attribute_values++;
+
+ if (READ_CHAR_FULL("title", title)) continue;
+ if (READ_CHAR_FULL("key", pkd->key)) continue;
+ if (READ_BOOL_FULL("expanded", pkd->pane.expanded)) continue;
+ if (READ_CHAR_FULL("id", pkd->pane.id)) continue;
+
+
+ log_printf("unknown attribute %s = %s\n", option, value);
+ }
+
+ if (title)
+ {
+ bar_pane_translate_title(PANE_KEYWORDS, pkd->pane.id, &title);
+ gtk_label_set_text(GTK_LABEL(pkd->pane.title), title);
+ g_free(title);
+ }
+
+ bar_update_expander(pane);
+ bar_pane_keywords_update(pkd);
+}
+
+
+void bar_pane_keywords_entry_add_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values)
+{
+ PaneKeywordsData *pkd;
+ gchar *path = nullptr;
+ GtkTreePath *tree_path;
+
+ pkd = static_cast<PaneKeywordsData *>(g_object_get_data(G_OBJECT(pane), "pane_data"));
+ if (!pkd) return;
+
+ while (*attribute_names)
+ {
+ const gchar *option = *attribute_names++;
+ const gchar *value = *attribute_values++;
+
+ if (READ_CHAR_FULL("path", path))
+ {
+ tree_path = gtk_tree_path_new_from_string(path);
+ gtk_tree_view_expand_to_path(GTK_TREE_VIEW(pkd->keyword_treeview), tree_path);
+ gtk_tree_path_free(tree_path);
+ pkd->expanded_rows = g_list_append(pkd->expanded_rows, g_strdup(path));
+ continue;
+ }
+ log_printf("unknown attribute %s = %s\n", option, value);
+ }
+}
+
+/*
+ *-------------------------------------------------------------------
+ * keyword / comment utils
+ *-------------------------------------------------------------------
+ */
+
+GList *keyword_list_pull(GtkWidget *text_widget)
+{
+ GList *list;
+ gchar *text;
+
+ text = text_widget_text_pull(text_widget);
+ list = string_to_keywords_list(text);
+
+ g_free(text);
+
+ return list;
+}
+
GList *keyword_list_get()
{
GList *ret_list = nullptr;