639 lines
24 KiB
Diff
639 lines
24 KiB
Diff
From d9c897c8b91165f95f011d44f2fea731b4b7eb16 Mon Sep 17 00:00:00 2001
|
|
From: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
|
Date: Wed, 10 Nov 2021 15:32:18 -0300
|
|
Subject: [PATCH] screencast: Trivial style cleanups
|
|
|
|
Move some code around, and cleanup some of the styling.
|
|
It's getting increasingly harder to follow these files,
|
|
so start this series of cleanups with them.
|
|
---
|
|
src/screencast.c | 30 ++--
|
|
src/screencastdialog.c | 62 +++----
|
|
src/screencastdialog.h | 2 +-
|
|
src/screencastwidget.c | 356 +++++++++++++++++++++--------------------
|
|
src/screencastwidget.h | 10 +-
|
|
5 files changed, 238 insertions(+), 222 deletions(-)
|
|
|
|
diff --git a/src/gnomescreencast.c b/src/gnomescreencast.c
|
|
index fd80ca7..abf5b53 100644
|
|
--- a/src/gnomescreencast.c
|
|
+++ b/src/gnomescreencast.c
|
|
@@ -473,6 +473,7 @@ gnome_screen_cast_session_record_selections (GnomeScreenCastSession *gnome_scree
|
|
select,
|
|
error))
|
|
return FALSE;
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
diff --git a/src/screencast.c b/src/screencast.c
|
|
index 27d8946..38d1d05 100644
|
|
--- a/src/screencast.c
|
|
+++ b/src/screencast.c
|
|
@@ -572,21 +572,6 @@ on_gnome_screen_cast_disabled (GDBusConnection *connection,
|
|
}
|
|
}
|
|
|
|
-gboolean
|
|
-screen_cast_init (GDBusConnection *connection,
|
|
- GError **error)
|
|
-{
|
|
- impl_connection = connection;
|
|
- gnome_screen_cast = gnome_screen_cast_new (connection);
|
|
-
|
|
- g_signal_connect (gnome_screen_cast, "enabled",
|
|
- G_CALLBACK (on_gnome_screen_cast_enabled), NULL);
|
|
- g_signal_connect (gnome_screen_cast, "disabled",
|
|
- G_CALLBACK (on_gnome_screen_cast_disabled), NULL);
|
|
-
|
|
- return TRUE;
|
|
-}
|
|
-
|
|
static void
|
|
screen_cast_session_close (Session *session)
|
|
{
|
|
@@ -636,3 +621,18 @@ screen_cast_session_class_init (ScreenCastSessionClass *klass)
|
|
session_class = (SessionClass *)klass;
|
|
session_class->close = screen_cast_session_close;
|
|
}
|
|
+
|
|
+gboolean
|
|
+screen_cast_init (GDBusConnection *connection,
|
|
+ GError **error)
|
|
+{
|
|
+ impl_connection = connection;
|
|
+ gnome_screen_cast = gnome_screen_cast_new (connection);
|
|
+
|
|
+ g_signal_connect (gnome_screen_cast, "enabled",
|
|
+ G_CALLBACK (on_gnome_screen_cast_enabled), NULL);
|
|
+ g_signal_connect (gnome_screen_cast, "disabled",
|
|
+ G_CALLBACK (on_gnome_screen_cast_disabled), NULL);
|
|
+
|
|
+ return TRUE;
|
|
+}
|
|
diff --git a/src/screencastdialog.c b/src/screencastdialog.c
|
|
index 306992d..56d4d49 100644
|
|
--- a/src/screencastdialog.c
|
|
+++ b/src/screencastdialog.c
|
|
@@ -51,6 +51,10 @@ static guint signals[N_SIGNALS];
|
|
|
|
G_DEFINE_TYPE (ScreenCastDialog, screen_cast_dialog, GTK_TYPE_WINDOW)
|
|
|
|
+/*
|
|
+ * Callbacks
|
|
+ */
|
|
+
|
|
static void
|
|
button_clicked (GtkWidget *button,
|
|
ScreenCastDialog *dialog)
|
|
@@ -84,7 +88,7 @@ button_clicked (GtkWidget *button,
|
|
|
|
static void
|
|
on_has_selection_changed (ScreenCastWidget *screen_cast_widget,
|
|
- gboolean has_selection,
|
|
+ gboolean has_selection,
|
|
ScreenCastDialog *dialog)
|
|
{
|
|
if (has_selection)
|
|
@@ -93,32 +97,9 @@ on_has_selection_changed (ScreenCastWidget *screen_cast_widget,
|
|
gtk_widget_set_sensitive (dialog->accept_button, FALSE);
|
|
}
|
|
|
|
-ScreenCastDialog *
|
|
-screen_cast_dialog_new (const char *app_id,
|
|
- ScreenCastSelection *select)
|
|
-{
|
|
- ScreenCastDialog *dialog;
|
|
- ScreenCastWidget *screen_cast_widget;
|
|
-
|
|
- dialog = g_object_new (SCREEN_CAST_TYPE_DIALOG, NULL);
|
|
- screen_cast_widget = SCREEN_CAST_WIDGET (dialog->screen_cast_widget);
|
|
- screen_cast_widget_set_app_id (screen_cast_widget, app_id);
|
|
- screen_cast_widget_set_allow_multiple (screen_cast_widget, select->multiple);
|
|
- screen_cast_widget_set_source_types (screen_cast_widget,
|
|
- select->source_types);
|
|
-
|
|
- return dialog;
|
|
-}
|
|
-
|
|
-static void
|
|
-screen_cast_dialog_init (ScreenCastDialog *dialog)
|
|
-{
|
|
- gtk_widget_init_template (GTK_WIDGET (dialog));
|
|
-
|
|
- g_signal_connect (dialog->screen_cast_widget, "has-selection-changed",
|
|
- G_CALLBACK (on_has_selection_changed), dialog);
|
|
- gtk_widget_show (dialog->screen_cast_widget);
|
|
-}
|
|
+/*
|
|
+ * GtkWindow overrides
|
|
+ */
|
|
|
|
static gboolean
|
|
screen_cast_dialog_close_request (GtkWindow *dialog)
|
|
@@ -155,3 +136,30 @@ screen_cast_dialog_class_init (ScreenCastDialogClass *klass)
|
|
gtk_widget_class_bind_template_child (widget_class, ScreenCastDialog, screen_cast_widget);
|
|
gtk_widget_class_bind_template_callback (widget_class, button_clicked);
|
|
}
|
|
+
|
|
+static void
|
|
+screen_cast_dialog_init (ScreenCastDialog *dialog)
|
|
+{
|
|
+ gtk_widget_init_template (GTK_WIDGET (dialog));
|
|
+
|
|
+ g_signal_connect (dialog->screen_cast_widget, "has-selection-changed",
|
|
+ G_CALLBACK (on_has_selection_changed), dialog);
|
|
+ gtk_widget_show (dialog->screen_cast_widget);
|
|
+}
|
|
+
|
|
+ScreenCastDialog *
|
|
+screen_cast_dialog_new (const char *app_id,
|
|
+ ScreenCastSelection *select)
|
|
+{
|
|
+ ScreenCastDialog *dialog;
|
|
+ ScreenCastWidget *screen_cast_widget;
|
|
+
|
|
+ dialog = g_object_new (SCREEN_CAST_TYPE_DIALOG, NULL);
|
|
+ screen_cast_widget = SCREEN_CAST_WIDGET (dialog->screen_cast_widget);
|
|
+ screen_cast_widget_set_app_id (screen_cast_widget, app_id);
|
|
+ screen_cast_widget_set_allow_multiple (screen_cast_widget, select->multiple);
|
|
+ screen_cast_widget_set_source_types (screen_cast_widget,
|
|
+ select->source_types);
|
|
+
|
|
+ return dialog;
|
|
+}
|
|
diff --git a/src/screencastdialog.h b/src/screencastdialog.h
|
|
index 247d93b..1fca470 100644
|
|
--- a/src/screencastdialog.h
|
|
+++ b/src/screencastdialog.h
|
|
@@ -26,5 +26,5 @@
|
|
G_DECLARE_FINAL_TYPE (ScreenCastDialog, screen_cast_dialog,
|
|
SCREEN_CAST, DIALOG, GtkWindow)
|
|
|
|
-ScreenCastDialog * screen_cast_dialog_new (const char *app_id,
|
|
+ScreenCastDialog * screen_cast_dialog_new (const char *app_id,
|
|
ScreenCastSelection *select);
|
|
diff --git a/src/screencastwidget.c b/src/screencastwidget.c
|
|
index cdd57dc..454c93e 100644
|
|
--- a/src/screencastwidget.c
|
|
+++ b/src/screencastwidget.c
|
|
@@ -65,6 +65,55 @@ static GQuark quark_window_widget_data;
|
|
|
|
G_DEFINE_TYPE (ScreenCastWidget, screen_cast_widget, GTK_TYPE_BOX)
|
|
|
|
+/*
|
|
+ * Auxiliary methods
|
|
+ */
|
|
+
|
|
+static gboolean
|
|
+add_selections (ScreenCastWidget *widget,
|
|
+ GVariantBuilder *source_selections_builder)
|
|
+{
|
|
+ GList *selected_monitor_rows;
|
|
+ GList *selected_window_rows;
|
|
+ GList *l;
|
|
+
|
|
+ selected_monitor_rows =
|
|
+ gtk_list_box_get_selected_rows (GTK_LIST_BOX (widget->monitor_list));
|
|
+ selected_window_rows =
|
|
+ gtk_list_box_get_selected_rows (GTK_LIST_BOX (widget->window_list));
|
|
+ if (!selected_monitor_rows && !selected_window_rows)
|
|
+ return FALSE;
|
|
+
|
|
+ for (l = selected_monitor_rows; l; l = l->next)
|
|
+ {
|
|
+ GtkWidget *monitor_widget = gtk_list_box_row_get_child (l->data);
|
|
+ Monitor *monitor;
|
|
+
|
|
+ monitor = g_object_get_qdata (G_OBJECT (monitor_widget),
|
|
+ quark_monitor_widget_data);
|
|
+
|
|
+ g_variant_builder_add (source_selections_builder, "(us)",
|
|
+ SCREEN_CAST_SOURCE_TYPE_MONITOR,
|
|
+ monitor_get_connector (monitor));
|
|
+ }
|
|
+ g_list_free (selected_monitor_rows);
|
|
+ for (l = selected_window_rows; l; l = l->next)
|
|
+ {
|
|
+ GtkWidget *window_widget = gtk_list_box_row_get_child (l->data);
|
|
+ Window *window;
|
|
+
|
|
+ window = g_object_get_qdata (G_OBJECT (window_widget),
|
|
+ quark_window_widget_data);
|
|
+
|
|
+ g_variant_builder_add (source_selections_builder, "(ut)",
|
|
+ SCREEN_CAST_SOURCE_TYPE_WINDOW,
|
|
+ window_get_id (window));
|
|
+ }
|
|
+ g_list_free (selected_window_rows);
|
|
+
|
|
+ return TRUE;
|
|
+}
|
|
+
|
|
static GtkWidget *
|
|
create_window_widget (Window *window)
|
|
{
|
|
@@ -131,7 +180,7 @@ create_monitor_widget (LogicalMonitor *logical_monitor)
|
|
}
|
|
|
|
static gboolean
|
|
-should_skip_window (Window *window,
|
|
+should_skip_window (Window *window,
|
|
GtkWindow *toplevel)
|
|
{
|
|
g_autofree char *processed_app_id = NULL;
|
|
@@ -254,7 +303,7 @@ unselect_rows (GtkListBox *listbox)
|
|
}
|
|
|
|
static void
|
|
-on_windows_changed (ShellIntrospect *shell_introspect,
|
|
+on_windows_changed (ShellIntrospect *shell_introspect,
|
|
ScreenCastWidget *widget)
|
|
{
|
|
update_windows_list (widget);
|
|
@@ -283,9 +332,9 @@ disconnect_windows_changed_listener (ScreenCastWidget *widget)
|
|
}
|
|
|
|
static void
|
|
-on_stack_switch (GtkStack *stack,
|
|
+on_stack_switch (GtkStack *stack,
|
|
GParamSpec *pspec,
|
|
- gpointer *data)
|
|
+ gpointer *data)
|
|
{
|
|
ScreenCastWidget *widget = (ScreenCastWidget *)data;
|
|
GtkWidget *visible_child;
|
|
@@ -307,9 +356,9 @@ on_stack_switch (GtkStack *stack,
|
|
}
|
|
|
|
static void
|
|
-on_row_activated (GtkListBox *box,
|
|
+on_row_activated (GtkListBox *box,
|
|
GtkListBoxRow *row,
|
|
- gpointer *data)
|
|
+ gpointer *data)
|
|
{
|
|
if (!row)
|
|
return;
|
|
@@ -378,7 +427,7 @@ schedule_selection_change (ScreenCastWidget *widget)
|
|
}
|
|
|
|
static void
|
|
-on_selected_rows_changed (GtkListBox *box,
|
|
+on_selected_rows_changed (GtkListBox *box,
|
|
ScreenCastWidget *widget)
|
|
{
|
|
/* GtkListBox activates rows after selecting them, which prevents
|
|
@@ -403,59 +452,128 @@ update_list_box_header (GtkListBoxRow *row,
|
|
|
|
static void
|
|
on_monitors_changed (DisplayStateTracker *display_state_tracker,
|
|
- ScreenCastWidget *widget)
|
|
+ ScreenCastWidget *widget)
|
|
{
|
|
update_monitors_list (widget);
|
|
}
|
|
|
|
-static gboolean
|
|
-add_selections (ScreenCastWidget *widget,
|
|
- GVariantBuilder *source_selections_builder)
|
|
+/*
|
|
+ * GObject overrides
|
|
+ */
|
|
+
|
|
+static void
|
|
+screen_cast_widget_finalize (GObject *object)
|
|
{
|
|
- GList *selected_monitor_rows;
|
|
- GList *selected_window_rows;
|
|
- GList *l;
|
|
+ ScreenCastWidget *widget = SCREEN_CAST_WIDGET (object);
|
|
|
|
- selected_monitor_rows =
|
|
- gtk_list_box_get_selected_rows (GTK_LIST_BOX (widget->monitor_list));
|
|
- selected_window_rows =
|
|
- gtk_list_box_get_selected_rows (GTK_LIST_BOX (widget->window_list));
|
|
- if (!selected_monitor_rows && !selected_window_rows)
|
|
- return FALSE;
|
|
+ g_signal_handler_disconnect (widget->display_state_tracker,
|
|
+ widget->monitors_changed_handler_id);
|
|
|
|
- for (l = selected_monitor_rows; l; l = l->next)
|
|
+ if (widget->windows_changed_handler_id)
|
|
+ disconnect_windows_changed_listener (widget);
|
|
+
|
|
+ if (widget->selection_changed_timeout_id > 0)
|
|
{
|
|
- GtkWidget *monitor_widget = gtk_list_box_row_get_child (l->data);
|
|
- Monitor *monitor;
|
|
+ g_source_remove (widget->selection_changed_timeout_id);
|
|
+ widget->selection_changed_timeout_id = 0;
|
|
+ }
|
|
|
|
- monitor = g_object_get_qdata (G_OBJECT (monitor_widget),
|
|
- quark_monitor_widget_data);
|
|
+ G_OBJECT_CLASS (screen_cast_widget_parent_class)->finalize (object);
|
|
+}
|
|
|
|
- g_variant_builder_add (source_selections_builder, "(us)",
|
|
- SCREEN_CAST_SOURCE_TYPE_MONITOR,
|
|
- monitor_get_connector (monitor));
|
|
- }
|
|
- g_list_free (selected_monitor_rows);
|
|
- for (l = selected_window_rows; l; l = l->next)
|
|
- {
|
|
- GtkWidget *window_widget = gtk_list_box_row_get_child (l->data);
|
|
- Window *window;
|
|
+static void
|
|
+screen_cast_widget_class_init (ScreenCastWidgetClass *klass)
|
|
+{
|
|
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
- window = g_object_get_qdata (G_OBJECT (window_widget),
|
|
- quark_window_widget_data);
|
|
+ object_class->finalize = screen_cast_widget_finalize;
|
|
|
|
- g_variant_builder_add (source_selections_builder, "(ut)",
|
|
- SCREEN_CAST_SOURCE_TYPE_WINDOW,
|
|
- window_get_id (window));
|
|
- }
|
|
- g_list_free (selected_window_rows);
|
|
+ signals[HAS_SELECTION_CHANGED] = g_signal_new ("has-selection-changed",
|
|
+ G_TYPE_FROM_CLASS (klass),
|
|
+ G_SIGNAL_RUN_LAST,
|
|
+ 0,
|
|
+ NULL, NULL,
|
|
+ NULL,
|
|
+ G_TYPE_NONE, 1,
|
|
+ G_TYPE_BOOLEAN);
|
|
|
|
- return TRUE;
|
|
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/freedesktop/portal/desktop/gnome/screencastwidget.ui");
|
|
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, source_type_switcher);
|
|
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, source_type);
|
|
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, monitor_selection);
|
|
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, window_selection);
|
|
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, monitor_heading);
|
|
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, monitor_list);
|
|
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, window_heading);
|
|
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, window_list);
|
|
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, window_list_scrolled);
|
|
+
|
|
+ quark_monitor_widget_data = g_quark_from_static_string ("-monitor-widget-connector-quark");
|
|
+ quark_window_widget_data = g_quark_from_static_string ("-window-widget-connector-quark");
|
|
+}
|
|
+
|
|
+static void
|
|
+screen_cast_widget_init (ScreenCastWidget *widget)
|
|
+{
|
|
+ GtkScrolledWindow *scrolled_window;
|
|
+ GtkAdjustment *vadjustment;
|
|
+
|
|
+ gtk_widget_init_template (GTK_WIDGET (widget));
|
|
+
|
|
+ screen_cast_widget_set_app_id (widget, NULL);
|
|
+ screen_cast_widget_set_allow_multiple (widget, FALSE);
|
|
+
|
|
+ gtk_list_box_set_header_func (GTK_LIST_BOX (widget->monitor_list),
|
|
+ update_list_box_header,
|
|
+ NULL, NULL);
|
|
+ gtk_list_box_set_header_func (GTK_LIST_BOX (widget->window_list),
|
|
+ update_list_box_header,
|
|
+ NULL, NULL);
|
|
+ scrolled_window = GTK_SCROLLED_WINDOW (widget->window_list_scrolled);
|
|
+ vadjustment = gtk_scrolled_window_get_vadjustment (scrolled_window);
|
|
+ gtk_list_box_set_adjustment (GTK_LIST_BOX (widget->window_list), vadjustment);
|
|
+
|
|
+ g_signal_connect (widget->source_type, "notify::visible-child",
|
|
+ G_CALLBACK (on_stack_switch),
|
|
+ widget);
|
|
+ g_signal_connect (widget->monitor_list, "row-activated",
|
|
+ G_CALLBACK (on_row_activated),
|
|
+ NULL);
|
|
+ g_signal_connect (widget->window_list, "row-activated",
|
|
+ G_CALLBACK (on_row_activated),
|
|
+ NULL);
|
|
+ g_signal_connect (widget->monitor_list, "selected-rows-changed",
|
|
+ G_CALLBACK (on_selected_rows_changed),
|
|
+ widget);
|
|
+ g_signal_connect (widget->window_list, "selected-rows-changed",
|
|
+ G_CALLBACK (on_selected_rows_changed),
|
|
+ widget);
|
|
+
|
|
+ widget->display_state_tracker = display_state_tracker_get ();
|
|
+ widget->monitors_changed_handler_id =
|
|
+ g_signal_connect (widget->display_state_tracker,
|
|
+ "monitors-changed",
|
|
+ G_CALLBACK (on_monitors_changed),
|
|
+ widget);
|
|
+ widget->shell_introspect = shell_introspect_get ();
|
|
+
|
|
+ update_monitors_list (widget);
|
|
+ update_windows_list (widget);
|
|
+
|
|
+ gtk_widget_show (widget->monitor_list);
|
|
+ gtk_widget_show (widget->window_list);
|
|
+}
|
|
+
|
|
+void
|
|
+init_screen_cast_widget (void)
|
|
+{
|
|
+ g_type_ensure (screen_cast_widget_get_type ());
|
|
}
|
|
|
|
void
|
|
screen_cast_widget_add_selections (ScreenCastWidget *widget,
|
|
- GVariantBuilder *selections_builder)
|
|
+ GVariantBuilder *selections_builder)
|
|
{
|
|
GVariantBuilder source_selections_builder;
|
|
|
|
@@ -474,7 +592,7 @@ screen_cast_widget_add_selections (ScreenCastWidget *widget,
|
|
|
|
void
|
|
screen_cast_widget_set_app_id (ScreenCastWidget *widget,
|
|
- const char *app_id)
|
|
+ const char *app_id)
|
|
{
|
|
g_autofree char *monitor_heading = NULL;
|
|
g_autofree char *window_heading = NULL;
|
|
@@ -508,7 +626,7 @@ screen_cast_widget_set_app_id (ScreenCastWidget *widget,
|
|
|
|
void
|
|
screen_cast_widget_set_allow_multiple (ScreenCastWidget *widget,
|
|
- gboolean multiple)
|
|
+ gboolean multiple)
|
|
{
|
|
gtk_list_box_set_selection_mode (GTK_LIST_BOX (widget->monitor_list),
|
|
multiple ? GTK_SELECTION_MULTIPLE
|
|
@@ -519,8 +637,8 @@ screen_cast_widget_set_allow_multiple (ScreenCastWidget *widget,
|
|
}
|
|
|
|
void
|
|
-screen_cast_widget_set_source_types (ScreenCastWidget *screen_cast_widget,
|
|
- ScreenCastSourceType source_types)
|
|
+screen_cast_widget_set_source_types (ScreenCastWidget *screen_cast_widget,
|
|
+ ScreenCastSourceType source_types)
|
|
{
|
|
if (source_types & SCREEN_CAST_SOURCE_TYPE_MONITOR)
|
|
gtk_widget_show (screen_cast_widget->monitor_selection);
|
|
@@ -531,113 +649,3 @@ screen_cast_widget_set_source_types (ScreenCastWidget *screen_cast_widget,
|
|
if (__builtin_popcount (source_types) > 1)
|
|
gtk_widget_show (screen_cast_widget->source_type_switcher);
|
|
}
|
|
-
|
|
-static void
|
|
-screen_cast_widget_finalize (GObject *object)
|
|
-{
|
|
- ScreenCastWidget *widget = SCREEN_CAST_WIDGET (object);
|
|
-
|
|
- g_signal_handler_disconnect (widget->display_state_tracker,
|
|
- widget->monitors_changed_handler_id);
|
|
-
|
|
- if (widget->windows_changed_handler_id)
|
|
- disconnect_windows_changed_listener (widget);
|
|
-
|
|
- if (widget->selection_changed_timeout_id > 0)
|
|
- {
|
|
- g_source_remove (widget->selection_changed_timeout_id);
|
|
- widget->selection_changed_timeout_id = 0;
|
|
- }
|
|
-
|
|
- G_OBJECT_CLASS (screen_cast_widget_parent_class)->finalize (object);
|
|
-}
|
|
-
|
|
-static void
|
|
-screen_cast_widget_init (ScreenCastWidget *widget)
|
|
-{
|
|
- GtkScrolledWindow *scrolled_window;
|
|
- GtkAdjustment *vadjustment;
|
|
-
|
|
- gtk_widget_init_template (GTK_WIDGET (widget));
|
|
-
|
|
- screen_cast_widget_set_app_id (widget, NULL);
|
|
- screen_cast_widget_set_allow_multiple (widget, FALSE);
|
|
-
|
|
- gtk_list_box_set_header_func (GTK_LIST_BOX (widget->monitor_list),
|
|
- update_list_box_header,
|
|
- NULL, NULL);
|
|
- gtk_list_box_set_header_func (GTK_LIST_BOX (widget->window_list),
|
|
- update_list_box_header,
|
|
- NULL, NULL);
|
|
- scrolled_window = GTK_SCROLLED_WINDOW (widget->window_list_scrolled);
|
|
- vadjustment = gtk_scrolled_window_get_vadjustment (scrolled_window);
|
|
- gtk_list_box_set_adjustment (GTK_LIST_BOX (widget->window_list), vadjustment);
|
|
-
|
|
- g_signal_connect (widget->source_type, "notify::visible-child",
|
|
- G_CALLBACK (on_stack_switch),
|
|
- widget);
|
|
- g_signal_connect (widget->monitor_list, "row-activated",
|
|
- G_CALLBACK (on_row_activated),
|
|
- NULL);
|
|
- g_signal_connect (widget->window_list, "row-activated",
|
|
- G_CALLBACK (on_row_activated),
|
|
- NULL);
|
|
- g_signal_connect (widget->monitor_list, "selected-rows-changed",
|
|
- G_CALLBACK (on_selected_rows_changed),
|
|
- widget);
|
|
- g_signal_connect (widget->window_list, "selected-rows-changed",
|
|
- G_CALLBACK (on_selected_rows_changed),
|
|
- widget);
|
|
-
|
|
- widget->display_state_tracker = display_state_tracker_get ();
|
|
- widget->monitors_changed_handler_id =
|
|
- g_signal_connect (widget->display_state_tracker,
|
|
- "monitors-changed",
|
|
- G_CALLBACK (on_monitors_changed),
|
|
- widget);
|
|
- widget->shell_introspect = shell_introspect_get ();
|
|
-
|
|
- update_monitors_list (widget);
|
|
- update_windows_list (widget);
|
|
-
|
|
- gtk_widget_show (widget->monitor_list);
|
|
- gtk_widget_show (widget->window_list);
|
|
-}
|
|
-
|
|
-static void
|
|
-screen_cast_widget_class_init (ScreenCastWidgetClass *klass)
|
|
-{
|
|
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
-
|
|
- object_class->finalize = screen_cast_widget_finalize;
|
|
-
|
|
- signals[HAS_SELECTION_CHANGED] = g_signal_new ("has-selection-changed",
|
|
- G_TYPE_FROM_CLASS (klass),
|
|
- G_SIGNAL_RUN_LAST,
|
|
- 0,
|
|
- NULL, NULL,
|
|
- NULL,
|
|
- G_TYPE_NONE, 1,
|
|
- G_TYPE_BOOLEAN);
|
|
-
|
|
- gtk_widget_class_set_template_from_resource (widget_class, "/org/freedesktop/portal/desktop/gnome/screencastwidget.ui");
|
|
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, source_type_switcher);
|
|
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, source_type);
|
|
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, monitor_selection);
|
|
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, window_selection);
|
|
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, monitor_heading);
|
|
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, monitor_list);
|
|
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, window_heading);
|
|
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, window_list);
|
|
- gtk_widget_class_bind_template_child (widget_class, ScreenCastWidget, window_list_scrolled);
|
|
-
|
|
- quark_monitor_widget_data = g_quark_from_static_string ("-monitor-widget-connector-quark");
|
|
- quark_window_widget_data = g_quark_from_static_string ("-window-widget-connector-quark");
|
|
-}
|
|
-
|
|
-void
|
|
-init_screen_cast_widget (void)
|
|
-{
|
|
- g_type_ensure (screen_cast_widget_get_type ());
|
|
-}
|
|
diff --git a/src/screencastwidget.h b/src/screencastwidget.h
|
|
index 3a1ebd2..34360a3 100644
|
|
--- a/src/screencastwidget.h
|
|
+++ b/src/screencastwidget.h
|
|
@@ -31,13 +31,13 @@ G_DECLARE_FINAL_TYPE (ScreenCastWidget, screen_cast_widget,
|
|
void init_screen_cast_widget (void);
|
|
|
|
void screen_cast_widget_set_app_id (ScreenCastWidget *widget,
|
|
- const char *app_id);
|
|
+ const char *app_id);
|
|
|
|
void screen_cast_widget_set_allow_multiple (ScreenCastWidget *widget,
|
|
- gboolean multiple);
|
|
+ gboolean multiple);
|
|
|
|
-void screen_cast_widget_set_source_types (ScreenCastWidget *screen_cast_widget,
|
|
- ScreenCastSourceType source_types);
|
|
+void screen_cast_widget_set_source_types (ScreenCastWidget *screen_cast_widget,
|
|
+ ScreenCastSourceType source_types);
|
|
|
|
void screen_cast_widget_add_selections (ScreenCastWidget *widget,
|
|
- GVariantBuilder *selections_builder);
|
|
+ GVariantBuilder *selections_builder);
|
|
diff --git a/src/screencastwidget.ui b/src/screencastwidget.ui
|
|
index 2417ca5..fb83b94 100644
|
|
--- a/src/screencastwidget.ui
|
|
+++ b/src/screencastwidget.ui
|
|
@@ -19,6 +19,7 @@
|
|
<child>
|
|
<object class="GtkStack" id="source_type">
|
|
<property name="transition-type">crossfade</property>
|
|
+ <!-- Window selection page -->
|
|
<child>
|
|
<object class="GtkStackPage">
|
|
<property name="name">windows_page</property>
|
|
@@ -80,6 +81,8 @@
|
|
</property>
|
|
</object>
|
|
</child>
|
|
+
|
|
+ <!-- Physical monitor selection page -->
|
|
<child>
|
|
<object class="GtkStackPage">
|
|
<property name="name">monitors_page</property>
|