grim/pidgin

Convert Themes pref page to Glade.

2019-08-05, Elliott Sales de Andrade
1ead9afaa71e
Parents e2dd6507d83e
Children aa2cd6945f70
Convert Themes pref page to Glade.
--- a/pidgin/gtkprefs.c Mon Aug 05 04:19:43 2019 -0400
+++ b/pidgin/gtkprefs.c Mon Aug 05 19:05:09 2019 -0400
@@ -246,6 +246,14 @@
GtkWidget *startup_hbox;
GtkWidget *startup_label;
} away;
+
+ /* Themes page */
+ struct {
+ GtkWidget *blist;
+ GtkWidget *status;
+ GtkWidget *sound;
+ GtkWidget *smiley;
+ } theme;
};
/* Main dialog */
@@ -1467,37 +1475,25 @@
}
/* builds a theme combo box from a list store with colums: icon preview, markup, theme name */
-static GtkWidget *
-prefs_build_theme_combo_box(GtkListStore *store, const char *current_theme, const char *type)
+static void
+prefs_build_theme_combo_box(GtkWidget *combo_box, GtkListStore *store,
+ const char *current_theme, const char *type)
{
- GtkCellRenderer *cell_rend;
- GtkWidget *combo_box;
GtkTargetEntry te[3] = {
{"text/plain", 0, 0},
{"text/uri-list", 0, 1},
{"STRING", 0, 2}
};
- g_return_val_if_fail(store != NULL && current_theme != NULL, NULL);
-
- combo_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
-
- cell_rend = gtk_cell_renderer_pixbuf_new();
- gtk_cell_renderer_set_fixed_size(cell_rend, PREFS_OPTIMAL_ICON_SIZE, PREFS_OPTIMAL_ICON_SIZE);
- gtk_cell_layout_pack_start(GTK_CELL_LAYOUT (combo_box), cell_rend, FALSE);
- gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_box), cell_rend, "pixbuf", 0, NULL);
-
- cell_rend = gtk_cell_renderer_text_new();
- gtk_cell_layout_pack_start(GTK_CELL_LAYOUT (combo_box), cell_rend, TRUE);
- gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_box), cell_rend, "markup", 1, NULL);
- g_object_set(cell_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+ g_return_if_fail(store != NULL && current_theme != NULL);
+
+ gtk_combo_box_set_model(GTK_COMBO_BOX(combo_box),
+ GTK_TREE_MODEL(store));
gtk_drag_dest_set(combo_box, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, te,
sizeof(te) / sizeof(GtkTargetEntry) , GDK_ACTION_COPY | GDK_ACTION_MOVE);
g_signal_connect(G_OBJECT(combo_box), "drag_data_received", G_CALLBACK(theme_dnd_recv), (gpointer) type);
-
- return combo_box;
}
/* sets the current sound theme */
@@ -1629,95 +1625,36 @@
}
}
-static GtkWidget *
-add_theme_prefs_combo(GtkWidget *vbox,
- GtkSizeGroup *combo_sg, GtkSizeGroup *label_sg,
- GtkListStore *theme_store,
- GCallback combo_box_cb, gpointer combo_box_cb_user_data,
- const char *label_str, const char *prefs_path,
- const char *theme_type)
+static void
+bind_theme_page(PidginPrefsWindow *win)
{
- GtkWidget *label;
- GtkWidget *combo_box = NULL;
- GtkWidget *themesel_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, PIDGIN_HIG_BOX_SPACE);
-
- label = gtk_label_new(label_str);
- gtk_label_set_xalign(GTK_LABEL(label), 0.0);
- gtk_label_set_yalign(GTK_LABEL(label), 0.5);
- gtk_size_group_add_widget(label_sg, label);
- gtk_box_pack_start(GTK_BOX(themesel_hbox), label, FALSE, FALSE, 0);
-
- combo_box = prefs_build_theme_combo_box(theme_store,
- purple_prefs_get_string(prefs_path),
- theme_type);
- g_signal_connect(G_OBJECT(combo_box), "changed",
- (GCallback)combo_box_cb, combo_box_cb_user_data);
- gtk_size_group_add_widget(combo_sg, combo_box);
- gtk_box_pack_start(GTK_BOX(themesel_hbox), combo_box, TRUE, TRUE, 0);
-
- gtk_box_pack_start(GTK_BOX(vbox), themesel_hbox, FALSE, FALSE, 0);
-
- return combo_box;
-}
-
-static GtkWidget *
-theme_page(PidginPrefsWindow *win)
-{
- GtkWidget *label;
- GtkWidget *ret, *vbox;
- GtkSizeGroup *label_sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
- GtkSizeGroup *combo_sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
-
- ret = gtk_box_new(GTK_ORIENTATION_VERTICAL, PIDGIN_HIG_CAT_SPACE);
- gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER);
-
- vbox = pidgin_make_frame(ret, _("Theme Selections"));
-
- /* Instructions */
- label = gtk_label_new(_("Select a theme that you would like to use from "
- "the lists below.\nNew themes can be installed by "
- "dragging and dropping them onto the theme list."));
-
- gtk_label_set_xalign(GTK_LABEL(label), 0.0);
- gtk_label_set_yalign(GTK_LABEL(label), 0.5);
- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
-
- gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, FALSE, 0);
- gtk_widget_show(label);
-
/* Buddy List Themes */
- prefs_blist_themes_combo_box = add_theme_prefs_combo(
- vbox, combo_sg, label_sg, prefs_blist_themes,
- (GCallback)prefs_set_blist_theme_cb, NULL,
- _("Buddy List Theme:"), PIDGIN_PREFS_ROOT "/blist/theme", "blist");
+ prefs_build_theme_combo_box(win->theme.blist, prefs_blist_themes,
+ PIDGIN_PREFS_ROOT "/blist/theme", "blist");
+ prefs_blist_themes_combo_box = win->theme.blist;
/* Status Icon Themes */
- prefs_status_themes_combo_box = add_theme_prefs_combo(
- vbox, combo_sg, label_sg, prefs_status_icon_themes,
- (GCallback)prefs_set_status_icon_theme_cb, NULL,
- _("Status Icon Theme:"), PIDGIN_PREFS_ROOT "/status/icon-theme", "icon");
+ prefs_build_theme_combo_box(win->theme.status, prefs_status_icon_themes,
+ PIDGIN_PREFS_ROOT "/status/icon-theme",
+ "icon");
+ prefs_status_themes_combo_box = win->theme.status;
/* Sound Themes */
- prefs_sound_themes_combo_box = add_theme_prefs_combo(
- vbox, combo_sg, label_sg, prefs_sound_themes,
- (GCallback)prefs_set_sound_theme_cb, win,
- _("Sound Theme:"), PIDGIN_PREFS_ROOT "/sound/theme", "sound");
+ prefs_build_theme_combo_box(win->theme.sound, prefs_sound_themes,
+ PIDGIN_PREFS_ROOT "/sound/theme", "sound");
+ prefs_sound_themes_combo_box = win->theme.sound;
/* Smiley Themes */
- prefs_smiley_themes_combo_box = add_theme_prefs_combo(
- vbox, combo_sg, label_sg, prefs_smiley_themes,
- (GCallback)prefs_set_smiley_theme_cb, NULL,
- _("Smiley Theme:"), PIDGIN_PREFS_ROOT "/smileys/theme", "smiley");
+ prefs_build_theme_combo_box(win->theme.smiley, prefs_smiley_themes,
+ PIDGIN_PREFS_ROOT "/smileys/theme",
+ "smiley");
+ prefs_smiley_themes_combo_box = win->theme.smiley;
/* Custom sort so "none" theme is at top of list */
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(prefs_smiley_themes),
2, pidgin_sort_smileys, NULL, NULL);
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(prefs_smiley_themes),
2, GTK_SORT_ASCENDING);
-
- gtk_widget_show_all(ret);
-
- return ret;
}
static void
@@ -3547,7 +3484,8 @@
notebook_page++;
bind_away_page(win);
notebook_page++;
- prefs_notebook_add_page(notebook, _("Themes"), theme_page(win), notebook_page++);
+ bind_theme_page(win);
+ notebook_page++;
#ifdef USE_VV
prefs_notebook_add_page(notebook, _("Voice/Video"), vv_page(win), notebook_page++);
#endif
@@ -3820,6 +3758,24 @@
widget_class, PidginPrefsWindow, away.startup_hbox);
gtk_widget_class_bind_template_child(
widget_class, PidginPrefsWindow, away.startup_label);
+
+ /* Themes page */
+ gtk_widget_class_bind_template_child(
+ widget_class, PidginPrefsWindow, theme.blist);
+ gtk_widget_class_bind_template_child(
+ widget_class, PidginPrefsWindow, theme.status);
+ gtk_widget_class_bind_template_child(
+ widget_class, PidginPrefsWindow, theme.sound);
+ gtk_widget_class_bind_template_child(
+ widget_class, PidginPrefsWindow, theme.smiley);
+ gtk_widget_class_bind_template_callback(widget_class,
+ prefs_set_blist_theme_cb);
+ gtk_widget_class_bind_template_callback(widget_class,
+ prefs_set_status_icon_theme_cb);
+ gtk_widget_class_bind_template_callback(widget_class,
+ prefs_set_sound_theme_cb);
+ gtk_widget_class_bind_template_callback(widget_class,
+ prefs_set_smiley_theme_cb);
}
static void
--- a/pidgin/resources/Prefs/prefs.ui Mon Aug 05 04:19:43 2019 -0400
+++ b/pidgin/resources/Prefs/prefs.ui Mon Aug 05 19:05:09 2019 -0400
@@ -3391,6 +3391,301 @@
<property name="tab_fill">False</property>
</packing>
</child>
+ <child>
+ <object class="GtkBox" id="theme.page">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">12</property>
+ <property name="margin_right">12</property>
+ <property name="margin_top">12</property>
+ <property name="margin_bottom">12</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">18</property>
+ <child>
+ <object class="GtkFrame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Select a theme that you would like to use from the lists below.
+New themes can be installed by dragging and dropping them onto the theme list.</property>
+ <property name="xalign">0</property>
+ </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="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label19">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Buddy List Theme:</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="theme.blist">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <signal name="changed" handler="prefs_set_blist_theme_cb" swapped="no"/>
+ <child>
+ <object class="GtkCellRendererPixbuf">
+ <property name="width">32</property>
+ <property name="height">32</property>
+ </object>
+ <attributes>
+ <attribute name="pixbuf">0</attribute>
+ </attributes>
+ </child>
+ <child>
+ <object class="GtkCellRendererText">
+ <property name="ellipsize">end</property>
+ </object>
+ <attributes>
+ <attribute name="markup">1</attribute>
+ </attributes>
+ </child>
+ </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">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label20">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Status Icon Theme:</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="theme.status">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <signal name="changed" handler="prefs_set_status_icon_theme_cb" swapped="no"/>
+ <child>
+ <object class="GtkCellRendererPixbuf">
+ <property name="width">32</property>
+ <property name="height">32</property>
+ </object>
+ <attributes>
+ <attribute name="pixbuf">0</attribute>
+ </attributes>
+ </child>
+ <child>
+ <object class="GtkCellRendererText">
+ <property name="ellipsize">end</property>
+ </object>
+ <attributes>
+ <attribute name="markup">1</attribute>
+ </attributes>
+ </child>
+ </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">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label21">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Sound Theme:</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="theme.sound">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <signal name="changed" handler="prefs_set_sound_theme_cb" object="PidginPrefsWindow" swapped="no"/>
+ <child>
+ <object class="GtkCellRendererPixbuf">
+ <property name="width">32</property>
+ <property name="height">32</property>
+ </object>
+ <attributes>
+ <attribute name="pixbuf">0</attribute>
+ </attributes>
+ </child>
+ <child>
+ <object class="GtkCellRendererText">
+ <property name="ellipsize">end</property>
+ </object>
+ <attributes>
+ <attribute name="markup">1</attribute>
+ </attributes>
+ </child>
+ </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">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label18">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Smiley Theme:</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="theme.smiley">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <signal name="changed" handler="prefs_set_smiley_theme_cb" swapped="no"/>
+ <child>
+ <object class="GtkCellRendererPixbuf">
+ <property name="width">32</property>
+ <property name="height">32</property>
+ </object>
+ <attributes>
+ <attribute name="pixbuf">0</attribute>
+ </attributes>
+ </child>
+ <child>
+ <object class="GtkCellRendererText">
+ <property name="ellipsize">end</property>
+ </object>
+ <attributes>
+ <attribute name="markup">1</attribute>
+ </attributes>
+ </child>
+ </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">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_bottom">6</property>
+ <property name="label" translatable="yes">Theme Selections</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">9</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Themes</property>
+ </object>
+ <packing>
+ <property name="position">9</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -3441,4 +3736,20 @@
<widget name="label17"/>
</widgets>
</object>
+ <object class="GtkSizeGroup" id="theme.combo_sg">
+ <widgets>
+ <widget name="theme.blist"/>
+ <widget name="theme.status"/>
+ <widget name="theme.sound"/>
+ <widget name="theme.smiley"/>
+ </widgets>
+ </object>
+ <object class="GtkSizeGroup" id="theme.label_sg">
+ <widgets>
+ <widget name="label18"/>
+ <widget name="label19"/>
+ <widget name="label20"/>
+ <widget name="label21"/>
+ </widgets>
+ </object>
</interface>