#include "ui-misc.h"
#include "ui-utildlg.h"
-static void bar_pane_keywords_changed(GtkTextBuffer *buffer, gpointer data);
+namespace
+{
+
+GtkListStore *keyword_store = nullptr;
+
+void bar_pane_keywords_changed(GtkTextBuffer *buffer, gpointer data);
-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 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;
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;
g_list_free_full(list, g_free);
}
-static gboolean bar_keyword_tree_expand_if_set_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+gboolean bar_keyword_tree_expand_if_set_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
gboolean set;
return FALSE;
}
-static gboolean bar_keyword_tree_collapse_if_unset_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+gboolean bar_keyword_tree_collapse_if_unset_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
gboolean set;
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;
g_list_free_full(orig_keywords, g_free);
}
-static void bar_pane_keywords_set_fd(GtkWidget *pane, FileData *fd)
+void bar_pane_keywords_set_fd(GtkWidget *pane, FileData *fd)
{
PaneKeywordsData *pkd;
bar_pane_keywords_update(pkd);
}
-static void bar_keyword_tree_get_expanded_cb(GtkTreeView *keyword_treeview, GtkTreePath *path, gpointer data)
+void bar_keyword_tree_get_expanded_cb(GtkTreeView *keyword_treeview, GtkTreePath *path, gpointer data)
{
auto expanded = static_cast<GList **>(data);
GtkTreeModel *model;
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;
WRITE_STRING("</pane_keywords>");
}
-static gint bar_pane_keywords_event(GtkWidget *bar, GdkEvent *event)
+gint bar_pane_keywords_event(GtkWidget *bar, GdkEvent *event)
{
PaneKeywordsData *pkd;
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;
bar_pane_keywords_changed(keyword_buffer, pkd);
}
-static void bar_pane_keywords_filter_modify(GtkTreeModel *model, GtkTreeIter *iter, GValue *value, gint column, gpointer data)
+void bar_pane_keywords_filter_modify(GtkTreeModel *model, GtkTreeIter *iter, GValue *value, gint column, gpointer data)
{
auto pkd = static_cast<PaneKeywordsData *>(data);
GtkTreeModel *keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
}
}
-static gboolean bar_pane_keywords_filter_visible(GtkTreeModel *keyword_tree, GtkTreeIter *iter, gpointer data)
+gboolean bar_pane_keywords_filter_visible(GtkTreeModel *keyword_tree, GtkTreeIter *iter, gpointer data)
{
auto filter = static_cast<GtkTreeModel *>(data);
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;
}
-
-
/*
*-------------------------------------------------------------------
* 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);
gtk_widget_show(gd->dialog);
}
-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 */
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);
- g_object_unref(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;
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;
return FALSE;
}
-static gint autocomplete_sort_iter_compare_func (GtkTreeModel *model,
+gint autocomplete_sort_iter_compare_func (GtkTreeModel *model,
GtkTreeIter *a,
GtkTreeIter *b,
gpointer)
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;