[gnome-control-center/gbsneto/gtk4: 16/35] removable-media: Port to GTK4
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gbsneto/gtk4: 16/35] removable-media: Port to GTK4
- Date: Mon, 1 Nov 2021 01:13:23 +0000 (UTC)
commit b0ff79cdc0513914aec6c09789fca2b29a04a763
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Oct 20 13:56:29 2021 -0300
removable-media: Port to GTK4
A pretty boring, regular port again. No new challenges here.
panels/meson.build | 2 +-
panels/removable-media/cc-removable-media-panel.c | 35 +-
panels/removable-media/cc-removable-media-panel.ui | 386 ++++++---------------
shell/cc-panel-loader.c | 4 +-
4 files changed, 127 insertions(+), 300 deletions(-)
---
diff --git a/panels/meson.build b/panels/meson.build
index 159fba0bc..0e09f4ab1 100644
--- a/panels/meson.build
+++ b/panels/meson.build
@@ -21,7 +21,7 @@ panels = [
# 'power',
# 'printers',
# 'region',
-# 'removable-media',
+ 'removable-media',
# 'search',
# 'sharing',
'sound',
diff --git a/panels/removable-media/cc-removable-media-panel.c
b/panels/removable-media/cc-removable-media-panel.c
index a891855c0..6ce238ede 100644
--- a/panels/removable-media/cc-removable-media-panel.c
+++ b/panels/removable-media/cc-removable-media-panel.c
@@ -64,17 +64,6 @@ struct _CcRemovableMediaPanel
G_DEFINE_TYPE (CcRemovableMediaPanel, cc_removable_media_panel, CC_TYPE_PANEL)
-static void
-ellipsize_cell_layout (GtkCellLayout *cell_layout)
-{
- g_autoptr(GList) cells = gtk_cell_layout_get_cells (cell_layout);
- GList *cell;
-
- for (cell = cells; cell; cell = cell->next)
- if (GTK_IS_CELL_RENDERER_TEXT (cell->data))
- g_object_set (G_OBJECT (cell->data), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
-}
-
static char **
remove_elem_from_str_array (char **v,
const char *s)
@@ -309,14 +298,13 @@ on_other_type_combo_box_changed (CcRemovableMediaPanel *self)
-1);
if (self->other_application_chooser != NULL) {
- gtk_widget_destroy (GTK_WIDGET (self->other_application_chooser));
+ gtk_box_remove (self->other_action_box, GTK_WIDGET (self->other_application_chooser));
+ self->other_application_chooser = NULL;
}
self->other_application_chooser = GTK_APP_CHOOSER_BUTTON (gtk_app_chooser_button_new (x_content_type));
- ellipsize_cell_layout (GTK_CELL_LAYOUT (self->other_application_chooser));
- gtk_box_pack_start (self->other_action_box, GTK_WIDGET (self->other_application_chooser), TRUE, TRUE, 0);
+ gtk_box_append (self->other_action_box, GTK_WIDGET (self->other_application_chooser));
prepare_chooser (self, self->other_application_chooser, NULL);
- gtk_widget_show (GTK_WIDGET (self->other_application_chooser));
gtk_label_set_mnemonic_widget (self->other_action_label, GTK_WIDGET (self->other_application_chooser));
}
@@ -327,7 +315,7 @@ on_extra_options_dialog_response (CcRemovableMediaPanel *self)
gtk_widget_hide (GTK_WIDGET (self->other_type_dialog));
if (self->other_application_chooser != NULL) {
- gtk_widget_destroy (GTK_WIDGET (self->other_application_chooser));
+ gtk_box_remove (self->other_action_box, GTK_WIDGET (self->other_application_chooser));
self->other_application_chooser = NULL;
}
}
@@ -335,8 +323,10 @@ on_extra_options_dialog_response (CcRemovableMediaPanel *self)
static void
on_extra_options_button_clicked (CcRemovableMediaPanel *self)
{
- gtk_window_set_transient_for (GTK_WINDOW (self->other_type_dialog),
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))));
+ CcShell *shell = cc_panel_get_shell (CC_PANEL (self));
+ GtkWidget *toplevel = cc_shell_get_toplevel (shell);
+
+ gtk_window_set_transient_for (GTK_WINDOW (self->other_type_dialog), GTK_WINDOW (toplevel));
gtk_window_set_modal (GTK_WINDOW (self->other_type_dialog), TRUE);
gtk_window_set_title (GTK_WINDOW (self->other_type_dialog), _("Other Media"));
/* update other_application_chooser */
@@ -474,7 +464,7 @@ cc_removable_media_panel_dispose (GObject *object)
{
CcRemovableMediaPanel *self = CC_REMOVABLE_MEDIA_PANEL (object);
- g_clear_pointer ((GtkWidget **) &self->other_type_dialog, gtk_widget_destroy);
+ g_clear_pointer ((GtkWindow **) &self->other_type_dialog, gtk_window_destroy);
G_OBJECT_CLASS (cc_removable_media_panel_parent_class)->dispose (object);
}
@@ -517,12 +507,5 @@ cc_removable_media_panel_init (CcRemovableMediaPanel *self)
gtk_widget_init_template (GTK_WIDGET (self));
self->settings = g_settings_new (MEDIA_HANDLING_SCHEMA);
- ellipsize_cell_layout (GTK_CELL_LAYOUT (self->audio_cdda_chooser));
- ellipsize_cell_layout (GTK_CELL_LAYOUT (self->video_dvd_chooser));
- ellipsize_cell_layout (GTK_CELL_LAYOUT (self->music_player_chooser));
- ellipsize_cell_layout (GTK_CELL_LAYOUT (self->dcf_chooser));
- ellipsize_cell_layout (GTK_CELL_LAYOUT (self->software_chooser));
- ellipsize_cell_layout (GTK_CELL_LAYOUT (self->other_type_combo_box));
-
info_panel_setup_media (self);
}
diff --git a/panels/removable-media/cc-removable-media-panel.ui
b/panels/removable-media/cc-removable-media-panel.ui
index 2feb46cfe..8ed43d5f3 100644
--- a/panels/removable-media/cc-removable-media-panel.ui
+++ b/panels/removable-media/cc-removable-media-panel.ui
@@ -2,42 +2,30 @@
<interface>
<!-- interface-requires gtk+ 3.0 -->
<template class="CcRemovableMediaPanel" parent="CcPanel">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="expand">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
<property name="margin_top">32</property>
<property name="margin_bottom">32</property>
- <property name="margin_left">24</property>
- <property name="margin_right">24</property>
+ <property name="margin_start">24</property>
+ <property name="margin_end">24</property>
<child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">horizontal</property>
+ <object class="AdwClamp">
<child>
<object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="spacing">18</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="handlers_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="spacing">10</property>
<property name="valign">start</property>
<property name="vexpand">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="spacing">10</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="halign">center</property>
<property name="justify">center</property>
<property name="wrap">True</property>
@@ -47,404 +35,260 @@
<class name="dim-label"/>
</style>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
<object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="spacing">18</property>
<property name="margin-start">12</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkGrid">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="column-spacing">6</property>
<property name="row-spacing">12</property>
<child>
<object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">CD _audio</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">audio_cdda_chooser</property>
+ <layout>
+ <property name="row">0</property>
+ <property name="column">0</property>
+ </layout>
<style>
<class name="dim-label"/>
</style>
</object>
- <packing>
- <property name="top-attach">0</property>
- <property name="left-attach">0</property>
- </packing>
</child>
<child>
<object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_DVD video</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">video_dvd_chooser</property>
+ <layout>
+ <property name="row">1</property>
+ <property name="column">0</property>
+ </layout>
<style>
<class name="dim-label"/>
</style>
</object>
- <packing>
- <property name="top-attach">1</property>
- <property name="left-attach">0</property>
- </packing>
</child>
<child>
<object class="GtkAppChooserButton" id="audio_cdda_chooser">
- <property name="visible">True</property>
<property name="hexpand">True</property>
- <property name="can_focus">False</property>
<property name="content_type">x-content/audio-cdda</property>
+ <layout>
+ <property name="row">0</property>
+ <property name="column">1</property>
+ </layout>
</object>
- <packing>
- <property name="top-attach">0</property>
- <property name="left-attach">1</property>
- </packing>
</child>
<child>
<object class="GtkAppChooserButton" id="video_dvd_chooser">
- <property name="visible">True</property>
<property name="hexpand">True</property>
- <property name="can_focus">False</property>
<property name="content_type">x-content/video-dvd</property>
+ <layout>
+ <property name="row">1</property>
+ <property name="column">1</property>
+ </layout>
</object>
- <packing>
- <property name="top-attach">1</property>
- <property name="left-attach">1</property>
- </packing>
</child>
<child>
<object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_Music player</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">music_player_chooser</property>
+ <layout>
+ <property name="row">2</property>
+ <property name="column">0</property>
+ </layout>
<style>
<class name="dim-label"/>
</style>
</object>
- <packing>
- <property name="top-attach">2</property>
- <property name="left-attach">0</property>
- </packing>
</child>
<child>
<object class="GtkAppChooserButton" id="music_player_chooser">
- <property name="visible">True</property>
<property name="hexpand">True</property>
- <property name="can_focus">False</property>
<property name="content_type">x-content/audio-player</property>
+ <layout>
+ <property name="row">2</property>
+ <property name="column">1</property>
+ </layout>
</object>
- <packing>
- <property name="top-attach">2</property>
- <property name="left-attach">1</property>
- </packing>
</child>
<child>
<object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_Photos</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">dcf_chooser</property>
+ <layout>
+ <property name="row">3</property>
+ <property name="column">0</property>
+ </layout>
<style>
<class name="dim-label"/>
</style>
</object>
- <packing>
- <property name="top-attach">3</property>
- <property name="left-attach">0</property>
- </packing>
</child>
<child>
<object class="GtkAppChooserButton" id="dcf_chooser">
- <property name="visible">True</property>
<property name="hexpand">True</property>
- <property name="can_focus">False</property>
<property name="content_type">x-content/image-dcf</property>
+ <layout>
+ <property name="row">3</property>
+ <property name="column">1</property>
+ </layout>
</object>
- <packing>
- <property name="top-attach">3</property>
- <property name="left-attach">1</property>
- </packing>
</child>
<child>
<object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_Software</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">software_chooser</property>
+ <layout>
+ <property name="row">4</property>
+ <property name="column">0</property>
+ </layout>
<style>
<class name="dim-label"/>
</style>
</object>
- <packing>
- <property name="top-attach">4</property>
- <property name="left-attach">0</property>
- </packing>
</child>
<child>
<object class="GtkAppChooserButton" id="software_chooser">
- <property name="visible">True</property>
<property name="hexpand">True</property>
- <property name="can_focus">False</property>
<property name="content_type">x-content/unix-software</property>
+ <layout>
+ <property name="row">4</property>
+ <property name="column">1</property>
+ </layout>
</object>
- <packing>
- <property name="top-attach">4</property>
- <property name="left-attach">1</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">horizontal</property>
- <child>
- <object class="GtkButton" id="extra_options_button">
- <property name="label" translatable="yes">_Other Media…</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="on_extra_options_button_clicked"
object="CcRemovableMediaPanel" swapped="yes"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
+ <object class="GtkButton" id="extra_options_button">
+ <property name="label" translatable="yes">_Other Media…</property>
+ <property name="halign">end</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="on_extra_options_button_clicked"
object="CcRemovableMediaPanel" swapped="yes"/>
</object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
<object class="GtkCheckButton" id="autorun_never_checkbutton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="draw_indicator">True</property>
<property name="valign">end</property>
<property name="vexpand">False</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="wrap">True</property>
- <property name="xalign">0</property>
- <property name="use_underline">True</property>
- <property name="label" translatable="yes">_Never prompt or start programs on media
insertion</property>
- </object>
- </child>
+ <property name="use_underline">True</property>
+ <property name="label" translatable="yes">_Never prompt or start programs on media
insertion</property>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
</child>
</object>
</child>
</template>
<object class="GtkDialog" id="other_type_dialog">
- <property name="can_focus">False</property>
- <property name="border_width">10</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="destroy_with_parent">True</property>
- <property name="type_hint">dialog</property>
<property name="use_header_bar">1</property>
- <signal name="delete-event" handler="gtk_widget_hide_on_delete"/>
+ <property name="hide-on-close">True</property>
<signal name="response" handler="on_extra_options_dialog_response" object="CcRemovableMediaPanel"
swapped="yes"/>
- <child internal-child="vbox">
+ <child>
<object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="margin-top">18</property>
+ <property name="margin-bottom">18</property>
+ <property name="margin-start">18</property>
+ <property name="margin-end">18</property>
<property name="orientation">vertical</property>
- <property name="spacing">2</property>
<child>
<object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">5</property>
+ <property name="spacing">10</property>
<property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Select how other media should be handled</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
<child>
<object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">10</property>
+ <property name="spacing">6</property>
+ <property name="margin-start">12</property>
<property name="orientation">vertical</property>
<child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Select how other media should be
handled</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">6</property>
- <property name="margin-start">12</property>
- <property name="orientation">vertical</property>
+ <object class="GtkGrid">
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">10</property>
<child>
- <object class="GtkGrid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="column_spacing">6</property>
- <property name="row_spacing">10</property>
+ <object class="GtkComboBox" id="other_type_combo_box">
+ <property name="model">other_type_list_store</property>
+ <signal name="changed" handler="on_other_type_combo_box_changed"
object="CcRemovableMediaPanel" swapped="yes"/>
+ <layout>
+ <property name="column">1</property>
+ <property name="row">0</property>
+ </layout>
<child>
- <object class="GtkComboBox" id="other_type_combo_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="model">other_type_list_store</property>
- <signal name="changed" handler="on_other_type_combo_box_changed"
object="CcRemovableMediaPanel" swapped="yes"/>
- <child>
- <object class="GtkCellRendererText"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="other_action_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">_Action:</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="other_action_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">_Type:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">other_type_combo_box</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="other_action_label">
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Action:</property>
+ <property name="use_underline">True</property>
+ <layout>
+ <property name="column">0</property>
+ <property name="row">1</property>
+ </layout>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="other_action_box">
+ <layout>
+ <property name="column">1</property>
+ <property name="row">1</property>
+ </layout>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Type:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">other_type_combo_box</property>
+ <layout>
+ <property name="column">0</property>
+ <property name="row">0</property>
+ </layout>
+ </object>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
</child>
diff --git a/shell/cc-panel-loader.c b/shell/cc-panel-loader.c
index 7b68ab8e7..661807a2a 100644
--- a/shell/cc-panel-loader.c
+++ b/shell/cc-panel-loader.c
@@ -53,7 +53,7 @@ extern GType cc_notifications_panel_get_type (void);
//extern GType cc_power_panel_get_type (void);
//extern GType cc_printers_panel_get_type (void);
//extern GType cc_region_panel_get_type (void);
-//extern GType cc_removable_media_panel_get_type (void);
+extern GType cc_removable_media_panel_get_type (void);
//extern GType cc_search_panel_get_type (void);
//extern GType cc_sharing_panel_get_type (void);
extern GType cc_sound_panel_get_type (void);
@@ -124,7 +124,7 @@ static CcPanelLoaderVtable default_panels[] =
//PANEL_TYPE("power", cc_power_panel_get_type, NULL),
//PANEL_TYPE("printers", cc_printers_panel_get_type, NULL),
//PANEL_TYPE("region", cc_region_panel_get_type, NULL),
- //PANEL_TYPE("removable-media", cc_removable_media_panel_get_type, NULL),
+ PANEL_TYPE("removable-media", cc_removable_media_panel_get_type, NULL),
//PANEL_TYPE("search", cc_search_panel_get_type, NULL),
//PANEL_TYPE("sharing", cc_sharing_panel_get_type, NULL),
PANEL_TYPE("sound", cc_sound_panel_get_type, NULL),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]