Fix #314: Remote commands for thumbnail maintenance
[geeqie.git] / src / ui_tree_edit.h
1 /*
2  * Copyright (C) 2004 John Ellis
3  * Copyright (C) 2008 - 2016 The Geeqie Team
4  *
5  * Author: John Ellis
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef UI_TREE_EDIT_H
23 #define UI_TREE_EDIT_H
24
25
26 typedef struct _TreeEditData TreeEditData;
27 struct _TreeEditData
28 {
29         GtkWidget *window;
30         GtkWidget *entry;
31
32         gchar *old_name;
33         gchar *new_name;
34
35         gint (*edit_func)(TreeEditData *ted, const gchar *oldname, const gchar *newname, gpointer data);
36         gpointer edit_data;
37
38         GtkTreeView *tree;
39         GtkTreePath *path;
40         GtkTreeViewColumn *column;
41         GtkCellRenderer *cell;
42 };
43
44
45 /*
46  * edit_func: return TRUE if rename successful, FALSE on failure.
47  */
48 gboolean tree_edit_by_path(GtkTreeView *tree, GtkTreePath *tpath, gint column, const gchar *text,
49                            gboolean (*edit_func)(TreeEditData *, const gchar *, const gchar *, gpointer), gpointer data);
50
51
52 /* returns location of cell in screen coordinates */
53 gboolean tree_view_get_cell_origin(GtkTreeView *widget, GtkTreePath *tpath, gint column, gboolean text_cell_only,
54                                    gint *x, gint *y, gint *width, gint *height);
55 /* similar to above, but limits the returned area to that of the tree window */
56 void tree_view_get_cell_clamped(GtkTreeView *widget, GtkTreePath *tpath, gint column, gboolean text_cell_only,
57                                gint *x, gint *y, gint *width, gint *height);
58
59 /* return 0 = row visible, -1 = row is above, 1 = row is below visible region
60  * if fully_visible is TRUE, the bahavior changes to return -1/1 if _any_ part of the cell is out of view */
61 gint tree_view_row_get_visibility(GtkTreeView *widget, GtkTreeIter *iter, gboolean fully_visible);
62
63 /* scrolls to make row visible, if necessary
64  * return is same as above (before the scroll)
65  */
66 gint tree_view_row_make_visible(GtkTreeView *widget, GtkTreeIter *iter, gboolean center);
67
68 /* if iter is location of cursor, moves cursor to nearest row */
69 gboolean tree_view_move_cursor_away(GtkTreeView *widget, GtkTreeIter *iter, gboolean only_selected);
70
71 /* utility to return row position of given GtkTreePath
72  */
73 gint tree_path_to_row(GtkTreePath *tpath);
74
75
76 /* shifts a GdkColor values lighter or darker
77  * val is percent from 1 to 100, or -1 for default (usually 10%)
78  * direction is -1 darker, 0 auto, 1 lighter
79  */
80 void shift_color(GdkColor *src, gshort val, gint direction);
81
82 /*
83  * Shifts a style's color for given state
84  * Useful for alternating dark/light rows in lists.
85  *
86  * shift_value is 1 to 100, representing the percent of the shift.
87  */
88 void style_shift_color(GtkStyle *style, GtkStateType type, gshort shift_value, gint direction);
89
90 /*
91  * The standard shift percent for alternating list row colors
92  */
93 #define STYLE_SHIFT_STANDARD 10
94
95 /*
96  * auto scroll, set scroll_speed or region_size to -1 to their respective the defaults
97  * notify_func will be called before a scroll, return FALSE to turn off autoscroll
98  */
99 gint widget_auto_scroll_start(GtkWidget *widget, GtkAdjustment *v_adj, gint scroll_speed, gint region_size,
100                               gint (*notify_func)(GtkWidget *widget, gint x, gint y, gpointer data), gpointer notify_data);
101 void widget_auto_scroll_stop(GtkWidget *widget);
102
103
104 /*
105  * Various g_list utils, do not really fit anywhere, so they are here.
106  */
107 GList *uig_list_insert_link(GList *list, GList *link, gpointer data);
108 GList *uig_list_insert_list(GList *parent, GList *insert_link, GList *list);
109
110
111 #endif
112 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */