* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "main.h"
#include "collect-table.h"
+#include <cstddef>
+#include <utility>
+
+#include <cairo.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gio/gio.h>
+#include <glib-object.h>
+
#include "cellrenderericon.h"
#include "collect-dlg.h"
#include "collect-io.h"
+#include "collect.h"
+#include "compat.h"
+#include "debug.h"
#include "dnd.h"
#include "dupe.h"
#include "filedata.h"
#include "img-view.h"
-#include "layout.h"
+#include "intl.h"
#include "layout-image.h"
+#include "layout.h"
+#include "main-defines.h"
#include "menu.h"
#include "metadata.h"
-#include "pixbuf-util.h"
+#include "misc.h"
+#include "options.h"
#include "print.h"
-#include "utilops.h"
+#include "typedefs.h"
#include "ui-fileops.h"
#include "ui-menu.h"
#include "ui-tree-edit.h"
#include "uri-utils.h"
+#include "utilops.h"
#include "view-file.h"
+namespace
+{
+
/* between these, the icon width is increased by thumb_max_width / 2 */
-#define THUMB_MIN_ICON_WIDTH 128
-#define THUMB_MAX_ICON_WIDTH 150
+constexpr gint THUMB_MIN_ICON_WIDTH = 128;
+constexpr gint THUMB_MAX_ICON_WIDTH = 150;
-#define COLLECT_TABLE_MAX_COLUMNS 32
-#define THUMB_BORDER_PADDING 2
+constexpr gint COLLECT_TABLE_MAX_COLUMNS = 32;
-#define COLLECT_TABLE_TIP_DELAY 500
-#define COLLECT_TABLE_TIP_DELAY_PATH (COLLECT_TABLE_TIP_DELAY * 1.7)
+constexpr gint THUMB_BORDER_PADDING = 2;
+constexpr gint COLLECT_TABLE_TIP_DELAY = 500;
+constexpr gint COLLECT_TABLE_TIP_DELAY_PATH = 850;
enum {
CTABLE_COLUMN_POINTER = 0,
CTABLE_COLUMN_COUNT
};
-#define INFO_SELECTED(x) (x->flag_mask & SELECTION_SELECTED)
+struct ColumnData
+{
+ CollectTable *ct;
+ gint number;
+};
+
+inline gboolean info_selected(const CollectInfo *info)
+{
+ return info->flag_mask & SELECTION_SELECTED;
+}
+} // namespace
static void collection_table_populate_at_new_size(CollectTable *ct, gint w, gint h, gboolean force);
{static_cast<GdkModifierType>(0), 'B', N_("Sort by size")},
{static_cast<GdkModifierType>(0), 'P', N_("Sort by path")},
{GDK_SHIFT_MASK, 'P', N_("Print")},
+ {GDK_MOD1_MASK, 'A', N_("Append (Append collection dialog)")},
+ {GDK_MOD1_MASK, 'D', N_("Discard (Close modified collection dialog)")},
{static_cast<GdkModifierType>(0), 0, nullptr}
};
static gboolean collection_table_find_iter(CollectTable *ct, CollectInfo *info, GtkTreeIter *iter, gint *column)
{
GtkTreeModel *store;
- gint row, col;
+ gint row;
+ gint col;
store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
if (!collection_table_find_position(ct, info, &row, &col)) return FALSE;
{
auto info = static_cast<CollectInfo *>(work->data);
- if (INFO_SELECTED(info))
+ if (info_selected(info))
{
collection_table_selection_remove(ct, info, SELECTION_SELECTED, nullptr);
}
{
ct->prev_selection = info;
- if (!info || INFO_SELECTED(info)) return;
+ if (!info || info_selected(info)) return;
ct->selection = g_list_append(ct->selection, info);
collection_table_selection_add(ct, info, SELECTION_SELECTED, nullptr);
{
ct->prev_selection = info;
- if (!info || !INFO_SELECTED(info) ) return;
+ if (!info || !info_selected(info) ) return;
ct->selection = g_list_remove(ct->selection, info);
collection_table_selection_remove(ct, info, SELECTION_SELECTED, nullptr);
static void collection_table_select_region_util(CollectTable *ct, CollectInfo *start, CollectInfo *end, gboolean select)
{
- gint row1, col1;
- gint row2, col2;
- gint t;
- gint i, j;
+ gint row1;
+ gint col1;
+ gint row2;
+ gint col2;
+ gint i;
+ gint j;
if (!collection_table_find_position(ct, start, &row1, &col1) ||
!collection_table_find_position(ct, end, &row2, &col2) ) return;
if (row2 < row1)
{
- t = row1;
- row1 = row2;
- row2 = t;
+ std::swap(row1, row2);
}
if (col2 < col1)
{
- t = col1;
- col1 = col2;
- col2 = t;
+ std::swap(col1, col2);
}
DEBUG_1("table: %d x %d to %d x %d", row1, col1, row2, col2);
static void tip_show(CollectTable *ct)
{
GtkWidget *label;
- gint x, y;
+ gint x;
+ gint y;
GdkDisplay *display;
GdkSeat *seat;
GdkDevice *device;
label = gtk_label_new(ct->show_text ? ct->tip_info->fd->path : ct->tip_info->fd->name);
g_object_set_data(G_OBJECT(ct->tip_window), "tip_label", label);
- gtk_container_add(GTK_CONTAINER(ct->tip_window), label);
+ gq_gtk_container_add(GTK_WIDGET(ct->tip_window), label);
gtk_widget_show(label);
display = gdk_display_get_default();
gdk_device_get_position(device, nullptr, &x, &y);
if (!gtk_widget_get_realized(ct->tip_window)) gtk_widget_realize(ct->tip_window);
- gtk_window_move(GTK_WINDOW(ct->tip_window), x + 16, y + 16);
+ gq_gtk_window_move(GTK_WINDOW(ct->tip_window), x + 16, y + 16);
gtk_widget_show(ct->tip_window);
}
static void tip_hide(CollectTable *ct)
{
- if (ct->tip_window) gtk_widget_destroy(ct->tip_window);
+ if (ct->tip_window) gq_gtk_widget_destroy(ct->tip_window);
ct->tip_window = nullptr;
}
if (ct->tip_window)
{
- gint x, y;
+ gint x;
+ gint y;
gdk_device_get_position(device, nullptr, &x, &y);
- gtk_window_move(GTK_WINDOW(ct->tip_window), x + 16, y + 16);
+ gq_gtk_window_move(GTK_WINDOW(ct->tip_window), x + 16, y + 16);
if (info != ct->tip_info)
{
*-------------------------------------------------------------------
*/
-static void collection_table_popup_save_as_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_save_as_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
- collection_dialog_save_as(nullptr, ct->cd);
+ collection_dialog_save_as(ct->cd);
}
static void collection_table_popup_save_cb(GtkWidget *widget, gpointer data)
{
if (!ct->click_info) return nullptr;
- if (INFO_SELECTED(ct->click_info))
+ if (info_selected(ct->click_info))
{
return collection_table_selection_get_list(ct);
}
file_util_start_editor_from_filelist(key, collection_table_popup_file_list(ct), nullptr, ct->listview);
}
-static void collection_table_popup_copy_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_copy_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
file_util_copy(nullptr, collection_table_popup_file_list(ct), nullptr, ct->listview);
}
-static void collection_table_popup_move_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_move_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
file_util_move(nullptr, collection_table_popup_file_list(ct), nullptr, ct->listview);
}
-static void collection_table_popup_rename_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_rename_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
file_util_rename(nullptr, collection_table_popup_file_list(ct), ct->listview);
}
-static void collection_table_popup_delete_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_delete_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
file_util_delete(nullptr, collection_table_popup_file_list(ct), ct->listview);
}
-static void collection_table_popup_move_to_trash_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_move_to_trash_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
file_util_delete(nullptr, collection_table_popup_file_list(ct), ct->listview);
}
-static void collection_table_popup_copy_path_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_copy_path_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
file_util_copy_path_list_to_clipboard(collection_table_popup_file_list(ct), TRUE);
}
-static void collection_table_popup_copy_path_unquoted_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_copy_path_unquoted_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
collection_set_sort_method(ct->cd, type);
}
-static void collection_table_popup_randomize_cb(GtkWidget *widget, gpointer UNUSED(data))
+static void collection_table_popup_randomize_cb(GtkWidget *widget, gpointer)
{
CollectTable *ct;
collection_randomize(ct->cd);
}
-static void collection_table_popup_view_new_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_view_new_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
}
}
-static void collection_table_popup_view_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_view_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
}
}
-static void collection_table_popup_selectall_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_selectall_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
ct->prev_selection= ct->click_info;
}
-static void collection_table_popup_unselectall_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_unselectall_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
ct->prev_selection= ct->click_info;
}
-static void collection_table_popup_select_invert_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_select_invert_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
ct->prev_selection= ct->click_info;
}
-static void collection_table_popup_rectangular_selection_cb(GtkWidget *UNUSED(widget), gpointer UNUSED(data))
+static void collection_table_popup_rectangular_selection_cb(GtkWidget *, gpointer)
{
options->collections.rectangular_selection = !(options->collections.rectangular_selection);
}
-static void collection_table_popup_remove_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_remove_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
GList *list;
if (!ct->click_info) return;
- if (INFO_SELECTED(ct->click_info))
+ if (info_selected(ct->click_info))
{
list = g_list_copy(ct->selection);
}
}
collection_remove_by_info_list(ct->cd, list);
+ collection_table_refresh(ct);
g_list_free(list);
}
-static void collection_table_popup_add_file_selection_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_add_file_selection_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
GList *list;
}
}
-static void collection_table_popup_add_collection_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_add_collection_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
- collection_dialog_append(nullptr, ct->cd);
+ collection_dialog_append(ct->cd);
}
-static void collection_table_popup_goto_original_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_goto_original_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
GList *list;
g_list_free(list);
}
-static void collection_table_popup_find_dupes_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_find_dupes_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
DupeWindow *dw;
dupe_window_add_collection(dw, ct->cd);
}
-static void collection_table_popup_print_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_print_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
FileData *fd;
print_window_new(fd, collection_table_selection_get_list(ct), collection_table_get_list(ct), gtk_widget_get_toplevel(ct->listview));
}
-static void collection_table_popup_show_names_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_show_names_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
collection_table_toggle_filenames(ct);
}
-static void collection_table_popup_show_stars_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_show_stars_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
collection_table_toggle_stars(ct);
}
-static void collection_table_popup_destroy_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_destroy_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
menu_item_add_sensitive(menu, _("_View"), over_icon,
G_CALLBACK(collection_table_popup_view_cb), ct);
- menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, over_icon,
+ menu_item_add_icon_sensitive(menu, _("View in _new window"), GQ_ICON_NEW, over_icon,
G_CALLBACK(collection_table_popup_view_new_cb), ct);
- menu_item_add_stock(menu, _("Go to original"), GTK_STOCK_FIND,
+ menu_item_add_icon(menu, _("Go to original"), GQ_ICON_FIND,
G_CALLBACK(collection_table_popup_goto_original_cb), ct);
menu_item_add_divider(menu);
- menu_item_add_stock_sensitive(menu, _("Rem_ove"), GTK_STOCK_REMOVE, over_icon,
+ menu_item_add_icon_sensitive(menu, _("Rem_ove"), GQ_ICON_REMOVE, over_icon,
G_CALLBACK(collection_table_popup_remove_cb), ct);
- menu_item_add_stock(menu, _("Append from file selection"), GTK_STOCK_ADD,
+ menu_item_add_icon(menu, _("Append from file selection"), GQ_ICON_ADD,
G_CALLBACK(collection_table_popup_add_file_selection_cb), ct);
- menu_item_add_stock(menu, _("Append from collection..."), GTK_STOCK_OPEN,
+ menu_item_add_icon(menu, _("Append from collection..."), GQ_ICON_OPEN,
G_CALLBACK(collection_table_popup_add_collection_cb), ct);
menu_item_add_divider(menu);
gtk_widget_set_sensitive(item, over_icon);
menu_item_add_divider(menu);
- menu_item_add_stock_sensitive(menu, _("_Copy..."), GTK_STOCK_COPY, over_icon,
+ menu_item_add_icon_sensitive(menu, _("_Copy..."), GQ_ICON_COPY, over_icon,
G_CALLBACK(collection_table_popup_copy_cb), ct);
menu_item_add_sensitive(menu, _("_Move..."), over_icon,
G_CALLBACK(collection_table_popup_move_cb), ct);
G_CALLBACK(collection_table_popup_copy_path_unquoted_cb), ct);
menu_item_add_divider(menu);
- menu_item_add_stock_sensitive(menu,
+ menu_item_add_icon_sensitive(menu,
options->file_ops.confirm_move_to_trash ? _("Move to Trash...") :
- _("Move to Trash"), PIXBUF_INLINE_ICON_TRASH, over_icon,
+ _("Move to Trash"), GQ_ICON_DELETE, over_icon,
G_CALLBACK(collection_table_popup_move_to_trash_cb), ct);
- menu_item_add_stock_sensitive(menu,
+ menu_item_add_icon_sensitive(menu,
options->file_ops.confirm_delete ? _("_Delete...") :
- _("_Delete"), GTK_STOCK_DELETE, over_icon,
+ _("_Delete"), GQ_ICON_DELETE_SHRED, over_icon,
G_CALLBACK(collection_table_popup_delete_cb), ct);
menu_item_add_divider(menu);
menu_item_add_check(menu, _("Show star rating"), ct->show_stars,
G_CALLBACK(collection_table_popup_show_stars_cb), ct);
menu_item_add_divider(menu);
- menu_item_add_stock(menu, _("_Save collection"), GTK_STOCK_SAVE,
+ menu_item_add_icon(menu, _("_Save collection"), GQ_ICON_SAVE,
G_CALLBACK(collection_table_popup_save_cb), ct);
- menu_item_add_stock(menu, _("Save collection _as..."), GTK_STOCK_SAVE_AS,
+ menu_item_add_icon(menu, _("Save collection _as..."), GQ_ICON_SAVE_AS,
G_CALLBACK(collection_table_popup_save_as_cb), ct);
menu_item_add_divider(menu);
- menu_item_add_stock(menu, _("_Find duplicates..."), GTK_STOCK_FIND,
+ menu_item_add_icon(menu, _("_Find duplicates..."), GQ_ICON_FIND,
G_CALLBACK(collection_table_popup_find_dupes_cb), ct);
- menu_item_add_stock_sensitive(menu, _("Print..."), GTK_STOCK_PRINT, over_icon,
+ menu_item_add_icon_sensitive(menu, _("Print..."), GQ_ICON_PRINT, over_icon,
G_CALLBACK(collection_table_popup_print_cb), ct);
return menu;
void collection_table_set_focus(CollectTable *ct, CollectInfo *info)
{
GtkTreeIter iter;
- gint row, col;
+ gint row;
+ gint col;
if (g_list_find(ct->cd->list, ct->focus_info))
{
gint row_height;
gint ret;
- adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(ct->listview));
+ adj = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(ct->listview));
page_size = static_cast<gint>(gtk_adjustment_get_page_increment(adj));
row_height = options->thumbnails.max_height + THUMB_BORDER_PADDING * 2;
ct->click_info = info;
if (event->state & GDK_CONTROL_MASK)
{
- collection_table_select_util(ct, info, !INFO_SELECTED(info));
+ collection_table_select_util(ct, info, !info_selected(info));
}
else
{
gboolean after = FALSE;
GdkRectangle cell;
GdkWindow *parent;
- gint x_parent, y_parent;
+ gint x_parent;
+ gint y_parent;
GError *error = nullptr;
GInputStream *in_stream;
GdkPixbuf *pb;
- gchar *path;
parent = gtk_widget_get_window(gtk_widget_get_toplevel(ct->listview));
gdk_window_get_position(parent, &x_parent, &y_parent);
GdkWindowAttr attributes;
gint attributes_mask;
- path = g_build_filename(GQ_RESOURCE_PATH_ICONS, "gq-marker.xpm", NULL);
- in_stream = g_resources_open_stream(path, G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
- g_free(path);
-
+ in_stream = g_resources_open_stream(GQ_RESOURCE_PATH_ICONS "/gq-marker.xpm", G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
pb = gdk_pixbuf_new_from_stream(in_stream, nullptr, &error);
g_object_unref(in_stream);
cairo_t *cr = cairo_create(img);
gdk_cairo_set_source_pixbuf(cr, pb, 0, 0);
cairo_paint(cr);
- /** @FIXME this is a hack to get the background color */
- //~ pattern = cairo_pattern_create_for_surface(img);
+ /** @FIXME this is a hack to get the background color
+ * pattern = cairo_pattern_create_for_surface(img);
+ */
pattern = cairo_pattern_create_rgb (1.0, 0.0, 0.0);
mask = gdk_cairo_region_create_from_surface(img);
gdk_window_shape_combine_region(ct->marker_window, mask, 0, 0);
if (info)
{
- gint x, y;
- gint w, h;
+ gint x;
+ gint y;
+ gint w;
+ gint h;
w = gdk_window_get_width(ct->marker_window);
h = gdk_window_get_height(ct->marker_window);
{
auto ct = static_cast<CollectTable *>(data);
GdkWindow *window;
- gint x, y;
- gint w, h;
+ gint x;
+ gint y;
+ gint w;
+ gint h;
GdkSeat *seat;
GdkDevice *device;
return G_SOURCE_REMOVE;
}
-static gboolean collection_table_auto_scroll_notify_cb(GtkWidget *UNUSED(widget), gint UNUSED(x), gint UNUSED(y), gpointer data)
+static gboolean collection_table_auto_scroll_notify_cb(GtkWidget *, gint, gint, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
}
else
{
- GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(ct->listview));
+ GtkAdjustment *adj = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(ct->listview));
widget_auto_scroll_start(ct->listview, adj, -1, options->thumbnails.max_height / 2,
collection_table_auto_scroll_notify_cb, ct);
}
*-------------------------------------------------------------------
*/
-static gboolean collection_table_motion_cb(GtkWidget *UNUSED(widget), GdkEventMotion *event, gpointer data)
+static gboolean collection_table_motion_cb(GtkWidget *, GdkEventMotion *event, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
return FALSE;
}
-static gboolean collection_table_press_cb(GtkWidget *UNUSED(widget), GdkEventButton *bevent, gpointer data)
+static gboolean collection_table_press_cb(GtkWidget *, GdkEventButton *bevent, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
GtkTreeIter iter;
return TRUE;
}
-static gboolean collection_table_release_cb(GtkWidget *UNUSED(widget), GdkEventButton *bevent, gpointer data)
+static gboolean collection_table_release_cb(GtkWidget *, GdkEventButton *bevent, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
GtkTreeIter iter;
if (bevent->state & GDK_CONTROL_MASK)
{
- gboolean select = !INFO_SELECTED(info);
+ gboolean select = !info_selected(info);
if ((bevent->state & GDK_SHIFT_MASK) && ct->prev_selection)
{
else if (bevent->button == MOUSE_BUTTON_MIDDLE &&
info && ct->click_info == info)
{
- collection_table_select_util(ct, info, !INFO_SELECTED(info));
+ collection_table_select_util(ct, info, !info_selected(info));
}
return TRUE;
}
-static gboolean collection_table_leave_cb(GtkWidget *UNUSED(widget), GdkEventCrossing *UNUSED(event), gpointer data)
+static gboolean collection_table_leave_cb(GtkWidget *, GdkEventCrossing *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
*-------------------------------------------------------------------
*/
-static gboolean collection_table_destroy_node_cb(GtkTreeModel *store, GtkTreePath *UNUSED(tpath), GtkTreeIter *iter, gpointer UNUSED(data))
+static gboolean collection_table_destroy_node_cb(GtkTreeModel *store, GtkTreePath *, GtkTreeIter *iter, gpointer)
{
GList *list;
collection_table_update_status(ct);
}
-static void collection_table_populate_at_new_size(CollectTable *ct, gint w, gint UNUSED(h), gboolean force)
+static void collection_table_populate_at_new_size(CollectTable *ct, gint w, gint, gboolean force)
{
gint new_cols;
gint thumb_width;
GtkTreeModel *store;
GtkTreeIter iter;
GList *work;
- gint r, c;
+ gint r;
store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
r = -1;
- c = 0;
work = ct->cd->list;
while (work)
{
GList *list;
r++;
- c = 0;
if (gtk_tree_model_iter_nth_child(store, &iter, nullptr, r))
{
gtk_tree_model_get(store, &iter, CTABLE_COLUMN_POINTER, &list, -1);
{
info = static_cast<CollectInfo *>(work->data);
work = work->next;
- c++;
}
else
{
void collection_table_file_update(CollectTable *ct, CollectInfo *info)
{
GtkTreeIter iter;
- gint row, col;
+ gint row;
+ gint col;
gdouble value;
if (!info)
}
}
-void collection_table_file_add(CollectTable *ct, CollectInfo *UNUSED(info))
+void collection_table_file_add(CollectTable *ct, CollectInfo *)
{
collection_table_sync_idle(ct);
}
-void collection_table_file_insert(CollectTable *ct, CollectInfo *UNUSED(ci))
+void collection_table_file_insert(CollectTable *ct, CollectInfo *)
{
collection_table_sync_idle(ct);
}
void collection_table_file_remove(CollectTable *ct, CollectInfo *ci)
{
- if (ci && INFO_SELECTED(ci))
+ if (ci && info_selected(ci))
{
ct->selection = g_list_remove(ct->selection, ci);
}
}
-static void confirm_dir_list_add(GtkWidget *UNUSED(widget), gpointer data)
+static void confirm_dir_list_add(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
confirm_dir_list_do(ct, ct->drop_list, FALSE);
}
-static void confirm_dir_list_recurse(GtkWidget *UNUSED(widget), gpointer data)
+static void confirm_dir_list_recurse(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
confirm_dir_list_do(ct, ct->drop_list, TRUE);
}
-static void confirm_dir_list_skip(GtkWidget *UNUSED(widget), gpointer data)
+static void confirm_dir_list_skip(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
g_signal_connect(G_OBJECT(menu), "destroy",
G_CALLBACK(collection_table_popup_destroy_cb), ct);
- menu_item_add_stock(menu, _("Dropped list includes folders."), GTK_STOCK_DND_MULTIPLE, nullptr, nullptr);
+ menu_item_add_stock(menu, _("Dropped list includes folders."), GQ_ICON_DND, nullptr, nullptr);
menu_item_add_divider(menu);
- menu_item_add_stock(menu, _("_Add contents"), GTK_STOCK_OK,
+ menu_item_add_icon(menu, _("_Add contents"), GQ_ICON_OK,
G_CALLBACK(confirm_dir_list_add), ct);
- menu_item_add_stock(menu, _("Add contents _recursive"), GTK_STOCK_ADD,
+ menu_item_add_icon(menu, _("Add contents _recursive"), GQ_ICON_ADD,
G_CALLBACK(confirm_dir_list_recurse), ct);
- menu_item_add_stock(menu, _("_Skip folders"), GTK_STOCK_REMOVE,
+ menu_item_add_icon(menu, _("_Skip folders"), GQ_ICON_REMOVE,
G_CALLBACK(confirm_dir_list_skip), ct);
menu_item_add_divider(menu);
- menu_item_add_stock(menu, _("Cancel"), GTK_STOCK_CANCEL, nullptr, ct);
+ menu_item_add_icon(menu, _("Cancel"), GQ_ICON_CANCEL, nullptr, ct);
return menu;
}
static gint n_collection_drop_types = 2;
-static void collection_table_dnd_get(GtkWidget *UNUSED(widget), GdkDragContext *UNUSED(context),
+static void collection_table_dnd_get(GtkWidget *, GdkDragContext *,
GtkSelectionData *selection_data, guint info,
- guint UNUSED(time), gpointer data)
+ guint, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
gboolean selected;
if (!ct->click_info) return;
- selected = INFO_SELECTED(ct->click_info);
+ selected = info_selected(ct->click_info);
switch (info)
{
}
-static void collection_table_dnd_receive(GtkWidget *UNUSED(widget), GdkDragContext *context,
+static void collection_table_dnd_receive(GtkWidget *, GdkDragContext *context,
gint x, gint y,
GtkSelectionData *selection_data, guint info,
- guint UNUSED(time), gpointer data)
+ guint, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
GList *list = nullptr;
{
gint items;
- if (INFO_SELECTED(ct->click_info))
+ if (info_selected(ct->click_info))
items = g_list_length(ct->selection);
else
items = 1;
}
}
-static void collection_table_dnd_end(GtkWidget *UNUSED(widget), GdkDragContext *UNUSED(context), gpointer data)
+static void collection_table_dnd_end(GtkWidget *, GdkDragContext *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
collection_table_scroll(ct, FALSE);
}
-static gint collection_table_dnd_motion(GtkWidget *UNUSED(widget), GdkDragContext *UNUSED(context),
- gint x, gint y, guint UNUSED(time), gpointer data)
+static gint collection_table_dnd_motion(GtkWidget *, GdkDragContext *, gint x, gint y, guint, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
return FALSE;
}
-static void collection_table_dnd_leave(GtkWidget *UNUSED(widget), GdkDragContext *UNUSED(context), guint UNUSED(time), gpointer data)
+static void collection_table_dnd_leave(GtkWidget *, GdkDragContext *, guint, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
*-----------------------------------------------------------------------------
*/
-struct ColumnData
-{
- CollectTable *ct;
- gint number;
-};
-
-static void collection_table_cell_data_cb(GtkTreeViewColumn *UNUSED(tree_column), GtkCellRenderer *cell,
+static void collection_table_cell_data_cb(GtkTreeViewColumn *, GtkCellRenderer *cell,
GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
{
auto cd = static_cast<ColumnData *>(data);
- CollectTable *ct;
- GtkStyle *style;
- GList *list;
CollectInfo *info;
- GdkColor color_fg;
- GdkColor color_bg;
- gchar *star_rating = nullptr;
+ CollectTable *ct;
gchar *display_text = nullptr;
+ gchar *star_rating = nullptr;
+ GdkRGBA color_bg;
+ GdkRGBA color_fg;
+ GList *list;
+ GtkStyle *style;
ct = cd->ct;
style = gtk_widget_get_style(ct->listview);
if (info && (info->flag_mask & SELECTION_SELECTED) )
{
- memcpy(&color_fg, &style->text[GTK_STATE_SELECTED], sizeof(color_fg));
- memcpy(&color_bg, &style->base[GTK_STATE_SELECTED], sizeof(color_bg));
+ convert_gdkcolor_to_gdkrgba(&style->text[GTK_STATE_SELECTED], &color_fg);
+ convert_gdkcolor_to_gdkrgba(&style->base[GTK_STATE_SELECTED], &color_bg);
}
else
{
- memcpy(&color_fg, &style->text[GTK_STATE_NORMAL], sizeof(color_fg));
- memcpy(&color_bg, &style->base[GTK_STATE_NORMAL], sizeof(color_bg));
+ convert_gdkcolor_to_gdkrgba(&style->text[GTK_STATE_NORMAL], &color_fg);
+ convert_gdkcolor_to_gdkrgba(&style->base[GTK_STATE_NORMAL], &color_bg);
}
if (info && (info->flag_mask & SELECTION_PRELIGHT))
{
g_object_set(cell, "pixbuf", info->pixbuf,
"text", display_text,
- "cell-background-gdk", &color_bg,
+ "cell-background-rgba", &color_bg,
"cell-background-set", TRUE,
- "foreground-gdk", &color_fg,
+ "foreground-rgba", &color_fg,
"foreground-set", TRUE,
"has-focus", (ct->focus_info == info), NULL);
}
*-------------------------------------------------------------------
*/
-static void collection_table_destroy(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_destroy(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
{
g_signal_handlers_disconnect_matched(G_OBJECT(ct->popup), G_SIGNAL_MATCH_DATA,
0, 0, nullptr, nullptr, ct);
- gtk_widget_destroy(ct->popup);
+ gq_gtk_widget_destroy(ct->popup);
}
if (ct->sync_idle_id) g_source_remove(ct->sync_idle_id);
g_free(ct);
}
-static void collection_table_sized(GtkWidget *UNUSED(widget), GtkAllocation *allocation, gpointer data)
+static void collection_table_sized(GtkWidget *, GtkAllocation *allocation, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
ct->show_text = options->show_icon_names;
ct->show_stars = options->show_star_rating;
- ct->scrolled = gtk_scrolled_window_new(nullptr, nullptr);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(ct->scrolled), GTK_SHADOW_IN);
+ ct->scrolled = gq_gtk_scrolled_window_new(nullptr, nullptr);
+ gq_gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(ct->scrolled), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ct->scrolled),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
g_signal_connect(G_OBJECT(ct->listview), "key_press_event",
G_CALLBACK(collection_table_press_key_cb), ct);
- gtk_container_add(GTK_CONTAINER(ct->scrolled), ct->listview);
+ gq_gtk_container_add(GTK_WIDGET(ct->scrolled), ct->listview);
gtk_widget_show(ct->listview);
collection_table_dnd_init(ct);