mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
sysprof: use gtk widget actions for window
This commit is contained in:
@ -65,11 +65,9 @@ sysprof_window_notify_can_replay_cb (SysprofWindow *self,
|
|||||||
g_assert (SYSPROF_IS_WINDOW (self));
|
g_assert (SYSPROF_IS_WINDOW (self));
|
||||||
g_assert (SYSPROF_IS_NOTEBOOK (notebook));
|
g_assert (SYSPROF_IS_NOTEBOOK (notebook));
|
||||||
|
|
||||||
#if 0
|
gtk_widget_action_set_enabled (GTK_WIDGET (self),
|
||||||
dzl_gtk_widget_action_set (GTK_WIDGET (self), "win", "replay-capture",
|
"win.replay-capture",
|
||||||
"enabled", sysprof_notebook_get_can_replay (notebook),
|
sysprof_notebook_get_can_replay (notebook));
|
||||||
NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -80,19 +78,17 @@ sysprof_window_notify_can_save_cb (SysprofWindow *self,
|
|||||||
g_assert (SYSPROF_IS_WINDOW (self));
|
g_assert (SYSPROF_IS_WINDOW (self));
|
||||||
g_assert (SYSPROF_IS_NOTEBOOK (notebook));
|
g_assert (SYSPROF_IS_NOTEBOOK (notebook));
|
||||||
|
|
||||||
#if 0
|
gtk_widget_action_set_enabled (GTK_WIDGET (self),
|
||||||
dzl_gtk_widget_action_set (GTK_WIDGET (self), "win", "save-capture",
|
"win.save-capture",
|
||||||
"enabled", sysprof_notebook_get_can_save (notebook),
|
sysprof_notebook_get_can_save (notebook));
|
||||||
NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
new_tab_cb (GSimpleAction *action,
|
new_tab_cb (GtkWidget *widget,
|
||||||
GVariant *param,
|
const char *action_name,
|
||||||
gpointer user_data)
|
GVariant *param)
|
||||||
{
|
{
|
||||||
SysprofWindow *self = user_data;
|
SysprofWindow *self = (SysprofWindow *)widget;
|
||||||
|
|
||||||
g_return_if_fail (SYSPROF_IS_WINDOW (self));
|
g_return_if_fail (SYSPROF_IS_WINDOW (self));
|
||||||
|
|
||||||
@ -100,12 +96,12 @@ new_tab_cb (GSimpleAction *action,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
switch_tab_cb (GSimpleAction *action,
|
switch_tab_cb (GtkWidget *widget,
|
||||||
GVariant *param,
|
const char *action_name,
|
||||||
gpointer user_data)
|
GVariant *param)
|
||||||
{
|
{
|
||||||
SysprofWindow *self = user_data;
|
SysprofWindow *self = (SysprofWindow *)widget;
|
||||||
gint page;
|
int page;
|
||||||
|
|
||||||
g_return_if_fail (SYSPROF_IS_WINDOW (self));
|
g_return_if_fail (SYSPROF_IS_WINDOW (self));
|
||||||
g_return_if_fail (g_variant_is_of_type (param, G_VARIANT_TYPE_INT32));
|
g_return_if_fail (g_variant_is_of_type (param, G_VARIANT_TYPE_INT32));
|
||||||
@ -115,11 +111,11 @@ switch_tab_cb (GSimpleAction *action,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
close_tab_cb (GSimpleAction *action,
|
close_tab_cb (GtkWidget *widget,
|
||||||
GVariant *param,
|
const char *action_name,
|
||||||
gpointer user_data)
|
GVariant *param)
|
||||||
{
|
{
|
||||||
SysprofWindow *self = user_data;
|
SysprofWindow *self = (SysprofWindow *)widget;
|
||||||
|
|
||||||
g_return_if_fail (SYSPROF_IS_WINDOW (self));
|
g_return_if_fail (SYSPROF_IS_WINDOW (self));
|
||||||
|
|
||||||
@ -139,34 +135,37 @@ close_tab_cb (GSimpleAction *action,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
replay_capture_cb (GSimpleAction *action,
|
replay_capture_cb (GtkWidget *widget,
|
||||||
GVariant *param,
|
const char *action_name,
|
||||||
gpointer user_data)
|
GVariant *param)
|
||||||
{
|
{
|
||||||
SysprofWindow *self = user_data;
|
SysprofWindow *self = (SysprofWindow *)widget;
|
||||||
|
|
||||||
g_return_if_fail (SYSPROF_IS_WINDOW (self));
|
g_return_if_fail (SYSPROF_IS_WINDOW (self));
|
||||||
|
|
||||||
sysprof_notebook_replay (self->notebook);
|
sysprof_notebook_replay (self->notebook);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
save_capture_cb (GSimpleAction *action,
|
save_capture_cb (GtkWidget *widget,
|
||||||
GVariant *param,
|
const char *action_name,
|
||||||
gpointer user_data)
|
GVariant *param)
|
||||||
{
|
{
|
||||||
SysprofWindow *self = user_data;
|
SysprofWindow *self = (SysprofWindow *)widget;
|
||||||
|
|
||||||
g_return_if_fail (SYSPROF_IS_WINDOW (self));
|
g_return_if_fail (SYSPROF_IS_WINDOW (self));
|
||||||
|
|
||||||
sysprof_notebook_save (self->notebook);
|
sysprof_notebook_save (self->notebook);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
stop_recording_cb (GSimpleAction *action,
|
stop_recording_cb (GtkWidget *widget,
|
||||||
GVariant *param,
|
const char *action_name,
|
||||||
gpointer user_data)
|
GVariant *param)
|
||||||
{
|
{
|
||||||
SysprofWindow *self = user_data;
|
SysprofWindow *self = (SysprofWindow *)widget;
|
||||||
SysprofDisplay *current;
|
SysprofDisplay *current;
|
||||||
|
|
||||||
g_assert (G_IS_SIMPLE_ACTION (action));
|
|
||||||
g_assert (SYSPROF_IS_WINDOW (self));
|
g_assert (SYSPROF_IS_WINDOW (self));
|
||||||
|
|
||||||
if ((current = sysprof_notebook_get_current (self->notebook)))
|
if ((current = sysprof_notebook_get_current (self->notebook)))
|
||||||
@ -197,16 +196,14 @@ sysprof_window_class_init (SysprofWindowClass *klass)
|
|||||||
gtk_widget_class_bind_template_child (widget_class, SysprofWindow, open_button);
|
gtk_widget_class_bind_template_child (widget_class, SysprofWindow, open_button);
|
||||||
gtk_widget_class_bind_template_child (widget_class, SysprofWindow, notebook);
|
gtk_widget_class_bind_template_child (widget_class, SysprofWindow, notebook);
|
||||||
|
|
||||||
#if 0
|
gtk_widget_class_install_action (widget_class, "win.close-tab", NULL, close_tab_cb);
|
||||||
/* Switch to GtkShortcutController class bindings */
|
gtk_widget_class_install_action (widget_class, "win.new-tab", NULL, new_tab_cb);
|
||||||
DzlShortcutController *controller;
|
gtk_widget_class_install_action (widget_class, "win.switch-tab", "i", switch_tab_cb);
|
||||||
controller = dzl_shortcut_controller_find (GTK_WIDGET (self));
|
gtk_widget_class_install_action (widget_class, "win.replay-capture", NULL, replay_capture_cb);
|
||||||
dzl_shortcut_controller_add_command_action (controller,
|
gtk_widget_class_install_action (widget_class, "win.save-capture", NULL, save_capture_cb);
|
||||||
"org.gnome.sysprof3.stop-recording",
|
gtk_widget_class_install_action (widget_class, "win.stop-recording", NULL, stop_recording_cb);
|
||||||
"Escape",
|
|
||||||
DZL_SHORTCUT_PHASE_BUBBLE,
|
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_Escape, 0, "win.stop-recording", NULL);
|
||||||
"win.stop-recording");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_type_ensure (SYSPROF_TYPE_NOTEBOOK);
|
g_type_ensure (SYSPROF_TYPE_NOTEBOOK);
|
||||||
g_type_ensure (SYSPROF_TYPE_DISPLAY);
|
g_type_ensure (SYSPROF_TYPE_DISPLAY);
|
||||||
@ -215,14 +212,6 @@ sysprof_window_class_init (SysprofWindowClass *klass)
|
|||||||
static void
|
static void
|
||||||
sysprof_window_init (SysprofWindow *self)
|
sysprof_window_init (SysprofWindow *self)
|
||||||
{
|
{
|
||||||
static GActionEntry actions[] = {
|
|
||||||
{ "close-tab", close_tab_cb },
|
|
||||||
{ "new-tab", new_tab_cb },
|
|
||||||
{ "switch-tab", switch_tab_cb, "i" },
|
|
||||||
{ "replay-capture", replay_capture_cb },
|
|
||||||
{ "save-capture", save_capture_cb },
|
|
||||||
{ "stop-recording", stop_recording_cb },
|
|
||||||
};
|
|
||||||
GMenu *menu;
|
GMenu *menu;
|
||||||
|
|
||||||
gtk_widget_init_template (GTK_WIDGET (self));
|
gtk_widget_init_template (GTK_WIDGET (self));
|
||||||
@ -230,11 +219,6 @@ sysprof_window_init (SysprofWindow *self)
|
|||||||
menu = gtk_application_get_menu_by_id (GTK_APPLICATION (g_application_get_default ()), "win-menu");
|
menu = gtk_application_get_menu_by_id (GTK_APPLICATION (g_application_get_default ()), "win-menu");
|
||||||
gtk_menu_button_set_menu_model (self->menu_button, G_MENU_MODEL (menu));
|
gtk_menu_button_set_menu_model (self->menu_button, G_MENU_MODEL (menu));
|
||||||
|
|
||||||
g_action_map_add_action_entries (G_ACTION_MAP (self),
|
|
||||||
actions,
|
|
||||||
G_N_ELEMENTS (actions),
|
|
||||||
self);
|
|
||||||
|
|
||||||
g_signal_connect_object (self->notebook,
|
g_signal_connect_object (self->notebook,
|
||||||
"notify::can-replay",
|
"notify::can-replay",
|
||||||
G_CALLBACK (sysprof_window_notify_can_replay_cb),
|
G_CALLBACK (sysprof_window_notify_can_replay_cb),
|
||||||
@ -252,15 +236,8 @@ sysprof_window_init (SysprofWindow *self)
|
|||||||
g_object_bind_property (self->notebook, "current", self->bindings, "source",
|
g_object_bind_property (self->notebook, "current", self->bindings, "source",
|
||||||
G_BINDING_SYNC_CREATE);
|
G_BINDING_SYNC_CREATE);
|
||||||
|
|
||||||
#if 0
|
gtk_widget_action_set_enabled (GTK_WIDGET (self), "win.save-capture", FALSE);
|
||||||
/* Switch to using gtk_widget_action_set_enabled() */
|
gtk_widget_action_set_enabled (GTK_WIDGET (self), "win.replay-capture", FALSE);
|
||||||
dzl_gtk_widget_action_set (GTK_WIDGET (self), "win", "save-capture",
|
|
||||||
"enabled", FALSE,
|
|
||||||
NULL);
|
|
||||||
dzl_gtk_widget_action_set (GTK_WIDGET (self), "win", "replay-capture",
|
|
||||||
"enabled", FALSE,
|
|
||||||
NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user