diff -r a1093fbc45d2 -r dc8991868906 pidgin/gtkprefs.c --- a/pidgin/gtkprefs.c Mon Aug 22 22:46:08 2011 +0000 +++ b/pidgin/gtkprefs.c Fri Dec 23 08:21:58 2011 +0000 @@ -45,6 +45,7 @@ #include "gtkblist.h" #include "gtkconv.h" +#include "gtkconv-theme.h" #include "gtkdebug.h" #include "gtkdialogs.h" #include "gtkimhtml.h" @@ -83,6 +84,8 @@ /* Themes page */ static GtkWidget *prefs_sound_themes_combo_box; static GtkWidget *prefs_blist_themes_combo_box; +static GtkWidget *prefs_conv_themes_combo_box; +static GtkWidget *prefs_conv_variants_combo_box; static GtkWidget *prefs_status_themes_combo_box; static GtkWidget *prefs_smiley_themes_combo_box; @@ -94,6 +97,8 @@ /* These exist outside the lifetime of the prefs dialog */ static GtkListStore *prefs_sound_themes; static GtkListStore *prefs_blist_themes; +static GtkListStore *prefs_conv_themes; +static GtkListStore *prefs_conv_variants; static GtkListStore *prefs_status_icon_themes; static GtkListStore *prefs_smiley_themes; @@ -118,7 +123,7 @@ const char *key, int min, int max, GtkSizeGroup *sg) { GtkWidget *spin; - GtkAdjustment *adjust; + GtkObject *adjust; int val; val = purple_prefs_get_int(key); @@ -241,7 +246,7 @@ int int_value = 0; const char *str_value = NULL; gboolean bool_value = FALSE; - GtkListStore *store; + GtkListStore *store = NULL; GtkTreeIter iter; GtkTreeIter active; GtkCellRenderer *renderer; @@ -257,6 +262,9 @@ } else if (type == PURPLE_PREF_BOOLEAN) { store = gtk_list_store_new(PREF_DROPDOWN_COUNT, G_TYPE_STRING, G_TYPE_BOOLEAN); stored_bool = purple_prefs_get_bool(key); + } else { + g_warn_if_reached(); + return NULL; } dropdown = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); @@ -376,6 +384,8 @@ prefs_sound_themes_combo_box = NULL; prefs_blist_themes_combo_box = NULL; + prefs_conv_themes_combo_box = NULL; + prefs_conv_variants_combo_box = NULL; prefs_status_themes_combo_box = NULL; prefs_smiley_themes_combo_box = NULL; @@ -527,6 +537,18 @@ g_free(markup); if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf)); + + } else if (PIDGIN_IS_CONV_THEME(theme)) { + /* No image available? */ + + name = purple_theme_get_name(theme); + /* No author available */ + /* No description available */ + + markup = get_theme_markup(name, FALSE, NULL, NULL); + + gtk_list_store_append(prefs_conv_themes, &iter); + gtk_list_store_set(prefs_conv_themes, &iter, 1, markup, 2, name, -1); } } @@ -582,6 +604,17 @@ gtk_list_store_set(prefs_blist_themes, &iter, 0, pixbuf, 1, tmp, 2, "", -1); g_free(tmp); + /* conversation themes */ + gtk_list_store_clear(prefs_conv_themes); + gtk_list_store_append(prefs_conv_themes, &iter); + tmp = get_theme_markup(_("Default"), FALSE, _("Penguin Pimps"), + _("The default Pidgin conversation theme")); + gtk_list_store_set(prefs_conv_themes, &iter, 0, pixbuf, 1, tmp, 2, "", -1); + g_free(tmp); + + /* conversation theme variants */ + gtk_list_store_clear(prefs_conv_variants); + /* status icon themes */ gtk_list_store_clear(prefs_status_icon_themes); gtk_list_store_append(prefs_status_icon_themes, &iter); @@ -602,6 +635,7 @@ /* set active */ prefs_set_active_theme_combo(prefs_sound_themes_combo_box, prefs_sound_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/theme")); prefs_set_active_theme_combo(prefs_blist_themes_combo_box, prefs_blist_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/blist/theme")); + prefs_set_active_theme_combo(prefs_conv_themes_combo_box, prefs_conv_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/theme")); prefs_set_active_theme_combo(prefs_status_themes_combo_box, prefs_status_icon_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/status/icon-theme")); prefs_set_active_theme_combo(prefs_smiley_themes_combo_box, prefs_smiley_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/smileys/theme")); prefs_sound_themes_loading = FALSE; @@ -615,6 +649,10 @@ prefs_blist_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); + prefs_conv_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); + + prefs_conv_variants = gtk_list_store_new(1, G_TYPE_STRING); + prefs_status_icon_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); prefs_smiley_themes = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); @@ -864,10 +902,9 @@ theme_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, GtkSelectionData *sd, guint info, guint t, gpointer user_data) { - gchar *name = g_strchomp((gchar *)gtk_selection_data_get_data(sd)); - - if ((gtk_selection_data_get_length(sd) >= 0) - && (gtk_selection_data_get_format(sd) == 8)) { + gchar *name = g_strchomp((gchar *)sd->data); + + if ((sd->length >= 0) && (sd->format == 8)) { /* Well, it looks like the drag event was cool. * Let's do something with it */ gchar *temp; @@ -894,7 +931,7 @@ } else if (!g_ascii_strncasecmp(name, "http://", 7)) { /* Oo, a web drag and drop. This is where things * will start to get interesting */ - purple_util_fetch_url(name, TRUE, NULL, FALSE, theme_got_url, info); + purple_util_fetch_url(name, TRUE, NULL, FALSE, -1, theme_got_url, info); } else if (!g_ascii_strncasecmp(name, "https://", 8)) { /* purple_util_fetch_url() doesn't support HTTPS, but we want users * to be able to drag and drop links from the SF trackers, so @@ -905,7 +942,7 @@ tmp[2] = 't'; tmp[3] = 'p'; - purple_util_fetch_url(tmp, TRUE, NULL, FALSE, theme_got_url, info); + purple_util_fetch_url(tmp, TRUE, NULL, FALSE, -1, theme_got_url, info); g_free(tmp); } else free_theme_info(info); @@ -1057,6 +1094,72 @@ } } +/* sets the current conversation theme */ +static void +prefs_set_conv_theme_cb(GtkComboBox *combo_box, gpointer user_data) +{ + PidginConvTheme *theme = NULL; + GtkTreeIter iter; + gchar *name = NULL; + + if (gtk_combo_box_get_active_iter(combo_box, &iter)) { + const GList *variants; + const char *current_variant; + gboolean unset = TRUE; + + gtk_tree_model_get(GTK_TREE_MODEL(prefs_conv_themes), &iter, 2, &name, -1); + if (!name || !*name) { + g_free(name); + return; + } + + purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/theme", name); + + /* Update list of variants */ + gtk_list_store_clear(prefs_conv_variants); + + theme = PIDGIN_CONV_THEME(purple_theme_manager_find_theme(name, "conversation")); + current_variant = pidgin_conversation_theme_get_variant(theme); + + variants = pidgin_conversation_theme_get_variants(theme); + for (; variants && current_variant; variants = g_list_next(variants)) { + gtk_list_store_append(prefs_conv_variants, &iter); + gtk_list_store_set(prefs_conv_variants, &iter, 0, variants->data, -1); + + if (g_str_equal(variants->data, current_variant)) { + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(prefs_conv_variants_combo_box), &iter); + unset = FALSE; + } + } + + if (unset) + gtk_combo_box_set_active(GTK_COMBO_BOX(prefs_conv_variants_combo_box), 0); + + g_free(name); + } +} + +/* sets the current conversation theme variant */ +static void +prefs_set_conv_variant_cb(GtkComboBox *combo_box, gpointer user_data) +{ + PidginConvTheme *theme = NULL; + GtkTreeIter iter; + gchar *name = NULL; + + if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(prefs_conv_themes_combo_box), &iter)) { + gtk_tree_model_get(GTK_TREE_MODEL(prefs_conv_themes), &iter, 2, &name, -1); + theme = PIDGIN_CONV_THEME(purple_theme_manager_find_theme(name, "conversation")); + g_free(name); + + if (gtk_combo_box_get_active_iter(combo_box, &iter)) { + gtk_tree_model_get(GTK_TREE_MODEL(prefs_conv_variants), &iter, 0, &name, -1); + pidgin_conversation_theme_set_variant(theme, name); + g_free(name); + } + } +} + /* sets the current icon theme */ static void prefs_set_status_icon_theme_cb(GtkComboBox *combo_box, gpointer user_data) @@ -1110,6 +1213,40 @@ } static GtkWidget * +add_child_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) +{ + GtkWidget *label; + GtkWidget *combo_box; + GtkWidget *themesel_hbox; + GtkCellRenderer *cell_rend; + + themesel_hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); + gtk_box_pack_start(GTK_BOX(vbox), themesel_hbox, FALSE, FALSE, 0); + + label = gtk_label_new(label_str); + gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); + gtk_size_group_add_widget(label_sg, label); + gtk_box_pack_start(GTK_BOX(themesel_hbox), label, FALSE, FALSE, 0); + + combo_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL(theme_store)); + + 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, "text", 0, NULL); + g_object_set(cell_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); + + 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); + + return combo_box; +} + +static GtkWidget * theme_page(void) { GtkWidget *label; @@ -1139,6 +1276,20 @@ (GCallback)prefs_set_blist_theme_cb, NULL, _("Buddy List Theme:"), PIDGIN_PREFS_ROOT "/blist/theme", "blist"); + /* Conversation Themes */ + prefs_conv_themes_combo_box = add_theme_prefs_combo( + vbox, combo_sg, label_sg, prefs_conv_themes, + (GCallback)prefs_set_conv_theme_cb, NULL, + _("Conversation Theme:"), PIDGIN_PREFS_ROOT "/conversations/theme", "conversation"); + + /* Conversation Theme Variants */ + prefs_conv_variants_combo_box = add_child_theme_prefs_combo( + vbox, combo_sg, label_sg, prefs_conv_variants, + (GCallback)prefs_set_conv_variant_cb, NULL, _("\tVariant:")); + + gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(prefs_conv_variants), + 0, GTK_SORT_ASCENDING); + /* Status Icon Themes */ prefs_status_themes_combo_box = add_theme_prefs_combo( vbox, combo_sg, label_sg, prefs_status_icon_themes, @@ -2074,6 +2225,14 @@ path = g_find_program_in_path("gnome-network-properties"); if (path == NULL) path = g_find_program_in_path("gnome-network-preferences"); + if (path == NULL) { + path = g_find_program_in_path("gnome-control-center"); + if (path != NULL) { + char *tmp = g_strdup_printf("%s network", path); + g_free(path); + path = tmp; + } + } if (path == NULL) { label = gtk_label_new(NULL); @@ -2468,7 +2627,7 @@ sound_page(void) { GtkWidget *ret; - GtkWidget *vbox, *vbox2, *sw, *button, *parent, *parent_parent, *parent_parent_parent; + GtkWidget *vbox, *vbox2, *sw, *button; GtkSizeGroup *sg; GtkTreeIter iter; GtkWidget *event_view; @@ -2565,18 +2724,15 @@ sound_changed2_cb, vbox); #endif vbox = pidgin_make_frame(ret, _("Sound Events")); - parent = gtk_widget_get_parent(vbox); - parent_parent = gtk_widget_get_parent(parent); - parent_parent_parent = gtk_widget_get_parent(parent_parent); /* The following is an ugly hack to make the frame expand so the * sound events list is big enough to be usable */ - gtk_box_set_child_packing(GTK_BOX(parent), vbox, TRUE, TRUE, 0, + gtk_box_set_child_packing(GTK_BOX(vbox->parent), vbox, TRUE, TRUE, 0, GTK_PACK_START); - gtk_box_set_child_packing(GTK_BOX(parent_parent), - parent, TRUE, TRUE, 0, GTK_PACK_START); - gtk_box_set_child_packing(GTK_BOX(parent_parent_parent), - parent_parent, TRUE, TRUE, 0, GTK_PACK_START); + gtk_box_set_child_packing(GTK_BOX(vbox->parent->parent), vbox->parent, TRUE, + TRUE, 0, GTK_PACK_START); + gtk_box_set_child_packing(GTK_BOX(vbox->parent->parent->parent), + vbox->parent->parent, TRUE, TRUE, 0, GTK_PACK_START); /* SOUND SELECTION */ event_store = gtk_list_store_new (4, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT); @@ -2907,6 +3063,10 @@ /* Themes */ prefs_themes_init(); + /* Conversation Themes */ + purple_prefs_add_none(PIDGIN_PREFS_ROOT "/conversations"); + purple_prefs_add_string(PIDGIN_PREFS_ROOT "/conversations/theme", "Default"); + /* Smiley Themes */ purple_prefs_add_none(PIDGIN_PREFS_ROOT "/smileys"); purple_prefs_add_string(PIDGIN_PREFS_ROOT "/smileys/theme", "Default"); @@ -2929,7 +3089,6 @@ purple_prefs_rename("/purple/conversations/placement", PIDGIN_PREFS_ROOT "/conversations/placement"); - purple_prefs_rename(PIDGIN_PREFS_ROOT "/debug/timestamps", "/purple/debug/timestamps"); purple_prefs_rename(PIDGIN_PREFS_ROOT "/conversations/im/raise_on_events", "/plugins/gtk/X11/notify/method_raise"); purple_prefs_rename_boolean_toggle(PIDGIN_PREFS_ROOT "/conversations/ignore_colors", @@ -2975,6 +3134,7 @@ purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/ignore_fonts"); purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/ignore_font_sizes"); purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/passthrough_unknown_commands"); + purple_prefs_remove(PIDGIN_PREFS_ROOT "/debug/timestamps"); purple_prefs_remove(PIDGIN_PREFS_ROOT "/idle"); purple_prefs_remove(PIDGIN_PREFS_ROOT "/logging/individual_logs"); purple_prefs_remove(PIDGIN_PREFS_ROOT "/sound/signon");