Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
GIMP
Commits
a5868e1f
Commit
a5868e1f
authored
Sep 09, 2016
by
Michael Natterer
😴
Browse files
app: some cleanup in GimpSearchPopup
parent
53f34ebc
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/widgets/gimpsearchpopup.c
View file @
a5868e1f
...
...
@@ -39,6 +39,7 @@
#include
"gimp-intl.h"
enum
{
COLUMN_ICON
,
...
...
@@ -52,13 +53,12 @@ enum
enum
{
PROP_0
,
PROP_GIMP
,
PROP_CALLBACK
,
PROP_CALLBACK_DATA
PROP_0
,
PROP_GIMP
,
PROP_CALLBACK
,
PROP_CALLBACK_DATA
};
static
gint
window_height
=
0
;
struct
_GimpSearchPopupPrivate
{
...
...
@@ -71,7 +71,7 @@ struct _GimpSearchPopupPrivate
gpointer
build_results_data
;
};
/* GObject handlers */
static
void
gimp_search_popup_constructed
(
GObject
*
object
);
static
void
gimp_search_popup_set_property
(
GObject
*
object
,
guint
property_id
,
...
...
@@ -82,27 +82,28 @@ static void gimp_search_popup_get_property (GObject *obj
GValue
*
value
,
GParamSpec
*
pspec
);
/* GtkWidget handlers */
static
void
gimp_search_popup_size_allocate
(
GtkWidget
*
widget
,
GtkAllocation
*
allocation
);
/* GimpPopup handlers */
static
void
gimp_search_popup_confirm
(
GimpPopup
*
popup
);
/* Signal handlers on the search entry */
static
gboolean
keyword_entry_
on_
key_press_event
(
GtkWidget
*
widget
,
static
gboolean
keyword_entry_key_press_event
(
GtkWidget
*
widget
,
GdkEventKey
*
event
,
GimpSearchPopup
*
popup
);
static
gboolean
keyword_entry_
on_
key_release_event
(
GtkWidget
*
widget
,
static
gboolean
keyword_entry_key_release_event
(
GtkWidget
*
widget
,
GdkEventKey
*
event
,
GimpSearchPopup
*
popup
);
/* Signal handlers on the results list */
static
gboolean
results_list_
on_
key_press_event
(
GtkWidget
*
widget
,
static
gboolean
results_list_key_press_event
(
GtkWidget
*
widget
,
GdkEventKey
*
kevent
,
GimpSearchPopup
*
popup
);
static
void
results_list_
on_
row_activated
(
GtkTreeView
*
treeview
,
static
void
results_list_row_activated
(
GtkTreeView
*
treeview
,
GtkTreePath
*
path
,
GtkTreeViewColumn
*
col
,
GimpSearchPopup
*
popup
);
/* Utils */
static
void
gimp_search_popup_run_selected
(
GimpSearchPopup
*
popup
);
static
void
gimp_search_popup_setup_results
(
GtkWidget
**
results_list
,
...
...
@@ -118,6 +119,9 @@ G_DEFINE_TYPE (GimpSearchPopup, gimp_search_popup, GIMP_TYPE_POPUP)
#define parent_class gimp_search_popup_parent_class
static
gint
window_height
=
0
;
static
void
gimp_search_popup_class_init
(
GimpSearchPopupClass
*
klass
)
{
...
...
@@ -265,7 +269,7 @@ gimp_search_popup_add_result (GimpSearchPopup *popup,
}
accel_string
=
gimp_search_popup_find_accel_label
(
action
);
if
(
accel_string
!=
NULL
)
if
(
accel_string
)
{
escaped_accel
=
g_markup_escape_text
(
accel_string
,
-
1
);
has_shortcut
=
TRUE
;
...
...
@@ -367,17 +371,17 @@ gimp_search_popup_constructed (GObject *object)
GDK_SCROLL_MASK
);
g_signal_connect
(
popup
->
priv
->
keyword_entry
,
"key-press-event"
,
G_CALLBACK
(
keyword_entry_
on_
key_press_event
),
G_CALLBACK
(
keyword_entry_key_press_event
),
popup
);
g_signal_connect
(
popup
->
priv
->
keyword_entry
,
"key-release-event"
,
G_CALLBACK
(
keyword_entry_
on_
key_release_event
),
G_CALLBACK
(
keyword_entry_key_release_event
),
popup
);
g_signal_connect
(
popup
->
priv
->
results_list
,
"key-press-event"
,
G_CALLBACK
(
results_list_
on_
key_press_event
),
G_CALLBACK
(
results_list_key_press_event
),
popup
);
g_signal_connect
(
popup
->
priv
->
results_list
,
"row-activated"
,
G_CALLBACK
(
results_list_
on_
row_activated
),
G_CALLBACK
(
results_list_row_activated
),
popup
);
/* Default size of the search popup showing the result list is half
...
...
@@ -438,22 +442,22 @@ gimp_search_popup_get_property (GObject *object,
}
}
void
static
void
gimp_search_popup_size_allocate
(
GtkWidget
*
widget
,
GtkAllocation
*
allocation
)
{
GimpSearchPopup
*
popup
=
GIMP_SEARCH_POPUP
(
widget
);
GTK_WIDGET_CLASS
(
parent_class
)
->
size_allocate
(
widget
,
allocation
);
GTK_WIDGET_CLASS
(
parent_class
)
->
size_allocate
(
widget
,
allocation
);
if
(
gtk_widget_get_visible
(
widget
)
&&
gtk_widget_get_visible
(
popup
->
priv
->
list_view
))
{
GdkScreen
*
screen
=
gdk_screen_get_default
();
/* I save the window height when results are shown so that resizes
* by the user are saved accross searches. */
/* Save the window height when results are shown so that resizes
* by the user are saved accross searches.
*/
window_height
=
MAX
(
gdk_screen_get_height
(
screen
)
/
4
,
allocation
->
height
);
}
...
...
@@ -468,9 +472,9 @@ gimp_search_popup_confirm (GimpPopup *popup)
}
static
gboolean
keyword_entry_
on_
key_press_event
(
GtkWidget
*
widget
,
GdkEventKey
*
event
,
GimpSearchPopup
*
popup
)
keyword_entry_key_press_event
(
GtkWidget
*
widget
,
GdkEventKey
*
event
,
GimpSearchPopup
*
popup
)
{
gboolean
event_processed
=
FALSE
;
...
...
@@ -492,9 +496,9 @@ keyword_entry_on_key_press_event (GtkWidget *widget,
}
static
gboolean
keyword_entry_
on_
key_release_event
(
GtkWidget
*
widget
,
GdkEventKey
*
event
,
GimpSearchPopup
*
popup
)
keyword_entry_key_release_event
(
GtkWidget
*
widget
,
GdkEventKey
*
event
,
GimpSearchPopup
*
popup
)
{
GtkTreeView
*
tree_view
=
GTK_TREE_VIEW
(
popup
->
priv
->
results_list
);
gchar
*
entry_text
;
...
...
@@ -563,9 +567,9 @@ keyword_entry_on_key_release_event (GtkWidget *widget,
}
static
gboolean
results_list_
on_
key_press_event
(
GtkWidget
*
widget
,
GdkEventKey
*
kevent
,
GimpSearchPopup
*
popup
)
results_list_key_press_event
(
GtkWidget
*
widget
,
GdkEventKey
*
kevent
,
GimpSearchPopup
*
popup
)
{
/* These keys are already managed by key bindings. */
g_return_val_if_fail
(
kevent
->
keyval
!=
GDK_KEY_Escape
&&
...
...
@@ -632,10 +636,10 @@ results_list_on_key_press_event (GtkWidget *widget,
}
static
void
results_list_
on_
row_activated
(
GtkTreeView
*
treeview
,
GtkTreePath
*
path
,
GtkTreeViewColumn
*
col
,
GimpSearchPopup
*
popup
)
results_list_row_activated
(
GtkTreeView
*
treeview
,
GtkTreePath
*
path
,
GtkTreeViewColumn
*
col
,
GimpSearchPopup
*
popup
)
{
gimp_search_popup_run_selected
(
popup
);
}
...
...
@@ -659,6 +663,7 @@ gimp_search_popup_run_selected (GimpSearchPopup *popup)
if
(
gtk_action_is_sensitive
(
action
))
{
gtk_action_activate
(
action
);
/* Close the search popup on activation. */
GIMP_POPUP_CLASS
(
parent_class
)
->
cancel
(
GIMP_POPUP
(
popup
));
}
...
...
@@ -676,7 +681,7 @@ gimp_search_popup_setup_results (GtkWidget **results_list,
GtkCellRenderer
*
cell
;
GtkTreeViewColumn
*
column
;
*
list_view
=
GTK_WIDGET
(
gtk_scrolled_window_new
(
NULL
,
NULL
)
)
;
*
list_view
=
gtk_scrolled_window_new
(
NULL
,
NULL
);
store
=
gtk_list_store_new
(
N_COL
,
G_TYPE_STRING
,
G_TYPE_STRING
,
...
...
@@ -684,7 +689,7 @@ gimp_search_popup_setup_results (GtkWidget **results_list,
GTK_TYPE_ACTION
,
G_TYPE_BOOLEAN
,
G_TYPE_INT
);
*
results_list
=
GTK_WIDGET
(
gtk_tree_view_new_with_model
(
GTK_TREE_MODEL
(
store
))
)
;
*
results_list
=
gtk_tree_view_new_with_model
(
GTK_TREE_MODEL
(
store
));
gtk_tree_view_set_headers_visible
(
GTK_TREE_VIEW
(
*
results_list
),
FALSE
);
#ifdef GIMP_UNSTABLE
gtk_tree_view_set_tooltip_column
(
GTK_TREE_VIEW
(
*
results_list
),
...
...
@@ -730,26 +735,28 @@ gimp_search_popup_find_accel_label (GtkAction *action)
accel_closure
=
gtk_action_get_accel_closure
(
action
);
if
(
accel_closure
)
{
GtkAccelKey
*
key
;
key
=
gtk_accel_group_find
(
accel_group
,
gimp_search_popup_view_accel_find_func
,
accel_closure
);
if
(
key
&&
key
->
accel_key
&&
key
->
accel_flags
&
GTK_ACCEL_VISIBLE
)
{
accel_key
=
key
->
accel_key
;
accel_mask
=
key
->
accel_mods
;
}
}
{
GtkAccelKey
*
key
;
key
=
gtk_accel_group_find
(
accel_group
,
gimp_search_popup_view_accel_find_func
,
accel_closure
);
if
(
key
&&
key
->
accel_key
&&
key
->
accel_flags
&
GTK_ACCEL_VISIBLE
)
{
accel_key
=
key
->
accel_key
;
accel_mask
=
key
->
accel_mods
;
}
}
accel_string
=
gtk_accelerator_get_label
(
accel_key
,
accel_mask
);
if
(
strcmp
(
g_strstrip
(
accel_string
),
""
)
==
0
)
{
/* The value returned by gtk_accelerator_get_label() must be freed after use. */
/* The value returned by gtk_accelerator_get_label() must be
* freed after use.
*/
g_free
(
accel_string
);
accel_string
=
NULL
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment