[gnome-control-center] sound: Fix deprecated API usage
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] sound: Fix deprecated API usage
- Date: Fri, 5 Dec 2014 15:24:14 +0000 (UTC)
commit 70c33f473abaea155ea62d8c7519651b93cd52fc
Author: Rui Matos <tiagomatos gmail com>
Date: Wed Nov 26 19:00:02 2014 +0100
sound: Fix deprecated API usage
https://bugzilla.gnome.org/show_bug.cgi?id=740986
panels/sound/gvc-balance-bar.c | 6 +-
panels/sound/gvc-channel-bar.c | 32 +++++++++------
panels/sound/gvc-combo-box.c | 4 +-
panels/sound/gvc-mixer-dialog.c | 70 ++++++++++++--------------------
panels/sound/gvc-sound-theme-chooser.c | 18 +++-----
5 files changed, 56 insertions(+), 74 deletions(-)
---
diff --git a/panels/sound/gvc-balance-bar.c b/panels/sound/gvc-balance-bar.c
index 3b697ea..3933fd9 100644
--- a/panels/sound/gvc-balance-bar.c
+++ b/panels/sound/gvc-balance-bar.c
@@ -297,9 +297,9 @@ gvc_balance_bar_set_balance_type (GvcBalanceBar *bar,
default:
g_assert_not_reached ();
}
- gtk_misc_set_alignment (GTK_MISC (bar->priv->label),
- 0.0,
- 0.0);
+ gtk_widget_set_halign (bar->priv->label, GTK_ALIGN_START);
+ gtk_widget_set_valign (bar->priv->label, GTK_ALIGN_START);
+
/* frame */
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
diff --git a/panels/sound/gvc-channel-bar.c b/panels/sound/gvc-channel-bar.c
index 7fa4621..926dfc8 100644
--- a/panels/sound/gvc-channel-bar.c
+++ b/panels/sound/gvc-channel-bar.c
@@ -52,7 +52,6 @@ struct GvcChannelBarPrivate
GtkWidget *low_image;
GtkWidget *scale;
GtkWidget *high_image;
- GtkWidget *mute_box;
GtkWidget *mute_switch;
GtkAdjustment *adjustment;
GtkAdjustment *zero_adjustment;
@@ -132,7 +131,7 @@ _scale_box_new (GvcChannelBar *bar)
gtk_box_pack_start (GTK_BOX (ebox), priv->low_image, FALSE, FALSE, 0);
gtk_widget_hide (priv->low_image);
- gtk_box_pack_start (GTK_BOX (ebox), priv->mute_box, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (ebox), priv->mute_switch, FALSE, FALSE, 0);
} else {
bar->priv->scale_box = box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start (GTK_BOX (box), priv->image, FALSE, FALSE, 0);
@@ -155,7 +154,7 @@ _scale_box_new (GvcChannelBar *bar)
gtk_box_pack_start (GTK_BOX (ebox), priv->high_image, FALSE, FALSE, 0);
gtk_widget_show (priv->high_image);
- gtk_box_pack_start (GTK_BOX (ebox), priv->mute_box, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (ebox), priv->mute_switch, FALSE, FALSE, 0);
}
ca_gtk_widget_disable_sounds (bar->priv->scale, FALSE);
@@ -225,13 +224,13 @@ update_layout (GvcChannelBar *bar)
g_object_ref (bar->priv->image);
g_object_ref (bar->priv->label);
- g_object_ref (bar->priv->mute_box);
+ g_object_ref (bar->priv->mute_switch);
g_object_ref (bar->priv->low_image);
g_object_ref (bar->priv->high_image);
gtk_container_remove (GTK_CONTAINER (bar->priv->start_box), bar->priv->image);
gtk_container_remove (GTK_CONTAINER (bar->priv->start_box), bar->priv->label);
- gtk_container_remove (GTK_CONTAINER (bar->priv->end_box), bar->priv->mute_box);
+ gtk_container_remove (GTK_CONTAINER (bar->priv->end_box), bar->priv->mute_switch);
if (bar->priv->orientation == GTK_ORIENTATION_VERTICAL) {
gtk_container_remove (GTK_CONTAINER (bar->priv->start_box), bar->priv->low_image);
@@ -251,7 +250,7 @@ update_layout (GvcChannelBar *bar)
g_object_unref (bar->priv->image);
g_object_unref (bar->priv->label);
- g_object_unref (bar->priv->mute_box);
+ g_object_unref (bar->priv->mute_switch);
g_object_unref (bar->priv->low_image);
g_object_unref (bar->priv->high_image);
@@ -625,15 +624,24 @@ gvc_channel_bar_set_is_amplified (GvcChannelBar *bar, gboolean amplified)
}
g_free (str);
- gtk_alignment_set (GTK_ALIGNMENT (bar->priv->mute_box), 0.5, 0, 0, 0);
+
+ /* Ideally we would use baseline alignment for all
+ * these widgets plus the scale but neither GtkScale
+ * nor GtkSwitch support baseline alignment yet. */
+
+ gtk_widget_set_valign (bar->priv->mute_switch, GTK_ALIGN_START);
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_misc_set_alignment (GTK_MISC (bar->priv->low_image), 0.5, 0.15);
gtk_misc_set_alignment (GTK_MISC (bar->priv->high_image), 0.5, 0.15);
- gtk_misc_set_alignment (GTK_MISC (bar->priv->label), 0, 0);
+G_GNUC_END_IGNORE_DEPRECATIONS
+ gtk_widget_set_valign (bar->priv->label, GTK_ALIGN_START);
} else {
- gtk_alignment_set (GTK_ALIGNMENT (bar->priv->mute_box), 0.5, 0.5, 0, 0);
+ gtk_widget_set_valign (bar->priv->mute_switch, GTK_ALIGN_CENTER);
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_misc_set_alignment (GTK_MISC (bar->priv->low_image), 0.5, 0.5);
gtk_misc_set_alignment (GTK_MISC (bar->priv->high_image), 0.5, 0.5);
- gtk_misc_set_alignment (GTK_MISC (bar->priv->label), 0, 0.5);
+G_GNUC_END_IGNORE_DEPRECATIONS
+ gtk_widget_set_valign (bar->priv->label, GTK_ALIGN_CENTER);
}
}
@@ -914,8 +922,6 @@ gvc_channel_bar_init (GvcChannelBar *bar)
"notify::active",
G_CALLBACK (on_mute_switch_toggled),
bar);
- bar->priv->mute_box = gtk_alignment_new (0.5, 0.5, 0, 0);
- gtk_container_add (GTK_CONTAINER (bar->priv->mute_box), bar->priv->mute_switch);
bar->priv->low_image = gtk_image_new_from_icon_name ("audio-volume-low-symbolic",
GTK_ICON_SIZE_MENU);
@@ -930,7 +936,7 @@ gvc_channel_bar_init (GvcChannelBar *bar)
gtk_widget_set_no_show_all (bar->priv->image, TRUE);
bar->priv->label = gtk_label_new (NULL);
- gtk_misc_set_alignment (GTK_MISC (bar->priv->label), 0.0, 0.5);
+ gtk_widget_set_halign (bar->priv->label, GTK_ALIGN_START);
gtk_widget_set_no_show_all (bar->priv->label, TRUE);
/* frame */
diff --git a/panels/sound/gvc-combo-box.c b/panels/sound/gvc-combo-box.c
index 7dbe3c9..5f8eaed 100644
--- a/panels/sound/gvc-combo-box.c
+++ b/panels/sound/gvc-combo-box.c
@@ -308,9 +308,7 @@ gvc_combo_box_init (GvcComboBox *combo_box)
G_TYPE_STRING));
combo_box->priv->label = gtk_label_new (NULL);
- gtk_misc_set_alignment (GTK_MISC (combo_box->priv->label),
- 0.0,
- 0.5);
+ gtk_widget_set_halign (combo_box->priv->label, GTK_ALIGN_START);
/* frame */
frame = gtk_frame_new (NULL);
diff --git a/panels/sound/gvc-mixer-dialog.c b/panels/sound/gvc-mixer-dialog.c
index a576dd2..a9e314c 100644
--- a/panels/sound/gvc-mixer-dialog.c
+++ b/panels/sound/gvc-mixer-dialog.c
@@ -130,7 +130,7 @@ static void on_test_speakers_clicked (GvcComboBox *widget,
gpointer user_data);
-G_DEFINE_TYPE (GvcMixerDialog, gvc_mixer_dialog, GTK_TYPE_VBOX)
+G_DEFINE_TYPE (GvcMixerDialog, gvc_mixer_dialog, GTK_TYPE_BOX)
static void
profile_selection_changed (GvcComboBox *combo_box,
@@ -1391,21 +1391,11 @@ on_control_stream_removed (GvcMixerControl *control,
static void
_gtk_label_make_bold (GtkLabel *label)
{
- PangoFontDescription *font_desc;
-
- font_desc = pango_font_description_new ();
-
- pango_font_description_set_weight (font_desc,
- PANGO_WEIGHT_BOLD);
-
- /* This will only affect the weight of the font, the rest is
- * from the current state of the widget, which comes from the
- * theme or user prefs, since the font desc only has the
- * weight flag turned on.
- */
- gtk_widget_modify_font (GTK_WIDGET (label), font_desc);
-
- pango_font_description_free (font_desc);
+ gchar *str;
+ str = g_strdup_printf ("<span font-weight='bold'>%s</span>",
+ gtk_label_get_label (label));
+ gtk_label_set_markup_with_mnemonic (label, str);
+ g_free (str);
}
static void
@@ -1612,7 +1602,7 @@ gvc_mixer_dialog_constructor (GType type,
GvcMixerDialog *self;
GtkWidget *main_vbox;
GtkWidget *label;
- GtkWidget *alignment;
+ GtkWidget *sw;
GtkWidget *box;
GtkWidget *sbox;
GtkWidget *ebox;
@@ -1630,11 +1620,9 @@ gvc_mixer_dialog_constructor (GType type,
gtk_container_set_border_width (GTK_CONTAINER (self), 12);
self->priv->output_stream_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- alignment = gtk_alignment_new (0, 0, 1, 1);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 0, 0, 0);
- gtk_container_add (GTK_CONTAINER (alignment), self->priv->output_stream_box);
+ gtk_widget_set_margin_top (self->priv->output_stream_box, 12);
gtk_box_pack_start (GTK_BOX (main_vbox),
- alignment,
+ self->priv->output_stream_box,
FALSE, FALSE, 0);
self->priv->output_bar = create_bar (self, TRUE, TRUE);
gvc_channel_bar_set_name (GVC_CHANNEL_BAR (self->priv->output_bar),
@@ -1664,23 +1652,20 @@ gvc_mixer_dialog_constructor (GType type,
gtk_frame_set_shadow_type (GTK_FRAME (box), GTK_SHADOW_NONE);
gtk_box_pack_start (GTK_BOX (self->priv->output_box), box, TRUE, TRUE, 0);
- alignment = gtk_alignment_new (0, 0, 1, 1);
- gtk_container_add (GTK_CONTAINER (box), alignment);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 0, 0);
-
self->priv->output_treeview = create_ui_device_treeview (self,
G_CALLBACK (on_output_selection_changed));
gtk_label_set_mnemonic_widget (GTK_LABEL (label), self->priv->output_treeview);
- box = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (box),
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (box),
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
GTK_SHADOW_IN);
- gtk_container_add (GTK_CONTAINER (box), self->priv->output_treeview);
- gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (box), 150);
- gtk_container_add (GTK_CONTAINER (alignment), box);
+ gtk_container_add (GTK_CONTAINER (sw), self->priv->output_treeview);
+ gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 150);
+ gtk_widget_set_margin_top (sw, 6);
+ gtk_container_add (GTK_CONTAINER (box), sw);
box = gtk_frame_new (_("Settings for the selected device:"));
label = gtk_frame_get_label_widget (GTK_FRAME (box));
@@ -1706,11 +1691,9 @@ gvc_mixer_dialog_constructor (GType type,
gvc_channel_bar_set_high_icon_name (GVC_CHANNEL_BAR (self->priv->input_bar),
"audio-input-microphone-high-symbolic");
gtk_widget_set_sensitive (self->priv->input_bar, FALSE);
- alignment = gtk_alignment_new (0, 0, 1, 1);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 0, 0);
- gtk_container_add (GTK_CONTAINER (alignment), self->priv->input_bar);
+ gtk_widget_set_margin_top (self->priv->input_bar, 6);
gtk_box_pack_start (GTK_BOX (self->priv->input_box),
- alignment,
+ self->priv->input_bar,
FALSE, FALSE, 0);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
@@ -1758,22 +1741,19 @@ gvc_mixer_dialog_constructor (GType type,
gtk_frame_set_shadow_type (GTK_FRAME (box), GTK_SHADOW_NONE);
gtk_box_pack_start (GTK_BOX (self->priv->input_box), box, TRUE, TRUE, 0);
- alignment = gtk_alignment_new (0, 0, 1, 1);
- gtk_container_add (GTK_CONTAINER (box), alignment);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 0, 0);
-
self->priv->input_treeview = create_ui_device_treeview (self,
G_CALLBACK (on_input_selection_changed));
gtk_label_set_mnemonic_widget (GTK_LABEL (label), self->priv->input_treeview);
- box = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (box),
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (box),
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
GTK_SHADOW_IN);
- gtk_container_add (GTK_CONTAINER (box), self->priv->input_treeview);
- gtk_container_add (GTK_CONTAINER (alignment), box);
+ gtk_container_add (GTK_CONTAINER (sw), self->priv->input_treeview);
+ gtk_widget_set_margin_top (sw, 6);
+ gtk_container_add (GTK_CONTAINER (box), sw);
/* Effects page */
self->priv->sound_effects_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
@@ -1920,6 +1900,8 @@ gvc_mixer_dialog_class_init (GvcMixerDialogClass *klass)
static void
gvc_mixer_dialog_init (GvcMixerDialog *dialog)
{
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (dialog),
+ GTK_ORIENTATION_VERTICAL);
dialog->priv = GVC_MIXER_DIALOG_GET_PRIVATE (dialog);
dialog->priv->bars = g_hash_table_new (NULL, NULL);
dialog->priv->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
diff --git a/panels/sound/gvc-sound-theme-chooser.c b/panels/sound/gvc-sound-theme-chooser.c
index e735e6d..6a05b09 100644
--- a/panels/sound/gvc-sound-theme-chooser.c
+++ b/panels/sound/gvc-sound-theme-chooser.c
@@ -53,7 +53,7 @@ static void gvc_sound_theme_chooser_class_init (GvcSoundThemeChooserClass *k
static void gvc_sound_theme_chooser_init (GvcSoundThemeChooser *sound_theme_chooser);
static void gvc_sound_theme_chooser_finalize (GObject *object);
-G_DEFINE_TYPE (GvcSoundThemeChooser, gvc_sound_theme_chooser, GTK_TYPE_VBOX)
+G_DEFINE_TYPE (GvcSoundThemeChooser, gvc_sound_theme_chooser, GTK_TYPE_BOX)
#define KEY_SOUNDS_SCHEMA "org.gnome.desktop.sound"
#define EVENT_SOUNDS_KEY "event-sounds"
@@ -758,9 +758,10 @@ gvc_sound_theme_chooser_init (GvcSoundThemeChooser *chooser)
GtkWidget *box;
GtkWidget *label;
GtkWidget *scrolled_window;
- GtkWidget *alignment;
char *str;
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (chooser),
+ GTK_ORIENTATION_VERTICAL);
chooser->priv = GVC_SOUND_THEME_CHOOSER_GET_PRIVATE (chooser);
chooser->priv->settings = g_settings_new (WM_SCHEMA);
@@ -774,14 +775,8 @@ gvc_sound_theme_chooser_init (GvcSoundThemeChooser *chooser)
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_frame_set_shadow_type (GTK_FRAME (box), GTK_SHADOW_NONE);
- alignment = gtk_alignment_new (0, 0, 1, 1);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 0, 0);
- gtk_container_add (GTK_CONTAINER (alignment), box);
- gtk_box_pack_start (GTK_BOX (chooser), alignment, TRUE, TRUE, 6);
-
- alignment = gtk_alignment_new (0, 0, 1, 1);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 0, 0);
- gtk_container_add (GTK_CONTAINER (box), alignment);
+ gtk_widget_set_margin_top (box, 6);
+ gtk_box_pack_start (GTK_BOX (chooser), box, TRUE, TRUE, 6);
chooser->priv->treeview = create_alert_treeview (chooser);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser->priv->treeview);
@@ -795,7 +790,8 @@ gvc_sound_theme_chooser_init (GvcSoundThemeChooser *chooser)
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (scrolled_window), chooser->priv->treeview);
- gtk_container_add (GTK_CONTAINER (alignment), scrolled_window);
+ gtk_widget_set_margin_top (scrolled_window, 6);
+ gtk_container_add (GTK_CONTAINER (box), scrolled_window);
g_signal_connect (G_OBJECT (chooser->priv->sound_settings), "changed",
G_CALLBACK (on_sound_settings_changed), chooser);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]