* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "ui-misc.h"
+
+#include <langinfo.h>
+
#include <cstdlib>
#include <cstring>
-#include "main.h"
-#include "ui-misc.h"
+#include <pango/pango.h>
-#include "history-list.h"
+#include <config.h>
-#include <langinfo.h>
+#include "compat.h"
+#include "debug.h"
+#include "history-list.h"
+#include "layout.h"
+#include "main-defines.h"
+#include "misc.h"
+#include "options.h"
+#include "typedefs.h"
+#include "utilops.h"
/*
*-----------------------------------------------------------------------------
box = gtk_box_new(GTK_ORIENTATION_VERTICAL, padding);
}
- gtk_box_pack_start(GTK_BOX(parent_box), box, fill, fill, 0);
+ gq_gtk_box_pack_start(GTK_BOX(parent_box), box, fill, fill, 0);
gtk_widget_show(box);
return box;
g_list_free(list);
}
- gtk_box_pack_start(GTK_BOX(parent_box), vbox, fill, fill, 0);
+ gq_gtk_box_pack_start(GTK_BOX(parent_box), vbox, fill, fill, 0);
gtk_widget_show(vbox);
label = gtk_label_new(text);
gtk_label_set_yalign(GTK_LABEL(label), 0.5);
pref_label_bold(label, TRUE, FALSE);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
gtk_widget_show(label);
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, PREF_PAD_INDENT);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show(hbox);
/* indent using empty box */
{
box = gtk_box_new(GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP);
}
- gtk_box_pack_start(GTK_BOX(hbox), box, TRUE, TRUE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(hbox), box, TRUE, TRUE, 0);
gtk_widget_show(box);
g_object_set_data(G_OBJECT(box), "pref_group", vbox);
GtkWidget *frame = nullptr;
frame = gtk_frame_new(text);
- gtk_box_pack_start(GTK_BOX(parent_box), frame, fill, fill, 0);
+ gq_gtk_box_pack_start(GTK_BOX(parent_box), frame, fill, fill, 0);
gtk_widget_show(frame);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
box = gtk_box_new(GTK_ORIENTATION_VERTICAL, padding);
}
- gtk_container_add(GTK_CONTAINER(frame), box);
+ gq_gtk_container_add(GTK_WIDGET(frame), box);
gtk_container_set_border_width(GTK_CONTAINER(box), PREF_PAD_BORDER);
gtk_widget_show(box);
GtkWidget *spacer;
spacer = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_pack_start(GTK_BOX(parent_box), spacer, FALSE, FALSE, padding / 2);
+ gq_gtk_box_pack_start(GTK_BOX(parent_box), spacer, FALSE, FALSE, padding / 2);
gtk_widget_show(spacer);
return spacer;
GtkWidget *spacer;
spacer = gtk_separator_new(GTK_IS_HBOX(parent_box) ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL);
- gtk_box_pack_start(GTK_BOX(parent_box), spacer, FALSE, FALSE, padding / 2);
+ gq_gtk_box_pack_start(GTK_BOX(parent_box), spacer, FALSE, FALSE, padding / 2);
gtk_widget_show(spacer);
return spacer;
GtkWidget *label;
label = gtk_label_new(text);
- gtk_box_pack_start(GTK_BOX(parent_box), label, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(parent_box), label, FALSE, FALSE, 0);
gtk_widget_show(label);
return label;
label = gtk_label_new_with_mnemonic(text);
gtk_label_set_mnemonic_widget(GTK_LABEL(label), widget);
- gtk_box_pack_start(GTK_BOX(parent_box), label, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(parent_box), label, FALSE, FALSE, 0);
gtk_widget_show(label);
return label;
if (text)
{
+ gtk_button_set_use_underline(GTK_BUTTON(button), TRUE);
gtk_button_set_label(GTK_BUTTON(button), text);
}
if (parent_box)
{
- gtk_box_pack_start(GTK_BOX(parent_box), button, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(parent_box), button, FALSE, FALSE, 0);
gtk_widget_show(button);
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
if (func) g_signal_connect(G_OBJECT(button), "clicked", func, data);
- gtk_box_pack_start(GTK_BOX(parent_box), button, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(parent_box), button, FALSE, FALSE, 0);
gtk_widget_show(button);
return button;
#pragma GCC diagnostic ignored "-Wunused-function"
static void pref_checkbox_link_sensitivity_swap_cb_unused(GtkWidget *button, gpointer data)
{
- GtkWidget *widget = static_cast<GtkWidget *>(data);
+ auto *widget = static_cast<GtkWidget *>(data);
gtk_widget_set_sensitive(widget, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
}
GCallback func, gpointer data)
{
GtkWidget *button;
+#if HAVE_GTK4
+ GtkToggleButton *group;;
+#else
GSList *group;
+#endif
if (sibling)
{
+#if HAVE_GTK4
+ group = sibling;
+#else
group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(sibling));
+#endif
}
else
{
if (mnemonic_text)
{
+#if HAVE_GTK4
+ button = gtk_toggle_button_new_with_mnemonic(text);
+ gtk_toggle_button_set_group(button, group);
+#else
button = gtk_radio_button_new_with_mnemonic(group, text);
+#endif
}
else
{
+#if HAVE_GTK4
+ button = gtk_toggle_button_new_with_label(text);
+ gtk_toggle_button_set_group(button, group);
+#else
button = gtk_radio_button_new_with_label(group, text);
+#endif
}
if (active) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
if (func) g_signal_connect(G_OBJECT(button), "clicked", func, data);
- gtk_box_pack_start(GTK_BOX(parent_box), button, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(parent_box), button, FALSE, FALSE, 0);
gtk_widget_show(button);
return button;
static void pref_radiobutton_int_cb_unused(GtkWidget *widget, gpointer data)
{
- gboolean *result = static_cast<gboolean *>(data);
+ auto *result = static_cast<gboolean *>(data);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
{
pref_link_sensitivity(label, spin);
}
- gtk_box_pack_start(GTK_BOX(box), spin, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(box), spin, FALSE, FALSE, 0);
gtk_widget_show(spin);
/* perhaps this should only be PREF_PAD_GAP distance from spinbutton ? */
0, 0, nullptr, nullptr, data);
}
-GtkWidget *pref_table_new(GtkWidget *parent_box, gint columns, gint rows,
- gboolean homogeneous, gboolean fill)
+GtkWidget *pref_table_new(GtkWidget *parent_box, gint, gint, gboolean, gboolean fill)
{
GtkWidget *table;
- table = gtk_table_new(rows, columns, homogeneous);
- gtk_table_set_row_spacings(GTK_TABLE(table), PREF_PAD_GAP);
- gtk_table_set_col_spacings(GTK_TABLE(table), PREF_PAD_SPACE);
+ table = gtk_grid_new();
+ gtk_grid_set_row_spacing(GTK_GRID(table), PREF_PAD_GAP);
+ gtk_grid_set_column_spacing(GTK_GRID(table), PREF_PAD_SPACE);
if (parent_box)
{
- gtk_box_pack_start(GTK_BOX(parent_box), table, fill, fill, 0);
+ gq_gtk_box_pack_start(GTK_BOX(parent_box), table, fill, fill, 0);
gtk_widget_show(table);
}
shell = box;
}
- gtk_table_attach(GTK_TABLE(table), shell, column, column + 1, row, row + 1,
- static_cast<GtkAttachOptions>(GTK_EXPAND | GTK_FILL), static_cast<GtkAttachOptions>(0), 0, 0);
+ gq_gtk_grid_attach(GTK_GRID(table), shell, column, column + 1, row, row + 1, static_cast<GtkAttachOptions>(GTK_EXPAND | GTK_FILL), static_cast<GtkAttachOptions>(0), 0, 0);
gtk_widget_show(shell);
}
GtkWidget *pref_table_label(GtkWidget *table, gint column, gint row,
- const gchar *text, gfloat alignment)
+ const gchar *text, GtkAlign alignment)
{
GtkWidget *label;
- GtkWidget *align;
- align = gtk_alignment_new(alignment, 0.50, 0.0, 0.0);
- gtk_table_attach(GTK_TABLE(table), align, column, column + 1, row, row + 1,
- GTK_FILL, static_cast<GtkAttachOptions>(0), 0, 0);
- gtk_widget_show(align);
label = gtk_label_new(text);
- gtk_container_add(GTK_CONTAINER(align), label);
+ gtk_widget_set_halign(label, alignment);
+ gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
+ gq_gtk_grid_attach(GTK_GRID(table), label, column, column + 1, row, row + 1, GTK_FILL, static_cast<GtkAttachOptions>(0), 0, 0);
gtk_widget_show(label);
return label;
GtkWidget *button;
button = pref_button_new(nullptr, stock_id, text, func, data);
- gtk_table_attach(GTK_TABLE(table), button, column, column + 1, row, row + 1,
- GTK_FILL, static_cast<GtkAttachOptions>(0), 0, 0);
+ gq_gtk_grid_attach(GTK_GRID(table), button, column, column + 1, row, row + 1, GTK_FILL, static_cast<GtkAttachOptions>(0), 0, 0);
gtk_widget_show(button);
return button;
if (text)
{
- label = pref_table_label(table, column, row, text, 1.0);
+ label = pref_table_label(table, column, row, text, GTK_ALIGN_END);
pref_link_sensitivity(label, spin);
column++;
}
if (suffix)
{
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
- gtk_box_pack_start(GTK_BOX(box), spin, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(box), spin, FALSE, FALSE, 0);
gtk_widget_show(spin);
label = pref_label_new(box, suffix);
box = spin;
}
- gtk_table_attach(GTK_TABLE(table), box, column, column + 1, row, row + 1,
- static_cast<GtkAttachOptions>(GTK_EXPAND | GTK_FILL), static_cast<GtkAttachOptions>(GTK_EXPAND | GTK_FILL), 0, 0);
+ gq_gtk_grid_attach(GTK_GRID(table), box, column, column + 1, row, row + 1, static_cast<GtkAttachOptions>(GTK_EXPAND | GTK_FILL), static_cast<GtkAttachOptions>(GTK_EXPAND | GTK_FILL), 0, 0);
gtk_widget_show(box);
return spin;
}
-GtkWidget *pref_toolbar_new(GtkWidget *parent_box, GtkToolbarStyle style)
+GtkWidget *pref_toolbar_new(GtkWidget *parent_box)
{
GtkWidget *tbar;
- tbar = gtk_toolbar_new();
- gtk_toolbar_set_style(GTK_TOOLBAR(tbar), style);
+ tbar = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
if (parent_box)
{
- gtk_box_pack_start(GTK_BOX(parent_box), tbar, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(parent_box), tbar, FALSE, FALSE, 0);
gtk_widget_show(tbar);
}
return tbar;
gtk_tool_button_set_use_underline(GTK_TOOL_BUTTON(item), TRUE);
if (func) g_signal_connect(item, "clicked", func, data);
- gtk_container_add(GTK_CONTAINER(toolbar), item);
+ gq_gtk_container_add(GTK_WIDGET(toolbar), item);
gtk_widget_show(item);
if (description)
GtkWidget *item;
item = GTK_WIDGET(gtk_separator_tool_item_new());
- gtk_container_add(GTK_CONTAINER(toolbar), item);
+ gq_gtk_container_add(GTK_WIDGET(toolbar), item);
gtk_widget_show(item);
return item;
gtk_widget_hide(ds->window);
- gtk_widget_destroy(ds->window);
+ gq_gtk_widget_destroy(ds->window);
ds->window = nullptr;
ds->calendar = nullptr;
static gboolean date_selection_popup_press_cb(GtkWidget *, GdkEventButton *event, gpointer data)
{
auto ds = static_cast<DateSelection *>(data);
- gint x, y;
- gint w, h;
- gint xr, yr;
+ gint x;
+ gint y;
+ gint w;
+ gint h;
+ gint xr;
+ gint yr;
GdkWindow *window;
xr = static_cast<gint>(event->x_root);
static void date_selection_popup_sync(DateSelection *ds)
{
- guint day, month, year;
+ guint day;
+ guint month;
+ guint year;
+
+#if HAVE_GTK4
+ GDateTime *date_selected;
+ date_selected = gtk_calendar_get_date(GTK_CALENDAR(ds->calendar));
+ g_date_time_get_ymd(date_selected, static_cast<guint>(&year), static_cast<guint>(&month), static_cast<guint>(&day));
+
+ g_date_time_unref(date_selected);
+#else
gtk_calendar_get_date(GTK_CALENDAR(ds->calendar), &year, &month, &day);
- date_selection_set(ds->box, day, month + 1, year);
+ /* month is range 0 to 11 */
+ month = month + 1;
+#endif
+ date_selection_set(ds->box, day, month, year);
}
static gboolean date_selection_popup_keypress_cb(GtkWidget *, GdkEventKey *event, gpointer data)
static void date_selection_popup(DateSelection *ds)
{
- gint x, y;
- gint wx, wy;
- gint day, month, year;
+ GDateTime *date;
+ gint wx;
+ gint wy;
+ gint x;
+ gint y;
GtkAllocation button_allocation;
GtkAllocation window_allocation;
G_CALLBACK(date_selection_popup_keypress_cb), ds);
ds->calendar = gtk_calendar_new();
- gtk_container_add(GTK_CONTAINER(ds->window), ds->calendar);
+ gq_gtk_container_add(GTK_WIDGET(ds->window), ds->calendar);
gtk_widget_show(ds->calendar);
- date_selection_get(ds->box, &day, &month, &year);
- gtk_calendar_select_month(GTK_CALENDAR(ds->calendar), month - 1, year);
- gtk_calendar_select_day(GTK_CALENDAR(ds->calendar), day);
+ date = date_selection_get(ds->box);
+#if HAVE_GTK4
+ gtk_calendar_select_day(GTK_CALENDAR(ds->calendar), date);
+#else
+ gtk_calendar_select_month(GTK_CALENDAR(ds->calendar), g_date_time_get_month(date), g_date_time_get_year(date));
+ gtk_calendar_select_day(GTK_CALENDAR(ds->calendar), g_date_time_get_day_of_month(date));
+#endif
+ g_date_time_unref(date);
g_signal_connect(G_OBJECT(ds->calendar), "day_selected",
G_CALLBACK(date_selection_day_cb), ds);
if (x < 0) x = 0;
if (y < 0) y = 0;
- gtk_window_move(GTK_WINDOW(ds->window), x, y);
+ gq_gtk_window_move(GTK_WINDOW(ds->window), x, y);
gtk_widget_show(ds->window);
gtk_widget_grab_focus(ds->calendar);
GtkWidget *date_selection_new()
{
DateSelection *ds;
- GtkWidget *arrow;
+ GtkWidget *icon;
ds = g_new0(DateSelection, 1);
gchar *date_format;
g_signal_connect(G_OBJECT(ds->button), "size_allocate",
G_CALLBACK(button_size_allocate_cb), ds->spin_y);
- arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE);
- gtk_container_add(GTK_CONTAINER(ds->button), arrow);
- gtk_widget_show(arrow);
+ icon = gtk_image_new_from_icon_name(GQ_ICON_PAN_DOWN, GTK_ICON_SIZE_BUTTON);
+ gq_gtk_container_add(GTK_WIDGET(ds->button), icon);
+ gtk_widget_show(icon);
- gtk_box_pack_start(GTK_BOX(ds->box), ds->button, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(ds->box), ds->button, FALSE, FALSE, 0);
g_signal_connect(G_OBJECT(ds->button), "clicked",
G_CALLBACK(date_selection_button_cb), ds);
gtk_widget_show(ds->button);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(ds->spin_y), static_cast<gdouble>(year));
}
-
-void date_selection_get(GtkWidget *widget, gint *day, gint *month, gint *year)
+/**
+ * @brief Returns date structure set to value of spin buttons
+ * @param widget #DateSelection
+ * @returns
+ *
+ * Free returned structure with g_date_time_unref();
+ */
+GDateTime *date_selection_get(GtkWidget *widget)
{
DateSelection *ds;
+ gint day;
+ gint month;
+ gint year;
+ GDateTime *date;
ds = static_cast<DateSelection *>(g_object_get_data(G_OBJECT(widget), DATE_SELECION_KEY));
- if (!ds) return;
+ if (!ds)
+ {
+ return nullptr;
+ }
- if (day) *day = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ds->spin_d));
- if (month) *month = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ds->spin_m));
- if (year) *year = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ds->spin_y));
+ day = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ds->spin_d));
+ month = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ds->spin_m));
+ year = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ds->spin_y));
+
+ date = g_date_time_new_local(year, month, day, 0, 0, 0);
+
+ return date;
}
void date_selection_time_set(GtkWidget *widget, time_t t)
gint month = 0;
gint year = 0;
- date_selection_get(widget, &day, &month ,&year);
+ date_selection_get(widget);
lt.tm_sec = 0;
lt.tm_min = 0;
if (pref_list_get(group, key, PREF_LIST_MARKER_DOUBLE, &text) && text)
{
- *result = g_ascii_strtod(text, NULL);
+ *result = g_ascii_strtod(text, nullptr);
return TRUE;
}
void pref_color_button_set_cb(GtkWidget *widget, gpointer data)
{
- auto color = static_cast<GdkColor *>(data);
+ auto color = static_cast<GdkRGBA *>(data);
- gtk_color_button_get_color(GTK_COLOR_BUTTON(widget), color);
+ gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(widget), color);
}
-GtkWidget *pref_color_button_new(GtkWidget *parent_box,
- const gchar *title, const GdkColor *color,
- GCallback func, gpointer data)
+GtkWidget *pref_color_button_new(GtkWidget *parent_box, const gchar *title, GdkRGBA *color, GCallback func, gpointer data)
{
GtkWidget *button;
if (color)
{
- button = gtk_color_button_new_with_color(color);
+ button = gtk_color_button_new_with_rgba(color);
}
else
{
label = gtk_label_new(title);
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_pack_start(GTK_BOX(parent_box), hbox, TRUE, TRUE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(parent_box), hbox, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
- gtk_widget_show_all(hbox);
+ gq_gtk_widget_show_all(hbox);
}
else
{
if (GTK_IS_TEXT_VIEW(text_widget))
{
GtkTextBuffer *buffer;
- GtkTextIter start, end;
+ GtkTextIter start;
+ GtkTextIter end;
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_widget));
gtk_text_buffer_get_bounds(buffer, &start, &end);
return gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
}
- else if (GTK_IS_ENTRY(text_widget))
- {
- return g_strdup(gtk_entry_get_text(GTK_ENTRY(text_widget)));
- }
- else
+
+ if (GTK_IS_ENTRY(text_widget))
{
- return nullptr;
+ return g_strdup(gq_gtk_entry_get_text(GTK_ENTRY(text_widget)));
}
+ return nullptr;
+
+
}
gchar *text_widget_text_pull_selected(GtkWidget *text_widget)
if (GTK_IS_TEXT_VIEW(text_widget))
{
GtkTextBuffer *buffer;
- GtkTextIter start, end;
+ GtkTextIter start;
+ GtkTextIter end;
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_widget));
gtk_text_buffer_get_bounds(buffer, &start, &end);
return gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
}
- else if (GTK_IS_ENTRY(text_widget))
+
+ if (GTK_IS_ENTRY(text_widget))
{
- return g_strdup(gtk_entry_get_text(GTK_ENTRY(text_widget)));
+ return g_strdup(gq_gtk_entry_get_text(GTK_ENTRY(text_widget)));
}
- else
+
+ return nullptr;
+
+}
+
+static gint simple_sort_cb(gconstpointer a, gconstpointer b)
+{
+ const ActionItem *a_action;
+ const ActionItem *b_action;
+
+ a_action = static_cast<const ActionItem *>(a);
+ b_action = static_cast<const ActionItem *>(b);
+
+ return g_strcmp0(a_action->name, b_action->name);
+}
+
+void free_action_items_cb(gpointer data)
+{
+ ActionItem *action_item;
+
+ action_item = static_cast<ActionItem *>(data);
+ g_free((gchar *)action_item->icon_name);
+ g_free((gchar *)action_item->name);
+ g_free((gchar *)action_item->label);
+ g_free(action_item);
+}
+
+void action_items_free(GList *list)
+{
+ g_list_free_full(list, free_action_items_cb);
+}
+
+/**
+ * @brief Get a list of menu actions
+ * @param
+ * @returns GList ActionItem
+ *
+ * Free returned list with action_items_free(list)
+ *
+ * The list generated is used in the --remote --action-list command and
+ * programmable mouse buttons 8 and 9.
+ */
+GList* get_action_items()
+{
+ ActionItem *action_item;
+ const gchar *accel_path;
+ gboolean duplicate;
+ gchar *action_name;
+ gchar *label;
+ gchar *tooltip;
+ GList *actions;
+ GList *groups;
+ GList *list_duplicates = nullptr;
+ GList *list_unique = nullptr;
+ GList *work1;
+ GList *work2;
+ GtkAction *action;
+ LayoutWindow *lw = nullptr;
+
+ if (!layout_valid(&lw))
{
return nullptr;
}
+
+ groups = gtk_ui_manager_get_action_groups(lw->ui_manager);
+ while (groups)
+ {
+ actions = gtk_action_group_list_actions(GTK_ACTION_GROUP(groups->data));
+ while (actions)
+ {
+ action = GTK_ACTION(actions->data);
+ accel_path = gtk_action_get_accel_path(action);
+
+ if (accel_path && gtk_accel_map_lookup_entry(accel_path, nullptr))
+ {
+ g_object_get(action, "tooltip", &tooltip, "label", &label, NULL);
+
+ action_name = g_path_get_basename(accel_path);
+
+ /* Menu actions are irrelevant */
+ if (g_strstr_len(action_name, -1, "Menu") == nullptr)
+ {
+ action_item = g_new0(ActionItem, 1);
+
+ /* .desktop items need the program name, Geeqie menu items need the tooltip */
+ if (g_strstr_len(action_name, -1, ".desktop") == nullptr)
+ {
+
+ /* Tooltips with newlines affect output format */
+ if (tooltip && (g_strstr_len(tooltip, -1, "\n") == nullptr) )
+ {
+ action_item->label = g_strdup(tooltip);
+ }
+ else
+ {
+ action_item->label = g_strdup(label);
+ }
+ }
+ else
+ {
+ action_item->label = g_strdup(label);
+ }
+
+ action_item->name = action_name;
+ action_item->icon_name = g_strdup(gtk_action_get_stock_id(action));
+
+ list_duplicates = g_list_prepend(list_duplicates, action_item);
+ }
+ }
+ actions = actions->next;
+ }
+
+ groups = groups->next;
+ }
+
+ /* Use the shortest name i.e. ignore -Alt versions. Sort makes the shortest first in the list */
+ list_duplicates = g_list_sort(list_duplicates, simple_sort_cb);
+
+ /* Ignore duplicate entries */
+ work1 = list_duplicates;
+ while (work1)
+ {
+ duplicate = FALSE;
+ work2 = list_unique;
+ /* The first entry must be unique, list_unique is null so control bypasses the while */
+ while (work2)
+ {
+ if (g_strcmp0(static_cast<ActionItem *>(work2->data)->label, static_cast<ActionItem *>(work1->data)->label) == 0)
+ {
+ duplicate = TRUE;
+ break;
+ }
+ work2 = work2->next;
+ }
+
+ if (!duplicate)
+ {
+ action_item = g_new0(ActionItem, 1);
+ action_item->name = g_strdup(static_cast<ActionItem *>(work1->data)->name);
+ action_item->label = g_strdup(static_cast<ActionItem *>(work1->data)->label);
+ action_item->icon_name = g_strdup(static_cast<ActionItem *>(work1->data)->icon_name);
+ list_unique = g_list_append(list_unique, action_item);
+ }
+ work1 = work1->next;
+ }
+
+ g_list_free_full(list_duplicates, free_action_items_cb);
+
+ return list_unique;
}
gboolean defined_mouse_buttons(GtkWidget *, GdkEventButton *event, gpointer data)
case MOUSE_BUTTON_8:
if (options->mouse_button_8)
{
- action = gtk_action_group_get_action(lw->action_group, options->mouse_button_8);
- if (action)
+ if (g_strstr_len(options->mouse_button_8, -1, ".desktop") != nullptr)
{
- gtk_action_activate(action);
+ file_util_start_editor_from_filelist(options->mouse_button_8, layout_selection_list(lw), layout_get_path(lw), lw->window);
+ ret = TRUE;
+ }
+ else
+ {
+ action = gtk_action_group_get_action(lw->action_group, options->mouse_button_8);
+ if (action)
+ {
+ gtk_action_activate(action);
+ }
+ ret = TRUE;
}
- ret = TRUE;
}
- break;
+ break;
case MOUSE_BUTTON_9:
if (options->mouse_button_9)
{
- action = gtk_action_group_get_action(lw->action_group, options->mouse_button_9);
- if (action)
+ if (g_strstr_len(options->mouse_button_9, -1, ".desktop") != nullptr)
+ {
+ file_util_start_editor_from_filelist(options->mouse_button_9, layout_selection_list(lw), layout_get_path(lw), lw->window);
+ }
+ else
{
- gtk_action_activate(action);
+ action = gtk_action_group_get_action(lw->action_group, options->mouse_button_9);
+ ret = TRUE;
+ if (action)
+ {
+ gtk_action_activate(action);
+ }
+ ret = TRUE;
}
- ret = TRUE;
}
break;
default:
return ret;
}
+GdkPixbuf *gq_gtk_icon_theme_load_icon_copy(GtkIconTheme *icon_theme, const gchar *icon_name, gint size, GtkIconLookupFlags flags)
+{
+ GError *error = nullptr;
+ GdkPixbuf *icon = gtk_icon_theme_load_icon(icon_theme, icon_name, size, flags, &error);
+ if (error) return nullptr;
+
+ GdkPixbuf *pixbuf = gdk_pixbuf_copy(icon);
+ g_object_unref(icon);
+ return pixbuf;
+}
+
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */