[xdg-desktop-portal-gnome/gbsneto/post-restore-screencast-cleanups: 6/19] screencast: Move stack switcher to dialog
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [xdg-desktop-portal-gnome/gbsneto/post-restore-screencast-cleanups: 6/19] screencast: Move stack switcher to dialog
- Date: Mon, 22 Nov 2021 14:34:43 +0000 (UTC)
commit 5c706861babf05d5dd670f4f858b76a92782f91c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Nov 13 21:30:23 2021 -0300
screencast: Move stack switcher to dialog
As per suggested mockups
src/remotedesktopdialog.c | 9 +++++++++
src/screencastdialog.c | 10 ++++++++++
src/screencastwidget.c | 6 ++++++
src/screencastwidget.h | 2 ++
src/screencastwidget.ui | 17 ++++++-----------
5 files changed, 33 insertions(+), 11 deletions(-)
---
diff --git a/src/remotedesktopdialog.c b/src/remotedesktopdialog.c
index d3f43ee..f9089aa 100644
--- a/src/remotedesktopdialog.c
+++ b/src/remotedesktopdialog.c
@@ -33,6 +33,7 @@ struct _RemoteDesktopDialog
GtkWidget *screen_cast_widget;
GtkWidget *device_heading;
GtkWidget *device_list;
+ GtkHeaderBar *titlebar;
RemoteDesktopDeviceType device_types;
@@ -313,6 +314,13 @@ remote_desktop_dialog_new (const char *app_id,
g_signal_connect (screen_cast_widget, "has-selection-changed",
G_CALLBACK (on_has_selection_changed), dialog);
gtk_widget_show (GTK_WIDGET (screen_cast_widget));
+
+ if (__builtin_popcount (screen_cast_select->source_types) > 1)
+ {
+ gtk_header_bar_set_title_widget (dialog->titlebar,
+ screen_cast_widget_get_stack_switcher (screen_cast_widget));
+ }
+
}
gtk_label_set_label (GTK_LABEL (dialog->device_heading), heading);
@@ -379,6 +387,7 @@ remote_desktop_dialog_class_init (RemoteDesktopDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, RemoteDesktopDialog, screen_cast_widget);
gtk_widget_class_bind_template_child (widget_class, RemoteDesktopDialog, device_heading);
gtk_widget_class_bind_template_child (widget_class, RemoteDesktopDialog, device_list);
+ gtk_widget_class_bind_template_child (widget_class, RemoteDesktopDialog, titlebar);
gtk_widget_class_bind_template_callback (widget_class, button_clicked);
quark_device_widget_data = g_quark_from_static_string ("-device-widget-type-quark");
diff --git a/src/screencastdialog.c b/src/screencastdialog.c
index c8f6d2b..e36d126 100644
--- a/src/screencastdialog.c
+++ b/src/screencastdialog.c
@@ -31,6 +31,7 @@ struct _ScreenCastDialog
GtkWidget *accept_button;
GtkWidget *screen_cast_widget;
+ GtkHeaderBar *titlebar;
gboolean multiple;
};
@@ -133,6 +134,7 @@ screen_cast_dialog_class_init (ScreenCastDialogClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/freedesktop/portal/desktop/gnome/screencastdialog.ui");
gtk_widget_class_bind_template_child (widget_class, ScreenCastDialog, accept_button);
gtk_widget_class_bind_template_child (widget_class, ScreenCastDialog, screen_cast_widget);
+ gtk_widget_class_bind_template_child (widget_class, ScreenCastDialog, titlebar);
gtk_widget_class_bind_template_callback (widget_class, on_button_clicked_cb);
}
@@ -144,6 +146,7 @@ screen_cast_dialog_init (ScreenCastDialog *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 *
@@ -162,5 +165,12 @@ screen_cast_dialog_new (const char *app_id,
select->source_types);
screen_cast_widget_set_persist_mode (screen_cast_widget, persist_mode);
+ if (__builtin_popcount (select->source_types) > 1)
+ {
+ ScreenCastWidget *widget = SCREEN_CAST_WIDGET (dialog->screen_cast_widget);
+ gtk_header_bar_set_title_widget (dialog->titlebar,
+ screen_cast_widget_get_stack_switcher (widget));
+ }
+
return dialog;
}
diff --git a/src/screencastwidget.c b/src/screencastwidget.c
index 6125d28..ce74e39 100644
--- a/src/screencastwidget.c
+++ b/src/screencastwidget.c
@@ -526,6 +526,12 @@ screen_cast_widget_init (ScreenCastWidget *widget)
gtk_widget_show (widget->virtual_switch);
}
+GtkWidget *
+screen_cast_widget_get_stack_switcher (ScreenCastWidget *widget)
+{
+ return widget->source_type_switcher;
+}
+
void
screen_cast_widget_set_app_id (ScreenCastWidget *widget,
const char *app_id)
diff --git a/src/screencastwidget.h b/src/screencastwidget.h
index 3fe47eb..48b8b94 100644
--- a/src/screencastwidget.h
+++ b/src/screencastwidget.h
@@ -28,6 +28,8 @@ typedef struct _ScreenCastWidget ScreenCastWidget;
G_DECLARE_FINAL_TYPE (ScreenCastWidget, screen_cast_widget,
SCREEN_CAST, WIDGET, GtkBox)
+GtkWidget *screen_cast_widget_get_stack_switcher (ScreenCastWidget *self);
+
void screen_cast_widget_set_app_id (ScreenCastWidget *widget,
const char *app_id);
diff --git a/src/screencastwidget.ui b/src/screencastwidget.ui
index c28dcbf..652f4ac 100644
--- a/src/screencastwidget.ui
+++ b/src/screencastwidget.ui
@@ -5,17 +5,6 @@
<property name="orientation">vertical</property>
<child>
<object class="GtkGrid">
- <child>
- <object class="GtkStackSwitcher" id="source_type_switcher">
- <property name="visible">0</property>
- <property name="stack">source_type</property>
- <property name="halign">center</property>
- <layout>
- <property name="column">0</property>
- <property name="row">0</property>
- </layout>
- </object>
- </child>
<child>
<object class="GtkStack" id="source_type">
<property name="transition-type">crossfade</property>
@@ -174,4 +163,10 @@
</object>
</child>
</template>
+
+ <object class="GtkStackSwitcher" id="source_type_switcher">
+ <property name="visible">0</property>
+ <property name="stack">source_type</property>
+ <property name="halign">center</property>
+ </object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]