[gnome-control-center/app-chooser] media: simplify teh code a bit
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/app-chooser] media: simplify teh code a bit
- Date: Wed, 1 Dec 2010 14:59:37 +0000 (UTC)
commit c6c1d915536c319e22d19bbb0fa8081ce7ac2467
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed Dec 1 15:54:01 2010 +0100
media: simplify teh code a bit
panels/media/cc-media-panel.c | 31 +++++++++++++++----------------
1 files changed, 15 insertions(+), 16 deletions(-)
---
diff --git a/panels/media/cc-media-panel.c b/panels/media/cc-media-panel.c
index d281475..3ca27fd 100644
--- a/panels/media/cc-media-panel.c
+++ b/panels/media/cc-media-panel.c
@@ -291,8 +291,7 @@ combo_box_changed_cb (GtkComboBox *combo_box,
static void
prepare_combo_box (CcMediaPanel *self,
- GtkWidget *combo_box,
- const char *x_content_type)
+ GtkWidget *combo_box)
{
GtkAppChooserButton *app_chooser = GTK_APP_CHOOSER_BUTTON (combo_box);
GIcon *icon;
@@ -301,9 +300,12 @@ prepare_combo_box (CcMediaPanel *self,
gboolean pref_ignore;
gboolean pref_open_folder;
GAppInfo *info;
+ gchar *content_type;
+
+ content_type = gtk_app_chooser_get_content_type (GTK_APP_CHOOSER (app_chooser));
/* fetch preferences for this content type */
- autorun_get_preferences (self, x_content_type,
+ autorun_get_preferences (self, content_type,
&pref_start_app, &pref_ignore, &pref_open_folder);
pref_ask = !pref_start_app && !pref_ignore && !pref_open_folder;
@@ -347,6 +349,8 @@ prepare_combo_box (CcMediaPanel *self,
G_CALLBACK (combo_box_changed_cb), self);
g_signal_connect (app_chooser, "custom-item-activated",
G_CALLBACK (custom_item_activated_cb), self);
+
+ g_free (content_type);
}
static void
@@ -381,8 +385,7 @@ other_type_combo_box_changed (GtkComboBox *combo_box,
self->priv->other_application_combo = gtk_app_chooser_button_new (x_content_type);
gtk_box_pack_start (GTK_BOX (action_container), self->priv->other_application_combo, TRUE, TRUE, 0);
- prepare_combo_box (self, self->priv->other_application_combo,
- x_content_type);
+ prepare_combo_box (self, self->priv->other_application_combo);
gtk_widget_show (self->priv->other_application_combo);
g_free (x_content_type);
@@ -430,21 +433,17 @@ media_panel_setup (CcMediaPanel *self)
GtkTreeIter iter;
GtkBuilder *builder = self->priv->builder;
- struct {
- const gchar *widget_name;
- const gchar *content_type;
- } const defs[] = {
- { "media_audio_cdda_combobox", "x-content/audio-cdda" },
- { "media_video_dvd_combobox", "x-content/video-dvd" },
- { "media_music_player_combobox", "x-content/audio-player" },
- { "media_dcf_combobox", "x-content/image-dcf" },
- { "media_software_combobox", "x-content/software" },
+ const gchar *widget_names[] = {
+ "media_audio_cdda_combobox",
+ "media_video_dvd_combobox",
+ "media_music_player_combobox",
+ "media_dcf_combobox",
+ "media_software_combobox",
};
for (n = 0; n < G_N_ELEMENTS (defs); n++) {
prepare_combo_box (self,
- GTK_WIDGET (gtk_builder_get_object (builder, defs[n].widget_name)),
- defs[n].content_type);
+ GTK_WIDGET (gtk_builder_get_object (builder, defs[n].widget_name)));
}
other_type_combo_box = GTK_WIDGET (gtk_builder_get_object (builder, "media_other_type_combobox"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]