From da13cfb9bee24958775f46564f007a245ac82d72 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Wed, 8 Apr 2009 05:46:20 +0000
Subject: Replace GtkTooltips code with GtkTooltip on GTK+ 2.12+.
---
pidgin/gtkblist.c | 4 ++++
pidgin/gtkconv.c | 13 +++++++++++++
pidgin/gtkconv.h | 4 ++++
pidgin/gtkdocklet-x11.c | 10 ++++++++++
pidgin/gtkimhtmltoolbar.c | 16 ++++++++++++++++
pidgin/gtkimhtmltoolbar.h | 4 ++++
pidgin/gtkmenutray.c | 10 +++++++++-
pidgin/gtkmenutray.h | 4 ++++
8 files changed, 64 insertions(+), 1 deletion(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index 89aaa51fcf..89701fe720 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -5269,6 +5269,9 @@ static void
headline_style_set (GtkWidget *widget,
GtkStyle *prev_style)
{
+#if GTK_CHECK_VERSION(2,12,0)
+ /* TODO: Need to figure out how to do this in 2.12+ */
+#else
GtkTooltips *tooltips;
GtkStyle *style;
@@ -5295,6 +5298,7 @@ headline_style_set (GtkWidget *widget,
gtkblist->changing_style = FALSE;
g_object_unref (tooltips);
+#endif
}
/******************************************/
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
index 9d3fd9691d..4b3a16ae2f 100644
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -5195,7 +5195,9 @@ private_gtkconv_new(PurpleConversation *conv, gboolean hidden)
gtkconv->send_history = g_list_append(NULL, NULL);
/* Setup some initial variables. */
+#if !GTK_CHECK_VERSION(2,12,0)
gtkconv->tooltips = gtk_tooltips_new();
+#endif
gtkconv->unseen_state = PIDGIN_UNSEEN_NONE;
gtkconv->unseen_count = 0;
@@ -5388,7 +5390,9 @@ pidgin_conv_destroy(PurpleConversation *conv)
g_free(gtkconv->u.chat);
}
+#if !GTK_CHECK_VERSION(2,12,0)
gtk_object_sink(GTK_OBJECT(gtkconv->tooltips));
+#endif
gtkconv->send_history = g_list_first(gtkconv->send_history);
g_list_foreach(gtkconv->send_history, (GFunc)g_free, NULL);
@@ -6603,8 +6607,13 @@ pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields)
topic = purple_conv_chat_get_topic(chat);
gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : "");
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_widget_set_tooltip_text(gtkchat->topic_text,
+ topic ? topic : "");
+#else
gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text,
topic ? topic : "", NULL);
+#endif
}
}
@@ -9372,8 +9381,12 @@ pidgin_conv_window_add_gtkconv(PidginWindow *win, PidginConversation *gtkconv)
g_signal_connect(G_OBJECT(gtkconv->close), "leave-notify-event", G_CALLBACK(close_button_left_cb), close_image);
gtk_widget_show(close_image);
gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image);
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_widget_set_tooltip_text(gtkconv->close, _("Close conversation"));
+#else
gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close,
_("Close conversation"), NULL);
+#endif
g_signal_connect(G_OBJECT(gtkconv->close), "button-press-event",
G_CALLBACK(close_conv_cb), gtkconv);
diff --git a/pidgin/gtkconv.h b/pidgin/gtkconv.h
index f94b6efc4a..21e1f6394d 100644
--- a/pidgin/gtkconv.h
+++ b/pidgin/gtkconv.h
@@ -121,7 +121,11 @@ struct _PidginConversation
gboolean make_sound;
+#if GTK_CHECK_VERSION(2,12,0)
+ gpointer depr2;
+#else
GtkTooltips *tooltips;
+#endif
GtkWidget *tab_cont;
GtkWidget *tabby;
diff --git a/pidgin/gtkdocklet-x11.c b/pidgin/gtkdocklet-x11.c
index 8a07edf8ca..dfe4d32ddf 100644
--- a/pidgin/gtkdocklet-x11.c
+++ b/pidgin/gtkdocklet-x11.c
@@ -39,7 +39,9 @@
/* globals */
static EggTrayIcon *docklet = NULL;
static GtkWidget *image = NULL;
+#if !GTK_CHECK_VERSION(2,12,0)
static GtkTooltips *tooltips = NULL;
+#endif
static GdkPixbuf *blank_icon = NULL;
static int embed_timeout = 0;
static int docklet_height = 0;
@@ -164,6 +166,13 @@ docklet_x11_blank_icon(void)
static void
docklet_x11_set_tooltip(gchar *tooltip)
{
+#if GTK_CHECK_VERSION(2,12,0)
+ if (tooltip) {
+ gtk_widget_set_tooltip_text(image->parent, tooltip);
+ } else {
+ gtk_widget_set_tooltip_text(image->parent, ""); /* NULL? */
+ }
+#else
if (!tooltips)
tooltips = gtk_tooltips_new();
@@ -175,6 +184,7 @@ docklet_x11_set_tooltip(gchar *tooltip)
gtk_tooltips_set_tip(tooltips, image->parent, "", NULL);
gtk_tooltips_disable(tooltips);
}
+#endif
}
#if GTK_CHECK_VERSION(2,2,0)
diff --git a/pidgin/gtkimhtmltoolbar.c b/pidgin/gtkimhtmltoolbar.c
index 39e0ce475c..6e3088f4dc 100644
--- a/pidgin/gtkimhtmltoolbar.c
+++ b/pidgin/gtkimhtmltoolbar.c
@@ -669,7 +669,11 @@ sort_smileys(struct smiley_button_list *ls, GtkIMHtmlToolbar *toolbar,
g_object_set_data(G_OBJECT(button), "smiley_text", face);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(insert_smiley_text), toolbar);
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_widget_set_tooltip_text(button, face);
+#else
gtk_tooltips_set_tip(toolbar->tooltips, button, face, NULL);
+#endif
/* these look really weird with borders */
gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
@@ -683,7 +687,11 @@ sort_smileys(struct smiley_button_list *ls, GtkIMHtmlToolbar *toolbar,
g_snprintf(tip, sizeof(tip),
_("This smiley is disabled because a custom smiley exists for this shortcut:\n %s"),
face);
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_widget_set_tooltip_text(button, tip);
+#else
gtk_tooltips_set_tip(toolbar->tooltips, button, tip, NULL);
+#endif
gtk_widget_set_sensitive(button, FALSE);
} else if (psmiley) {
/* Remove the button if the smiley is destroyed */
@@ -1147,7 +1155,9 @@ gtk_imhtmltoolbar_finalize (GObject *object)
}
g_free(toolbar->sml);
+#if !GTK_CHECK_VERSION(2,12,0)
gtk_object_sink(GTK_OBJECT(toolbar->tooltips));
+#endif
menu = g_object_get_data(object, "font_menu");
if (menu)
@@ -1244,7 +1254,11 @@ static void gtk_imhtmltoolbar_create_old_buttons(GtkIMHtmlToolbar *toolbar)
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(buttons[iter].callback), toolbar);
*(buttons[iter].button) = button;
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_widget_set_tooltip_text(button, buttons[iter].tooltip);
+#else
gtk_tooltips_set_tip(toolbar->tooltips, button, buttons[iter].tooltip, NULL);
+#endif
} else
button = gtk_vseparator_new();
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
@@ -1334,7 +1348,9 @@ static void gtk_imhtmltoolbar_init (GtkIMHtmlToolbar *toolbar)
toolbar->smiley_dialog = NULL;
toolbar->image_dialog = NULL;
+#if !GTK_CHECK_VERSION(2,12,0)
toolbar->tooltips = gtk_tooltips_new();
+#endif
gtk_box_set_spacing(GTK_BOX(toolbar), 3);
diff --git a/pidgin/gtkimhtmltoolbar.h b/pidgin/gtkimhtmltoolbar.h
index 5f67603496..33e1db007d 100644
--- a/pidgin/gtkimhtmltoolbar.h
+++ b/pidgin/gtkimhtmltoolbar.h
@@ -46,7 +46,11 @@ struct _GtkIMHtmlToolbar {
GtkWidget *imhtml;
+#if GTK_CHECK_VERSION(2,12,0)
+ gpointer depr1;
+#else
GtkTooltips *tooltips;
+#endif
GtkWidget *bold;
GtkWidget *italic;
diff --git a/pidgin/gtkmenutray.c b/pidgin/gtkmenutray.c
index d74f9ced4f..881b8f4fe9 100644
--- a/pidgin/gtkmenutray.c
+++ b/pidgin/gtkmenutray.c
@@ -104,9 +104,11 @@ pidgin_menu_tray_finalize(GObject *obj)
gtk_widget_destroy(GTK_WIDGET(tray->tray));
#endif
+#if !GTK_CHECK_VERSION(2,12,0)
if (tray->tooltips) {
gtk_object_sink(GTK_OBJECT(tray->tooltips));
}
+#endif
G_OBJECT_CLASS(parent_class)->finalize(obj);
}
@@ -244,13 +246,15 @@ pidgin_menu_tray_prepend(PidginMenuTray *menu_tray, GtkWidget *widget, const cha
void
pidgin_menu_tray_set_tooltip(PidginMenuTray *menu_tray, GtkWidget *widget, const char *tooltip)
{
+#if !GTK_CHECK_VERSION(2,12,0)
if (!menu_tray->tooltips)
menu_tray->tooltips = gtk_tooltips_new();
+#endif
/* Should we check whether widget is a child of menu_tray? */
/*
- * If the widget does not have it's own window, then it
+ * If the widget does not have its own window, then it
* must have automatically been added to an event box
* when it was added to the menu tray. If this is the
* case, we want to set the tooltip on the widget's parent,
@@ -259,6 +263,10 @@ pidgin_menu_tray_set_tooltip(PidginMenuTray *menu_tray, GtkWidget *widget, const
if (GTK_WIDGET_NO_WINDOW(widget))
widget = widget->parent;
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_widget_set_tooltip_text(widget, tooltip);
+#else
gtk_tooltips_set_tip(menu_tray->tooltips, widget, tooltip, NULL);
+#endif
}
diff --git a/pidgin/gtkmenutray.h b/pidgin/gtkmenutray.h
index 3604b7192b..7d0c683ce5 100644
--- a/pidgin/gtkmenutray.h
+++ b/pidgin/gtkmenutray.h
@@ -40,7 +40,11 @@ typedef struct _PidginMenuTrayClass PidginMenuTrayClass;
struct _PidginMenuTray {
GtkMenuItem gparent; /**< The parent instance */
GtkWidget *tray; /**< The tray */
+#if GTK_CHECK_VERSION(2,12,0)
+ gpointer depr1;
+#else
GtkTooltips *tooltips; /**< Tooltips */
+#endif
};
/** A PidginMenuTrayClass */
--
cgit v1.2.1
From 04850f3a972313683067f33a4095f1b4bbae6668 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Thu, 9 Apr 2009 04:11:01 +0000
Subject: Use GtkComboBox instead of GtkOptionMenu in the choice request field
for GTK+ 2.4 and up.
---
pidgin/gtkrequest.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c
index 7fc4b97a04..802e14b76c 100644
--- a/pidgin/gtkrequest.c
+++ b/pidgin/gtkrequest.c
@@ -202,12 +202,21 @@ field_bool_cb(GtkToggleButton *button, PurpleRequestField *field)
gtk_toggle_button_get_active(button));
}
+#if GTK_CHECK_VERSION(2,4,0)
+static void
+field_choice_menu_cb(GtkComboBox *menu, PurpleRequestField *field)
+{
+ purple_request_field_choice_set_value(field,
+ gtk_combo_box_get_active(menu));
+}
+#else
static void
field_choice_menu_cb(GtkOptionMenu *menu, PurpleRequestField *field)
{
purple_request_field_choice_set_value(field,
gtk_option_menu_get_history(menu));
}
+#endif
static void
field_choice_option_cb(GtkRadioButton *button, PurpleRequestField *field)
@@ -870,6 +879,21 @@ create_choice_field(PurpleRequestField *field)
if (num_labels > 5)
{
+#if GTK_CHECK_VERSION(2,4,0)
+ widget = gtk_combo_box_new_text();
+
+ for (l = labels; l != NULL; l = l->next)
+ {
+ const char *text = l->data;
+ gtk_combo_box_append_text(GTK_COMBO_BOX(widget), text);
+ }
+
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
+ purple_request_field_choice_get_default_value(field));
+
+ g_signal_connect(G_OBJECT(widget), "changed",
+ G_CALLBACK(field_choice_menu_cb), field);
+#else
GtkWidget *menu;
GtkWidget *item;
@@ -894,6 +918,7 @@ create_choice_field(PurpleRequestField *field)
g_signal_connect(G_OBJECT(widget), "changed",
G_CALLBACK(field_choice_menu_cb), field);
+#endif
}
else
{
--
cgit v1.2.1
From 9e7164a610c0cb894bc860fc66a92fddda159365 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Thu, 9 Apr 2009 04:13:52 +0000
Subject: Replace the GtkOptionMenu with a GtkComboBox for the privacy options
list on GTK+ 2.4 and up.
---
pidgin/gtkprivacy.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/pidgin/gtkprivacy.c b/pidgin/gtkprivacy.c
index 518b03d508..730225b15c 100644
--- a/pidgin/gtkprivacy.c
+++ b/pidgin/gtkprivacy.c
@@ -220,7 +220,11 @@ select_account_cb(GtkWidget *dropdown, PurpleAccount *account,
for (i = 0; i < menu_entry_count; i++) {
if (menu_entries[i].num == account->perm_deny) {
+#if GTK_CHECK_VERSION(2,4,0)
+ gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->type_menu), i);
+#else
gtk_option_menu_set_history(GTK_OPTION_MENU(dialog->type_menu), i);
+#endif
break;
}
}
@@ -233,10 +237,17 @@ select_account_cb(GtkWidget *dropdown, PurpleAccount *account,
* TODO: Setting the permit/deny setting needs to go through privacy.c
* Even better: the privacy API needs to not suck.
*/
+#if GTK_CHECK_VERSION(2,4,0)
+static void
+type_changed_cb(GtkComboBox *combo, PidginPrivacyDialog *dialog)
+{
+ int new_type = menu_entries[gtk_combo_box_get_active(combo)].num;
+#else
static void
type_changed_cb(GtkOptionMenu *optmenu, PidginPrivacyDialog *dialog)
{
int new_type = menu_entries[gtk_option_menu_get_history(optmenu)].num;
+#endif
dialog->account->perm_deny = new_type;
serv_set_permit_deny(purple_account_get_connection(dialog->account));
@@ -343,7 +354,9 @@ privacy_dialog_new(void)
GtkWidget *button;
GtkWidget *dropdown;
GtkWidget *label;
+#if !GTK_CHECK_VERSION(2,4,0)
GtkWidget *menu;
+#endif
int selected = 0;
int i;
@@ -372,6 +385,24 @@ privacy_dialog_new(void)
dialog->account = pidgin_account_option_menu_get_selected(dropdown);
/* Add the drop-down list with the allow/block types. */
+#if GTK_CHECK_VERSION(2,4,0)
+ dialog->type_menu = gtk_combo_box_new_text();
+ gtk_box_pack_start(GTK_BOX(vbox), dialog->type_menu, FALSE, FALSE, 0);
+ gtk_widget_show(dialog->type_menu);
+
+ for (i = 0; i < menu_entry_count; i++) {
+ gtk_combo_box_append_text(GTK_COMBO_BOX(dialog->type_menu),
+ _(menu_entries[i].text));
+
+ if (menu_entries[i].num == dialog->account->perm_deny)
+ selected = i;
+ }
+
+ gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->type_menu), selected);
+
+ g_signal_connect(G_OBJECT(dialog->type_menu), "changed",
+ G_CALLBACK(type_changed_cb), dialog);
+#else
dialog->type_menu = gtk_option_menu_new();
gtk_box_pack_start(GTK_BOX(vbox), dialog->type_menu, FALSE, FALSE, 0);
gtk_widget_show(dialog->type_menu);
@@ -391,6 +422,7 @@ privacy_dialog_new(void)
g_signal_connect(G_OBJECT(dialog->type_menu), "changed",
G_CALLBACK(type_changed_cb), dialog);
+#endif
/* Build the treeview for the allow list. */
dialog->allow_widget = build_allow_list(dialog);
@@ -421,7 +453,11 @@ privacy_dialog_new(void)
button = pidgin_dialog_add_button(GTK_DIALOG(dialog->win), GTK_STOCK_CLOSE, G_CALLBACK(close_cb), dialog);
dialog->close_button = button;
+#if GTK_CHECK_VERSION(2,4,0)
+ type_changed_cb(GTK_COMBO_BOX(dialog->type_menu), dialog);
+#else
type_changed_cb(GTK_OPTION_MENU(dialog->type_menu), dialog);
+#endif
#if 0
if (dialog->account->perm_deny == PURPLE_PRIVACY_ALLOW_USERS) {
gtk_widget_show(dialog->allow_widget);
--
cgit v1.2.1
From 6e539391f7174dca0e46dca1cbe919a8fc5bfb3d Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Thu, 9 Apr 2009 04:18:50 +0000
Subject: Replace GtkOptionMenu with GtkComboBox in the saved status editor for
GTK+ 2.4 and up.
---
pidgin/gtksavedstatuses.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 67 insertions(+), 1 deletion(-)
diff --git a/pidgin/gtksavedstatuses.c b/pidgin/gtksavedstatuses.c
index 9df26bf30b..4780ee1743 100644
--- a/pidgin/gtksavedstatuses.c
+++ b/pidgin/gtksavedstatuses.c
@@ -119,7 +119,11 @@ typedef struct
gchar *original_title;
GtkEntry *title;
+#if GTK_CHECK_VERSION(2,4,0)
+ GtkComboBox *type;
+#else
GtkOptionMenu *type;
+#endif
GtkIMHtml *message;
} StatusEditor;
@@ -795,7 +799,11 @@ status_editor_ok_cb(GtkButton *button, gpointer user_data)
return;
}
+#if GTK_CHECK_VERSION(2,4,0)
+ type = gtk_combo_box_get_active(dialog->type) + (PURPLE_STATUS_UNSET + 1);
+#else
type = gtk_option_menu_get_history(dialog->type) + (PURPLE_STATUS_UNSET + 1);
+#endif
message = gtk_imhtml_get_markup(dialog->message);
unformatted = purple_markup_strip_html(message);
@@ -889,6 +897,58 @@ editor_title_changed_cb(GtkWidget *widget, gpointer user_data)
gtk_widget_set_sensitive(GTK_WIDGET(dialog->save_button), (*text != '\0'));
}
+#if GTK_CHECK_VERSION(2,4,0)
+
+static GtkWidget *
+create_status_type_menu(PurpleStatusPrimitive type)
+{
+ int i;
+ GtkWidget *dropdown;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkCellRenderer *renderer;
+
+ store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
+
+ for (i = PURPLE_STATUS_UNSET + 1; i < PURPLE_STATUS_NUM_PRIMITIVES; i++)
+ {
+ if (i == PURPLE_STATUS_MOBILE || i == PURPLE_STATUS_TUNE)
+ /*
+ * Special-case these. They're intended to be independent
+ * status types, so don't show them in the list.
+ */
+ continue;
+
+ gtk_list_store_append(store, &iter);
+ /* TODO: how's this get the right size (since it seems to work fine)? */
+ gtk_list_store_set(store, &iter,
+ 0, get_stock_icon_from_primitive(i),
+ 1, purple_primitive_get_name_from_type(i),
+ -1);
+ }
+
+ dropdown = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
+
+ renderer = gtk_cell_renderer_pixbuf_new();
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(dropdown), renderer, FALSE);
+ gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dropdown), renderer,
+ "stock-id", 0,
+ NULL);
+
+ renderer = gtk_cell_renderer_text_new();
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(dropdown), renderer, TRUE);
+ gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dropdown), renderer,
+ "text", 1,
+ NULL);
+
+ gtk_combo_box_set_active(GTK_COMBO_BOX(dropdown),
+ type - (PURPLE_STATUS_UNSET + 1));
+
+ return dropdown;
+}
+
+#else
+
static GtkWidget *
create_stock_item(const gchar *str, const gchar *icon)
{
@@ -896,7 +956,7 @@ create_stock_item(const gchar *str, const gchar *icon)
GtkWidget *label = gtk_label_new_with_mnemonic(str);
GtkWidget *hbox = gtk_hbox_new(FALSE, 4);
GtkIconSize icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL);
- GtkWidget *image = gtk_image_new_from_stock(icon, icon_size);;
+ GtkWidget *image = gtk_image_new_from_stock(icon, icon_size);
gtk_widget_show(label);
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
@@ -941,6 +1001,8 @@ create_status_type_menu(PurpleStatusPrimitive type)
return dropdown;
}
+#endif
+
static void edit_substatus(StatusEditor *status_editor, PurpleAccount *account);
static void
@@ -1206,7 +1268,11 @@ pidgin_status_editor_show(gboolean edit, PurpleSavedStatus *saved_status)
dropdown = create_status_type_menu(purple_savedstatus_get_type(saved_status));
else
dropdown = create_status_type_menu(PURPLE_STATUS_AWAY);
+#if GTK_CHECK_VERSION(2,4,0)
+ dialog->type = GTK_COMBO_BOX(dropdown);
+#else
dialog->type = GTK_OPTION_MENU(dropdown);
+#endif
pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("_Status:"), sg, dropdown, TRUE, NULL);
/* Status message */
--
cgit v1.2.1
From e12e713d9defe2a71a4181aa4dd7d66a763e90e6 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Thu, 9 Apr 2009 04:21:12 +0000
Subject: Replace GtkOptionMenu with GtkComboBox in the gestures plugin for
GTK+ 2.4 and up. But that code's commented out, so this is totally untested.
---
pidgin/plugins/gestures/gestures.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/pidgin/plugins/gestures/gestures.c b/pidgin/plugins/gestures/gestures.c
index 20c4c3d39a..3dabbc02e3 100644
--- a/pidgin/plugins/gestures/gestures.c
+++ b/pidgin/plugins/gestures/gestures.c
@@ -149,6 +149,15 @@ new_conv_cb(PurpleConversation *conv)
}
#if 0
+#if GTK_CHECK_VERSION(2,4,0)
+static void
+mouse_button_menu_cb(GtkComboBox *opt, gpointer data)
+{
+ int button = gtk_combo_box_get_active(opt);
+
+ gstroke_set_mouse_button(button + 2);
+}
+#else
static void
mouse_button_menu_cb(GtkMenuItem *item, gpointer data)
{
@@ -157,6 +166,7 @@ mouse_button_menu_cb(GtkMenuItem *item, gpointer data)
gstroke_set_mouse_button(button + 2);
}
#endif
+#endif
static void
toggle_draw_cb(GtkToggleButton *toggle, gpointer data)
@@ -224,7 +234,9 @@ get_config_frame(PurplePlugin *plugin)
GtkWidget *toggle;
#if 0
GtkWidget *opt;
+#if GTK_CHECK_VERSION(2,4,0)
GtkWidget *menu, *item;
+#endif
#endif
/* Outside container */
@@ -235,6 +247,19 @@ get_config_frame(PurplePlugin *plugin)
vbox = pidgin_make_frame(ret, _("Mouse Gestures Configuration"));
#if 0
+#if GTK_CHECK_VERSION(2,4,0)
+ /* Mouse button drop-down menu */
+ opt = gtk_combo_box_new_text();
+
+ gtk_combo_box_append_text(_("Middle mouse button"));
+ gtk_combo_box_append_text(_("Right mouse button"));
+ g_signal_connect(G_OBJECT(opt), "changed",
+ G_CALLBACK(mouse_button_menu_cb), NULL);
+
+ gtk_box_pack_start(GTK_BOX(vbox), opt, FALSE, FALSE, 0);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(opt),
+ gstroke_get_mouse_button() - 2);
+#else
/* Mouse button drop-down menu */
menu = gtk_menu_new();
opt = gtk_option_menu_new();
@@ -253,6 +278,7 @@ get_config_frame(PurplePlugin *plugin)
gtk_option_menu_set_menu(GTK_OPTION_MENU(opt), menu);
gtk_option_menu_set_history(GTK_OPTION_MENU(opt),
gstroke_get_mouse_button() - 2);
+#endif
#endif
/* "Visual gesture display" checkbox */
--
cgit v1.2.1
From 116b2fee700680a9bfaab90118782f9f9a9537f3 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Fri, 10 Apr 2009 04:55:52 +0000
Subject: Replace GtkOptionMenu with a GtkComboBox in the preferences dropdowns
for GTK+ 2.4 and up.
---
pidgin/gtkprefs.c | 155 +++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 130 insertions(+), 25 deletions(-)
diff --git a/pidgin/gtkprefs.c b/pidgin/gtkprefs.c
index d07bd7f374..7fc461b0c0 100644
--- a/pidgin/gtkprefs.c
+++ b/pidgin/gtkprefs.c
@@ -164,14 +164,52 @@ pidgin_prefs_labeled_password(GtkWidget *page, const gchar *title,
return pidgin_add_widget_to_vbox(GTK_BOX(page), title, sg, entry, TRUE, NULL);
}
+/* TODO: Maybe move this up somewheres... */
+enum {
+ PREF_DROPDOWN_TEXT,
+ PREF_DROPDOWN_VALUE,
+ PREF_DROPDOWN_COUNT
+};
static void
dropdown_set(GObject *w, const char *key)
{
const char *str_value;
int int_value;
+ gboolean bool_value;
PurplePrefType type;
+#if GTK_CHECK_VERSION(2,4,0)
+ GtkTreeIter iter;
+ GtkTreeModel *tree_model;
+
+ tree_model = gtk_combo_box_get_model(GTK_COMBO_BOX(w));
+ gtk_combo_box_get_active_iter(GTK_COMBO_BOX(w), &iter);
+
+ type = GPOINTER_TO_INT(g_object_get_data(w, "type"));
+
+ if (type == PURPLE_PREF_INT) {
+ gtk_tree_model_get(tree_model, &iter,
+ PREF_DROPDOWN_VALUE, &int_value,
+ -1);
+
+ purple_prefs_set_int(key, int_value);
+ }
+ else if (type == PURPLE_PREF_STRING) {
+ gtk_tree_model_get(tree_model, &iter,
+ PREF_DROPDOWN_VALUE, &str_value,
+ -1);
+
+ purple_prefs_set_string(key, str_value);
+ }
+ else if (type == PURPLE_PREF_BOOLEAN) {
+ gtk_tree_model_get(tree_model, &iter,
+ PREF_DROPDOWN_VALUE, &bool_value,
+ -1);
+
+ purple_prefs_set_bool(key, bool_value);
+ }
+#else
type = GPOINTER_TO_INT(g_object_get_data(w, "type"));
if (type == PURPLE_PREF_INT) {
@@ -185,64 +223,129 @@ dropdown_set(GObject *w, const char *key)
purple_prefs_set_string(key, str_value);
}
else if (type == PURPLE_PREF_BOOLEAN) {
- purple_prefs_set_bool(key,
- GPOINTER_TO_INT(g_object_get_data(w, "value")));
+ bool_value = (gboolean)GPOINTER_TO_INT(g_object_get_data(w, "value"));
+ purple_prefs_set_bool(key, bool_value);
}
+#endif
}
GtkWidget *
pidgin_prefs_dropdown_from_list(GtkWidget *box, const gchar *title,
PurplePrefType type, const char *key, GList *menuitems)
{
- GtkWidget *dropdown, *opt, *menu;
+ GtkWidget *dropdown;
GtkWidget *label = NULL;
gchar *text;
const char *stored_str = NULL;
int stored_int = 0;
+ gboolean stored_bool = FALSE;
int int_value = 0;
const char *str_value = NULL;
- int o = 0;
+ gboolean bool_value = FALSE;
+#if GTK_CHECK_VERSION(2,4,0)
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkTreeIter active;
+ GtkCellRenderer *renderer;
g_return_val_if_fail(menuitems != NULL, NULL);
-#if 0 /* GTK_CHECK_VERSION(2,4,0) */
- if(type == PURPLE_PREF_INT)
- model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
- else if(type == PURPLE_PREF_STRING)
- model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
- dropdown = gtk_combo_box_new_with_model(model);
+ if (type == PURPLE_PREF_INT) {
+ store = gtk_list_store_new(PREF_DROPDOWN_COUNT, G_TYPE_STRING, G_TYPE_INT);
+ stored_int = purple_prefs_get_int(key);
+ } else if (type == PURPLE_PREF_STRING) {
+ store = gtk_list_store_new(PREF_DROPDOWN_COUNT, G_TYPE_STRING, G_TYPE_STRING);
+ stored_str = purple_prefs_get_string(key);
+ } 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);
+ }
+
+ dropdown = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
+ g_object_set_data(G_OBJECT(dropdown), "type", GINT_TO_POINTER(type));
+
+ while (menuitems != NULL && (text = (char *)menuitems->data) != NULL) {
+ menuitems = g_list_next(menuitems);
+ g_return_val_if_fail(menuitems != NULL, NULL);
+
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ PREF_DROPDOWN_TEXT, text,
+ -1);
+
+ if (type == PURPLE_PREF_INT) {
+ int_value = GPOINTER_TO_INT(menuitems->data);
+ gtk_list_store_set(store, &iter,
+ PREF_DROPDOWN_VALUE, int_value,
+ -1);
+ }
+ else if (type == PURPLE_PREF_STRING) {
+ str_value = (const char *)menuitems->data;
+ gtk_list_store_set(store, &iter,
+ PREF_DROPDOWN_VALUE, str_value,
+ -1);
+ }
+ else if (type == PURPLE_PREF_BOOLEAN) {
+ bool_value = (gboolean)GPOINTER_TO_INT(menuitems->data);
+ gtk_list_store_set(store, &iter,
+ PREF_DROPDOWN_VALUE, bool_value,
+ -1);
+ }
+
+ if ((type == PURPLE_PREF_INT && stored_int == int_value) ||
+ (type == PURPLE_PREF_STRING && stored_str != NULL &&
+ !strcmp(stored_str, str_value)) ||
+ (type == PURPLE_PREF_BOOLEAN &&
+ (stored_bool == bool_value))) {
+
+ active = iter;
+ }
+
+ menuitems = g_list_next(menuitems);
+ }
+
+ renderer = gtk_cell_renderer_text_new();
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(dropdown), renderer, TRUE);
+ gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dropdown), renderer,
+ "text", 0,
+ NULL);
+
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(dropdown), &active);
+
+ g_signal_connect(G_OBJECT(dropdown), "changed",
+ G_CALLBACK(dropdown_set), (char *)key);
+
#else
+ GtkWidget *opt, *menu;
+ int o = 0;
+
+ g_return_val_if_fail(menuitems != NULL, NULL);
+
dropdown = gtk_option_menu_new();
menu = gtk_menu_new();
-#endif
if (type == PURPLE_PREF_INT)
stored_int = purple_prefs_get_int(key);
else if (type == PURPLE_PREF_STRING)
stored_str = purple_prefs_get_string(key);
+ else if (type == PURPLE_PREF_BOOLEAN)
+ stored_bool = purple_prefs_get_bool(key);
- while (menuitems != NULL && (text = (char *) menuitems->data) != NULL) {
+ while (menuitems != NULL && (text = (char *)menuitems->data) != NULL) {
menuitems = g_list_next(menuitems);
g_return_val_if_fail(menuitems != NULL, NULL);
opt = gtk_menu_item_new_with_label(text);
g_object_set_data(G_OBJECT(opt), "type", GINT_TO_POINTER(type));
+ g_object_set_data(G_OBJECT(opt), "value", menuitems->data);
- if (type == PURPLE_PREF_INT) {
+ if (type == PURPLE_PREF_INT)
int_value = GPOINTER_TO_INT(menuitems->data);
- g_object_set_data(G_OBJECT(opt), "value",
- GINT_TO_POINTER(int_value));
- }
- else if (type == PURPLE_PREF_STRING) {
+ else if (type == PURPLE_PREF_STRING)
str_value = (const char *)menuitems->data;
-
- g_object_set_data(G_OBJECT(opt), "value", (char *)str_value);
- }
- else if (type == PURPLE_PREF_BOOLEAN) {
- g_object_set_data(G_OBJECT(opt), "value",
- menuitems->data);
- }
+ else if (type == PURPLE_PREF_BOOLEAN)
+ bool_value = (gboolean)GPOINTER_TO_INT(menuitems->data);
g_signal_connect(G_OBJECT(opt), "activate",
G_CALLBACK(dropdown_set), (char *)key);
@@ -254,7 +357,7 @@ pidgin_prefs_dropdown_from_list(GtkWidget *box, const gchar *title,
(type == PURPLE_PREF_STRING && stored_str != NULL &&
!strcmp(stored_str, str_value)) ||
(type == PURPLE_PREF_BOOLEAN &&
- (purple_prefs_get_bool(key) == GPOINTER_TO_INT(menuitems->data)))) {
+ (stored_bool == bool_value))) {
gtk_menu_set_active(GTK_MENU(menu), o);
}
@@ -266,6 +369,8 @@ pidgin_prefs_dropdown_from_list(GtkWidget *box, const gchar *title,
gtk_option_menu_set_menu(GTK_OPTION_MENU(dropdown), menu);
+#endif
+
pidgin_add_widget_to_vbox(GTK_BOX(box), title, NULL, dropdown, FALSE, &label);
return label;
--
cgit v1.2.1
From fd6fca1a8a584cd53bfdd1f26bb98fff51e2b447 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Fri, 10 Apr 2009 05:00:13 +0000
Subject: Add an enumeration to replace a couple hardcoded numbers in the combo
box code for saved statuses.
---
pidgin/gtksavedstatuses.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/pidgin/gtksavedstatuses.c b/pidgin/gtksavedstatuses.c
index 4780ee1743..4613f9fffe 100644
--- a/pidgin/gtksavedstatuses.c
+++ b/pidgin/gtksavedstatuses.c
@@ -899,6 +899,12 @@ editor_title_changed_cb(GtkWidget *widget, gpointer user_data)
#if GTK_CHECK_VERSION(2,4,0)
+enum {
+ STATUS_MENU_STOCK_ICON,
+ STATUS_MENU_NAME,
+ STATUS_MENU_COUNT
+};
+
static GtkWidget *
create_status_type_menu(PurpleStatusPrimitive type)
{
@@ -908,7 +914,7 @@ create_status_type_menu(PurpleStatusPrimitive type)
GtkTreeIter iter;
GtkCellRenderer *renderer;
- store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
+ store = gtk_list_store_new(STATUS_MENU_COUNT, G_TYPE_STRING, G_TYPE_STRING);
for (i = PURPLE_STATUS_UNSET + 1; i < PURPLE_STATUS_NUM_PRIMITIVES; i++)
{
@@ -922,8 +928,8 @@ create_status_type_menu(PurpleStatusPrimitive type)
gtk_list_store_append(store, &iter);
/* TODO: how's this get the right size (since it seems to work fine)? */
gtk_list_store_set(store, &iter,
- 0, get_stock_icon_from_primitive(i),
- 1, purple_primitive_get_name_from_type(i),
+ STATUS_MENU_STOCK_ICON, get_stock_icon_from_primitive(i),
+ STATUS_MENU_NAME, purple_primitive_get_name_from_type(i),
-1);
}
@@ -932,13 +938,13 @@ create_status_type_menu(PurpleStatusPrimitive type)
renderer = gtk_cell_renderer_pixbuf_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(dropdown), renderer, FALSE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dropdown), renderer,
- "stock-id", 0,
+ "stock-id", STATUS_MENU_STOCK_ICON,
NULL);
renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(dropdown), renderer, TRUE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dropdown), renderer,
- "text", 1,
+ "text", STATUS_MENU_NAME,
NULL);
gtk_combo_box_set_active(GTK_COMBO_BOX(dropdown),
--
cgit v1.2.1
From ca815a89293168ba3d04b5cec794c76031d314b1 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Sun, 19 Apr 2009 03:21:27 +0000
Subject: Update the toolbar code in the Debug Window. There remains a bug when
it's set to "Icons and Text", because all I see are the icons (and the one
that has no icon is blank). If I set the toolbar to "Text Only" or "Icons
Only" then it works correctly.
---
pidgin/gtkdebug.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 126 insertions(+), 2 deletions(-)
diff --git a/pidgin/gtkdebug.c b/pidgin/gtkdebug.c
index 07e8872dcd..97d38fe48d 100644
--- a/pidgin/gtkdebug.c
+++ b/pidgin/gtkdebug.c
@@ -43,6 +43,19 @@
#include
+/* TODO: I'm too lazy to change all these until we bump required GTK+ version */
+#if GTK_CHECK_VERSION(2,4,0)
+#undef GTK_TOGGLE_BUTTON
+#undef gtk_toggle_button_get_active
+#undef gtk_toggle_button_set_active
+#undef GtkToggleButton
+
+#define GTK_TOGGLE_BUTTON GTK_TOGGLE_TOOL_BUTTON
+#define gtk_toggle_button_get_active gtk_toggle_tool_button_get_active
+#define gtk_toggle_button_set_active gtk_toggle_tool_button_set_active
+#define GtkToggleButton GtkToggleToolButton
+#endif
+
typedef struct
{
GtkWidget *window;
@@ -677,9 +690,16 @@ debug_window_new(void)
GtkWidget *vbox;
GtkWidget *toolbar;
GtkWidget *frame;
- GtkWidget *image;
gint width, height;
void *handle;
+#if GTK_CHECK_VERSION(2,4,0)
+ GtkToolItem *item;
+#if !GTK_CHECK_VERSION(2,12,0)
+ GtkTooltips *tooltips;
+#endif
+#else
+ GtkWidget *image;
+#endif
win = g_new0(DebugWindow, 1);
@@ -719,7 +739,12 @@ debug_window_new(void)
if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/toolbar")) {
/* Setup our top button bar thingie. */
toolbar = gtk_toolbar_new();
+#if GTK_CHECK_VERSION(2,4,0) && !GTK_CHECK_VERSION(2,12,0)
+ tooltips = gtk_tooltips_new();
+#endif
+#if !GTK_CHECK_VERSION(2,14,0)
gtk_toolbar_set_tooltips(GTK_TOOLBAR(toolbar), TRUE);
+#endif
#if GTK_CHECK_VERSION(2,4,0)
gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE);
#endif
@@ -736,36 +761,101 @@ debug_window_new(void)
#ifndef HAVE_REGEX_H
/* Find button */
+#if GTK_CHECK_VERSION(2,4,0)
+ item = gtk_tool_button_new_from_stock(GTK_STOCK_FIND);
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_tool_item_set_tooltip_text(item, _("Find"));
+#else
+ gtk_tool_item_set_tooltip(item, tooltips, _("Find"), NULL);
+#endif
+ g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(find_cb), win);
+ gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
+#else
gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_FIND,
_("Find"), NULL, G_CALLBACK(find_cb),
win, -1);
+#endif
#endif /* HAVE_REGEX_H */
/* Save */
+#if GTK_CHECK_VERSION(2,4,0)
+ item = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE);
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_tool_item_set_tooltip_text(item, _("Save"));
+#else
+ gtk_tool_item_set_tooltip(item, tooltips, _("Save"), NULL);
+#endif
+ g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(save_cb), win);
+ gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
+#else
gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_SAVE,
_("Save"), NULL, G_CALLBACK(save_cb),
win, -1);
+#endif
/* Clear button */
+#if GTK_CHECK_VERSION(2,4,0)
+ item = gtk_tool_button_new_from_stock(GTK_STOCK_CLEAR);
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_tool_item_set_tooltip_text(item, _("Clear"));
+#else
+ gtk_tool_item_set_tooltip(item, tooltips, _("Clear"), NULL);
+#endif
+ g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(clear_cb), win);
+ gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
+#else
gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_CLEAR,
_("Clear"), NULL, G_CALLBACK(clear_cb),
win, -1);
+#endif
+#if GTK_CHECK_VERSION(2,4,0)
+ item = gtk_separator_tool_item_new();
+ gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
+#else
gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1);
+#endif
/* Pause */
+#if GTK_CHECK_VERSION(2,4,0)
+ item = gtk_tool_button_new_from_stock(PIDGIN_STOCK_PAUSE);
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_tool_item_set_tooltip_text(item, _("Pause"));
+#else
+ gtk_tool_item_set_tooltip(item, tooltips, _("Pause"), NULL);
+#endif
+ g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(pause_cb), win);
+ gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
+#else
image = gtk_image_new_from_stock(PIDGIN_STOCK_PAUSE, GTK_ICON_SIZE_MENU);
gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
NULL, _("Pause"), _("Pause"),
NULL, image,
G_CALLBACK(pause_cb), win);
+#endif
#ifdef HAVE_REGEX_H
/* regex stuff */
+#if GTK_CHECK_VERSION(2,4,0)
+ item = gtk_separator_tool_item_new();
+ gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
+#else
gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1);
+#endif
/* regex toggle button */
+#if GTK_CHECK_VERSION(2,4,0)
+ win->filter = GTK_WIDGET(gtk_toggle_tool_button_new());
+ gtk_tool_button_set_label(GTK_TOOL_BUTTON(win->filter), _("Filter"));
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(win->filter), _("Filter"));
+#else
+ gtk_tooltips_set_tip(tooltips, win->filter, _("Filter"), NULL);
+#endif
+ g_signal_connect(G_OBJECT(win->filter), "clicked", G_CALLBACK(regex_filter_toggled_cb), win);
+ gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(win->filter));
+#else
win->filter =
gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
@@ -773,6 +863,8 @@ debug_window_new(void)
NULL, NULL,
G_CALLBACK(regex_filter_toggled_cb),
win);
+#endif
+
/* we purposely disable the toggle button here in case
* /purple/gtk/debug/expression has an empty string. If it does not have
* an empty string, the change signal will get called and make the
@@ -786,10 +878,21 @@ debug_window_new(void)
/* regex entry */
win->expression = gtk_entry_new();
+#if GTK_CHECK_VERSION(2,4,0)
+ item = gtk_tool_item_new();
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_widget_set_tooltip_text(win->expression, _("Right click for more options."));
+#else
+ gtk_tooltips_set_tip(tooltips, win->expression, _("Right click for more options."), NULL);
+#endif
+ gtk_container_add(GTK_CONTAINER(item), GTK_WIDGET(win->expression));
+ gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
+#else
gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
GTK_TOOLBAR_CHILD_WIDGET, win->expression,
NULL, _("Right click for more options."),
NULL, NULL, NULL, NULL);
+#endif
/* this needs to be before the text is set from the pref if we want it
* to colorize a stored expression.
*/
@@ -815,18 +918,39 @@ debug_window_new(void)
#endif /* HAVE_REGEX_H */
+#if GTK_CHECK_VERSION(2,4,0)
+ item = gtk_separator_tool_item_new();
+ gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
+#else
gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1);
+#endif
+#if GTK_CHECK_VERSION(2,4,0)
+ item = gtk_tool_item_new();
+ gtk_container_add(GTK_CONTAINER(item), gtk_label_new(_("Level ")));
+ gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
+#else
gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
GTK_TOOLBAR_CHILD_WIDGET, gtk_label_new(_("Level ")),
NULL, _("Select the debug filter level."),
NULL, NULL, NULL, NULL);
-
+#endif
win->filterlevel = gtk_combo_box_new_text();
+#if GTK_CHECK_VERSION(2,4,0)
+ item = gtk_tool_item_new();
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_widget_set_tooltip_text(win->filterlevel, _("Select the debug filter level."));
+#else
+ gtk_tooltips_set_tip(tooltips, win->filterlevel, _("Select the debug filter level."), NULL);
+#endif
+ gtk_container_add(GTK_CONTAINER(item), win->filterlevel);
+ gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
+#else
gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
GTK_TOOLBAR_CHILD_WIDGET, win->filterlevel,
NULL, _("Select the debug filter level."),
NULL, NULL, NULL, NULL);
+#endif
gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("All"));
gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Misc"));
gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Info"));
--
cgit v1.2.1
From 6ae3846d47778cc0450b883322d9cc2063cccb10 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Sun, 10 May 2009 06:24:26 +0000
Subject: If gedit can do it, then so can we!
References #4351.
---
pidgin/gtkblist.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index 2107d2e4a3..09ca3ce858 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -5276,11 +5276,28 @@ static void
headline_style_set (GtkWidget *widget,
GtkStyle *prev_style)
{
+ GtkStyle *style;
#if GTK_CHECK_VERSION(2,12,0)
- /* TODO: Need to figure out how to do this in 2.12+ */
+ GtkWidget *window;
+
+ if (gtkblist->changing_style)
+ return;
+
+ /* This is a hack needed to use the tooltip background colour */
+ window = gtk_window_new(GTK_WINDOW_POPUP);
+ gtk_widget_set_name(window, "gtk-tooltip");
+ gtk_widget_ensure_style(window);
+ style = gtk_widget_get_style(window);
+
+ gtkblist->changing_style = TRUE;
+ gtk_widget_set_style(gtkblist->headline_hbox, style);
+ gtkblist->changing_style = FALSE;
+
+ gtk_widget_destroy(window);
+
+ gtk_widget_queue_draw(gtkblist->headline_hbox);
#else
GtkTooltips *tooltips;
- GtkStyle *style;
if (gtkblist->changing_style)
return;
--
cgit v1.2.1
From 869749577f14b25da2189dcecd6db0df6f0fe6c2 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Fri, 24 Jul 2009 01:18:07 +0000
Subject: Webkit Message views.
This commit is a squashed commit of the series of commits from my git repository which I was using for development.
(git://github.com/tdrhq/pidgin-clone.git, branch webkit)
---
configure.ac | 3 +
pidgin/Makefile.am | 10 +-
pidgin/gtkconv.c | 543 ++++++++-------------------------------------
pidgin/gtkconv.h | 2 +-
pidgin/gtkdialogs.c | 26 ++-
pidgin/gtklog.c | 37 +--
pidgin/gtklog.h | 2 +-
pidgin/gtknotify.c | 52 ++---
pidgin/gtkthemes.c | 4 +-
pidgin/gtkthemes.h | 1 +
pidgin/plugins/Makefile.am | 41 +---
11 files changed, 164 insertions(+), 557 deletions(-)
diff --git a/configure.ac b/configure.ac
index b69cecebd8..9b54f7bee3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -700,6 +700,8 @@ AM_CONDITIONAL(ENABLE_GNT, test "x$enable_consoleui" = "xyes")
#AC_CHECK_FUNC(wcwidth, [AC_DEFINE([HAVE_WCWIDTH], [1], [Define to 1 if you have wcwidth function.])])
+PKG_CHECK_MODULES(WEBKIT, [webkit-1.0 >= 1.1.1]);
+
dnl #######################################################################
dnl # Check for LibXML2 (required)
dnl #######################################################################
@@ -2476,6 +2478,7 @@ AC_OUTPUT([Makefile
pidgin/pixmaps/emotes/none/Makefile
pidgin/pixmaps/emotes/small/16/Makefile
pidgin/plugins/Makefile
+ pidgin/plugins/adiumthemes/Makefile
pidgin/plugins/cap/Makefile
pidgin/plugins/disco/Makefile
pidgin/plugins/gestures/Makefile
diff --git a/pidgin/Makefile.am b/pidgin/Makefile.am
index 058be59c2a..eec1d627a6 100644
--- a/pidgin/Makefile.am
+++ b/pidgin/Makefile.am
@@ -125,9 +125,11 @@ pidgin_SOURCES = \
gtkstatusbox.c \
gtkthemes.c \
gtkutils.c \
+ gtkwebview.c \
gtkwhiteboard.c \
minidialog.c \
- pidgintooltip.c
+ pidgintooltip.c \
+ smileyparser.c
pidgin_headers = \
eggtrayicon.h \
@@ -183,10 +185,12 @@ pidgin_headers = \
pidginstock.h \
gtkthemes.h \
gtkutils.h \
+ gtkwebview.h \
gtkwhiteboard.h \
minidialog.h \
pidgintooltip.h \
- pidgin.h
+ pidgin.h \
+ smileyparser.h
pidginincludedir=$(includedir)/pidgin
pidgininclude_HEADERS = \
@@ -206,6 +210,7 @@ pidgin_LDADD = \
$(GTKSPELL_LIBS) \
$(STARTUP_NOTIFICATION_LIBS) \
$(LIBXML_LIBS) \
+ $(WEBKIT_LIBS) \
$(GTK_LIBS) \
$(top_builddir)/libpurple/libpurple.la
@@ -231,5 +236,6 @@ AM_CPPFLAGS = \
$(GTKSPELL_CFLAGS) \
$(STARTUP_NOTIFICATION_CFLAGS) \
$(LIBXML_CFLAGS) \
+ $(WEBKIT_CFLAGS) \
$(INTGG_CFLAGS)
endif # ENABLE_GTK
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
index d235759bc7..872b6e6526 100644
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -69,6 +69,7 @@
#include "gtkprivacy.h"
#include "gtkthemes.h"
#include "gtkutils.h"
+#include "gtkwebview.h"
#include "pidginstock.h"
#include "pidgintooltip.h"
@@ -164,7 +165,6 @@ static const char *item_factory_translate_func (const char *path, gpointer func_
gboolean pidgin_conv_has_focus(PurpleConversation *conv);
static GdkColor* generate_nick_colors(guint *numcolors, GdkColor background);
static gboolean color_is_visible(GdkColor foreground, GdkColor background, int color_contrast, int brightness_contrast);
-static GtkTextTag *get_buddy_tag(PurpleConversation *conv, const char *who, PurpleMessageFlags flag, gboolean create);
static void pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields);
static void focus_out_from_menubar(GtkWidget *wid, PidginWindow *win);
static void pidgin_conv_tab_pack(PidginWindow *win, PidginConversation *gtkconv);
@@ -178,7 +178,7 @@ static gboolean pidgin_conv_xy_to_right_infopane(PidginWindow *win, int x, int y
static const GdkColor *get_nick_color(PidginConversation *gtkconv, const char *name)
{
static GdkColor col;
- GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml);
+ GtkStyle *style = gtk_widget_get_style(gtkconv->webview);
float scale;
col = nick_colors[g_str_hash(name) % nbr_nick_colors];
@@ -353,7 +353,7 @@ static void clear_conversation_scrollback(PurpleConversation *conv)
gtkconv = PIDGIN_CONVERSATION(conv);
- gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml));
+ webkit_web_view_load_html_string (WEBKIT_WEB_VIEW (gtkconv->webview), "", "");
for (iter = gtkconv->convs; iter; iter = iter->next)
purple_conversation_clear_message_history(iter->data);
}
@@ -961,32 +961,7 @@ menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget)
static void
savelog_writefile_cb(void *user_data, const char *filename)
{
- PurpleConversation *conv = (PurpleConversation *)user_data;
- FILE *fp;
- const char *name;
- char **lines;
- gchar *text;
-
- if ((fp = g_fopen(filename, "w+")) == NULL) {
- purple_notify_error(PIDGIN_CONVERSATION(conv), NULL, _("Unable to open file."), NULL);
- return;
- }
-
- name = purple_conversation_get_name(conv);
- fprintf(fp, "\n\n");
- fprintf(fp, "\n");
- fprintf(fp, "%s\n\n\n", name);
- fprintf(fp, _("Conversation with %s
\n"), name);
-
- lines = gtk_imhtml_get_markup_lines(
- GTK_IMHTML(PIDGIN_CONVERSATION(conv)->imhtml));
- text = g_strjoinv("
\n", lines);
- fprintf(fp, "%s", text);
- g_free(text);
- g_strfreev(lines);
-
- fprintf(fp, "\n\n\n");
- fclose(fp);
+ /* TODO: I don't know how to support this using webkit yet. */
}
/*
@@ -1116,12 +1091,16 @@ static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s)
if (gtkconv != gtk_active_conv)
{
- gtk_imhtml_search_clear(GTK_IMHTML(gtkconv->imhtml));
+ webkit_web_view_unmark_text_matches (WEBKIT_WEB_VIEW (gtkconv->webview));
}
else
{
- gtk_imhtml_search_find(GTK_IMHTML(gtk_active_conv->imhtml),
- gtk_entry_get_text(GTK_ENTRY(s->entry)));
+ webkit_web_view_mark_text_matches (WEBKIT_WEB_VIEW (gtkconv->webview),
+ gtk_entry_get_text (GTK_ENTRY(s->entry)), TRUE, 0);
+ webkit_web_view_set_highlight_text_matches (WEBKIT_WEB_VIEW (gtkconv->webview),
+ true);
+ webkit_web_view_search_text (WEBKIT_WEB_VIEW (gtkconv->webview),
+ gtk_entry_get_text (GTK_ENTRY(s->entry)), FALSE, TRUE, FALSE);
}
}
break;
@@ -1132,7 +1111,7 @@ static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s)
for (iter = pidgin_conv_window_get_gtkconvs(s->gtkwin); iter; iter=iter->next)
{
PidginConversation *gconv = iter->data;
- gtk_imhtml_search_clear(GTK_IMHTML(gconv->imhtml));
+ webkit_web_view_unmark_text_matches (WEBKIT_WEB_VIEW(gconv->webview));
}
gtk_widget_destroy(s->gtkwin->dialogs.search);
@@ -1635,30 +1614,11 @@ menu_chat_add_remove_cb(GtkWidget *w, PidginConversation *gtkconv)
gtk_widget_grab_focus(PIDGIN_CONVERSATION(conv)->entry);
}
-static GtkTextMark *
-get_mark_for_user(PidginConversation *gtkconv, const char *who)
-{
- GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml));
- char *tmp = g_strconcat("user:", who, NULL);
- GtkTextMark *mark = gtk_text_buffer_get_mark(buf, tmp);
-
- g_free(tmp);
- return mark;
-}
-
static void
menu_last_said_cb(GtkWidget *w, PidginConversation *gtkconv)
{
- GtkTextMark *mark;
- const char *who;
-
- who = g_object_get_data(G_OBJECT(w), "user_data");
- mark = get_mark_for_user(gtkconv, who);
-
- if (mark != NULL)
- gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(gtkconv->imhtml), mark, 0.1, FALSE, 0, 0);
- else
- g_return_if_reached();
+ /* I don't know what this is! */
+ return;
}
static GtkWidget *
@@ -1773,8 +1733,6 @@ create_chat_menu(PurpleConversation *conv, const char *who, PurpleConnection *gc
button = pidgin_new_item_from_stock(menu, _("Last Said"), GTK_STOCK_INDEX,
G_CALLBACK(menu_last_said_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL);
g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
- if (!get_mark_for_user(PIDGIN_CONVERSATION(conv), who))
- gtk_widget_set_sensitive(button, FALSE);
if (buddy != NULL)
{
@@ -1864,10 +1822,10 @@ right_click_chat_cb(GtkWidget *widget, GdkEventButton *event,
chat_do_im(gtkconv, who);
} else if (event->button == 2 && event->type == GDK_BUTTON_PRESS) {
/* Move to user's anchor */
- GtkTextMark *mark = get_mark_for_user(gtkconv, who);
+ //GtkTextMark *mark = get_mark_for_user(gtkconv, who);
- if(mark != NULL)
- gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(gtkconv->imhtml), mark, 0.1, FALSE, 0, 0);
+ //if(mark != NULL)
+ // gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(gtkconv->imhtml), mark, 0.1, FALSE, 0, 0);
} else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) {
GtkWidget *menu = create_chat_menu (conv, who, gc);
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
@@ -1943,8 +1901,8 @@ gtkconv_cycle_focus(PidginConversation *gtkconv, GtkDirectionType dir)
GtkWidget *from;
GtkWidget *to;
} transitions[] = {
- {gtkconv->entry, gtkconv->imhtml},
- {gtkconv->imhtml, chat ? gtkconv->u.chat->list : gtkconv->entry},
+ {gtkconv->entry, gtkconv->webview},
+ {gtkconv->webview, chat ? gtkconv->u.chat->list : gtkconv->entry},
{chat ? gtkconv->u.chat->list : NULL, gtkconv->entry},
{NULL, NULL}
}, *ptr;
@@ -2200,12 +2158,12 @@ entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data)
break;
case GDK_Page_Up:
- gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml));
+ //gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml));
return TRUE;
break;
case GDK_Page_Down:
- gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml));
+ //gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml));
return TRUE;
break;
@@ -2308,7 +2266,7 @@ pidgin_conv_switch_active_conversation(PurpleConversation *conv)
entry = GTK_IMHTML(gtkconv->entry);
protocol_name = purple_account_get_protocol_name(conv->account);
gtk_imhtml_set_protocol_name(entry, protocol_name);
- gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), protocol_name);
+ //gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), protocol_name);
if (!(conv->features & PURPLE_CONNECTION_HTML))
gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry));
@@ -3250,11 +3208,11 @@ populate_menu_with_options(GtkWidget *menu, PidginConversation *gtkconv, gboolea
if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
chat = purple_blist_find_chat(conv->account, conv->name);
- if ((chat == NULL) && (gtkconv->imhtml != NULL)) {
- chat = g_object_get_data(G_OBJECT(gtkconv->imhtml), "transient_chat");
+ if ((chat == NULL) && (gtkconv->webview != NULL)) {
+ chat = g_object_get_data(G_OBJECT(gtkconv->webview), "transient_chat");
}
- if ((chat == NULL) && (gtkconv->imhtml != NULL)) {
+ if ((chat == NULL) && (gtkconv->webview != NULL)) {
GHashTable *components;
PurpleAccount *account = purple_conversation_get_account(conv);
PurplePlugin *prpl = purple_find_prpl(purple_account_get_protocol_id(account));
@@ -3272,7 +3230,7 @@ populate_menu_with_options(GtkWidget *menu, PidginConversation *gtkconv, gboolea
chat = purple_chat_new(conv->account, NULL, components);
purple_blist_node_set_flags((PurpleBlistNode *)chat,
PURPLE_BLIST_NODE_FLAG_NO_SAVE);
- g_object_set_data_full(G_OBJECT(gtkconv->imhtml), "transient_chat",
+ g_object_set_data_full(G_OBJECT(gtkconv->webview), "transient_chat",
chat, (GDestroyNotify)purple_blist_remove_chat);
}
} else {
@@ -3284,15 +3242,15 @@ populate_menu_with_options(GtkWidget *menu, PidginConversation *gtkconv, gboolea
/* gotta remain bug-compatible :( libpurple < 2.0.2 didn't handle
* removing "isolated" buddy nodes well */
if (purple_version_check(2, 0, 2) == NULL) {
- if ((buddy == NULL) && (gtkconv->imhtml != NULL)) {
- buddy = g_object_get_data(G_OBJECT(gtkconv->imhtml), "transient_buddy");
+ if ((buddy == NULL) && (gtkconv->webview != NULL)) {
+ buddy = g_object_get_data(G_OBJECT(gtkconv->webview), "transient_buddy");
}
- if ((buddy == NULL) && (gtkconv->imhtml != NULL)) {
+ if ((buddy == NULL) && (gtkconv->webview != NULL)) {
buddy = purple_buddy_new(conv->account, conv->name, NULL);
purple_blist_node_set_flags((PurpleBlistNode *)buddy,
PURPLE_BLIST_NODE_FLAG_NO_SAVE);
- g_object_set_data_full(G_OBJECT(gtkconv->imhtml), "transient_buddy",
+ g_object_set_data_full(G_OBJECT(gtkconv->webview), "transient_buddy",
buddy, (GDestroyNotify)purple_buddy_destroy);
}
}
@@ -3643,38 +3601,7 @@ typing_animation(gpointer data) {
static void
update_typing_message(PidginConversation *gtkconv, const char *message)
{
- GtkTextBuffer *buffer;
- GtkTextMark *stmark, *enmark;
-
- if (g_object_get_data(G_OBJECT(gtkconv->imhtml), "disable-typing-notification"))
- return;
-
- buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml));
- stmark = gtk_text_buffer_get_mark(buffer, "typing-notification-start");
- enmark = gtk_text_buffer_get_mark(buffer, "typing-notification-end");
- if (stmark && enmark) {
- GtkTextIter start, end;
- gtk_text_buffer_get_iter_at_mark(buffer, &start, stmark);
- gtk_text_buffer_get_iter_at_mark(buffer, &end, enmark);
- gtk_text_buffer_delete_mark(buffer, stmark);
- gtk_text_buffer_delete_mark(buffer, enmark);
- gtk_text_buffer_delete(buffer, &start, &end);
- } else if (message && *message == '\n' && message[1] == ' ' && message[2] == '\0')
- message = NULL;
-
-#ifdef RESERVE_LINE
- if (!message)
- message = "\n "; /* The blank space is required to avoid a GTK+/Pango bug */
-#endif
-
- if (message) {
- GtkTextIter iter;
- gtk_text_buffer_get_end_iter(buffer, &iter);
- gtk_text_buffer_create_mark(buffer, "typing-notification-start", &iter, TRUE);
- gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, message, -1, "TYPING-NOTIFICATION", NULL);
- gtk_text_buffer_get_end_iter(buffer, &iter);
- gtk_text_buffer_create_mark(buffer, "typing-notification-end", &iter, TRUE);
- }
+ /* this is not handled at all */
}
static void
@@ -3991,7 +3918,6 @@ add_chat_buddy_common(PurpleConversation *conv, PurpleConvChatBuddy *cb, const c
gboolean is_buddy;
gchar *tmp, *alias_key, *name, *alias;
int flags;
- GdkColor *color = NULL;
alias = cb->alias;
name = cb->name;
@@ -4018,20 +3944,6 @@ add_chat_buddy_common(PurpleConversation *conv, PurpleConvChatBuddy *cb, const c
alias_key = g_utf8_collate_key(tmp, -1);
g_free(tmp);
- if (is_me) {
- GtkTextTag *tag = gtk_text_tag_table_lookup(
- gtk_text_buffer_get_tag_table(GTK_IMHTML(gtkconv->imhtml)->text_buffer),
- "send-name");
- g_object_get(tag, "foreground-gdk", &color, NULL);
- } else {
- GtkTextTag *tag;
- if ((tag = get_buddy_tag(conv, name, 0, FALSE)))
- g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_NORMAL, NULL);
- if ((tag = get_buddy_tag(conv, name, PURPLE_MESSAGE_NICK, FALSE)))
- g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_NORMAL, NULL);
- color = (GdkColor*)get_nick_color(gtkconv, name);
- }
-
#if GTK_CHECK_VERSION(2,6,0)
gtk_list_store_insert_with_values(ls, &iter,
/*
@@ -4047,7 +3959,6 @@ add_chat_buddy_common(PurpleConversation *conv, PurpleConvChatBuddy *cb, const c
CHAT_USERS_ALIAS_KEY_COLUMN, alias_key,
CHAT_USERS_NAME_COLUMN, name,
CHAT_USERS_FLAGS_COLUMN, flags,
- CHAT_USERS_COLOR_COLUMN, color,
CHAT_USERS_WEIGHT_COLUMN, is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL,
-1);
#else
@@ -4058,13 +3969,10 @@ add_chat_buddy_common(PurpleConversation *conv, PurpleConvChatBuddy *cb, const c
CHAT_USERS_ALIAS_KEY_COLUMN, alias_key,
CHAT_USERS_NAME_COLUMN, name,
CHAT_USERS_FLAGS_COLUMN, flags,
- CHAT_USERS_COLOR_COLUMN, color,
CHAT_USERS_WEIGHT_COLUMN, is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL,
-1);
#endif
- if (is_me && color)
- gdk_color_free(color);
g_free(alias_key);
}
@@ -4458,7 +4366,6 @@ buddy_cb_common(PurpleBuddy *buddy, PurpleConversation *conv, gboolean is_buddy)
GtkTreeModel *model;
char *normalized_name;
GtkTreeIter iter;
- GtkTextTag *texttag;
int f;
g_return_if_fail(buddy != NULL);
@@ -4497,10 +4404,6 @@ buddy_cb_common(PurpleBuddy *buddy, PurpleConversation *conv, gboolean is_buddy)
blist_node_aliased_cb((PurpleBlistNode *)buddy, NULL, conv);
- texttag = get_buddy_tag(conv, purple_buddy_get_name(buddy), 0, FALSE); /* XXX: do we want the normalized name? */
- if (texttag) {
- g_object_set(texttag, "weight", is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, NULL);
- }
}
static void
@@ -4532,7 +4435,7 @@ static void send_menu_cb(GtkWidget *widget, PidginConversation *gtkconv)
}
static void
-entry_popup_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data)
+entry_popup_menu_cb(GtkIMHtml *imhtml /* this is for ->entry, fine! */, GtkMenu *menu, gpointer data)
{
GtkWidget *menuitem;
PidginConversation *gtkconv = data;
@@ -4560,7 +4463,7 @@ static gboolean resize_imhtml_cb(PidginConversation *gtkconv)
GdkRectangle oneline;
int height, diff;
int pad_top, pad_inside, pad_bottom;
- int total_height = (gtkconv->imhtml->allocation.height + gtkconv->entry->allocation.height);
+ int total_height = (gtkconv->webview->allocation.height + gtkconv->entry->allocation.height);
int max_height = total_height / 2;
int min_lines = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines");
int min_height;
@@ -4796,13 +4699,13 @@ pidgin_conv_create_tooltip(GtkWidget *tipwindow, gpointer userdata, int *w, int
if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
node = (PurpleBlistNode*)(purple_blist_find_chat(conv->account, conv->name));
if (!node)
- node = g_object_get_data(G_OBJECT(gtkconv->imhtml), "transient_chat");
+ node = g_object_get_data(G_OBJECT(gtkconv->webview), "transient_chat");
} else {
node = (PurpleBlistNode*)(purple_find_buddy(conv->account, conv->name));
#if 0
/* Using the transient blist nodes to show the tooltip doesn't quite work yet. */
if (!node)
- node = g_object_get_data(G_OBJECT(gtkconv->imhtml), "transient_buddy");
+ node = g_object_get_data(G_OBJECT(gtkconv->webview), "transient_buddy");
#endif
}
@@ -4814,13 +4717,13 @@ pidgin_conv_create_tooltip(GtkWidget *tipwindow, gpointer userdata, int *w, int
static GtkWidget *
setup_common_pane(PidginConversation *gtkconv)
{
- GtkWidget *vbox, *frame, *imhtml_sw, *event_box;
+ GtkWidget *vbox, *frame, *webview_sw, *event_box;
GtkCellRenderer *rend;
GtkTreePath *path;
PurpleConversation *conv = gtkconv->active_conv;
PurpleBuddy *buddy;
gboolean chat = (conv->type == PURPLE_CONV_TYPE_CHAT);
- GtkPolicyType imhtml_sw_hscroll;
+ GtkPolicyType webview_sw_hscroll;
int buddyicon_size = 0;
/* Setup the top part of the pane */
@@ -4916,8 +4819,15 @@ setup_common_pane(PidginConversation *gtkconv)
g_object_set(rend, "xalign", 0.0, "xpad", 6, "ypad", 0, NULL);
/* Setup the gtkimhtml widget */
- frame = pidgin_create_imhtml(FALSE, >kconv->imhtml, NULL, &imhtml_sw);
- gtk_widget_set_size_request(gtkconv->imhtml, -1, 0);
+ webview_sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(webview_sw), GTK_SHADOW_IN);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (webview_sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ gtkconv->webview = gtk_webview_new ();
+ gtk_container_add (GTK_CONTAINER (webview_sw), gtkconv->webview);
+
+ gtk_widget_set_size_request(gtkconv->webview, -1, 0);
+
if (chat) {
GtkWidget *hpaned;
@@ -4928,29 +4838,28 @@ setup_common_pane(PidginConversation *gtkconv)
hpaned = gtk_hpaned_new();
gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0);
gtk_widget_show(hpaned);
- gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE);
+ gtk_paned_pack1(GTK_PANED(hpaned), webview_sw, TRUE, TRUE);
/* Now add the userlist */
setup_chat_userlist(gtkconv, hpaned);
} else {
- gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), webview_sw, TRUE, TRUE, 0);
}
- gtk_widget_show(frame);
+ gtk_widget_show_all(webview_sw);
- gtk_widget_set_name(gtkconv->imhtml, "pidgin_conv_imhtml");
- gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE);
- g_object_set_data(G_OBJECT(gtkconv->imhtml), "gtkconv", gtkconv);
+ gtk_widget_set_name(gtkconv->webview, "pidgin_conv_webview");
+ g_object_set_data(G_OBJECT(gtkconv->webview), "gtkconv", gtkconv);
- gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(imhtml_sw),
- &imhtml_sw_hscroll, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(imhtml_sw),
- imhtml_sw_hscroll, GTK_POLICY_ALWAYS);
+ gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(webview_sw),
+ &webview_sw_hscroll, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(webview_sw),
+ webview_sw_hscroll, GTK_POLICY_ALWAYS);
- g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event",
+ g_signal_connect_after(G_OBJECT(gtkconv->webview), "button_press_event",
G_CALLBACK(entry_stop_rclick_cb), NULL);
- g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event",
+ g_signal_connect(G_OBJECT(gtkconv->webview), "key_press_event",
G_CALLBACK(refocus_entry_cb), gtkconv);
- g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event",
+ g_signal_connect(G_OBJECT(gtkconv->webview), "key_release_event",
G_CALLBACK(refocus_entry_cb), gtkconv);
gtkconv->lower_hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
@@ -5189,36 +5098,6 @@ ignore_middle_click(GtkWidget *widget, GdkEventButton *e, gpointer null)
static void set_typing_font(GtkWidget *widget, GtkStyle *style, PidginConversation *gtkconv)
{
- static PangoFontDescription *font_desc = NULL;
- static GdkColor *color = NULL;
- static gboolean enable = TRUE;
-
- if (font_desc == NULL) {
- char *string = NULL;
- gtk_widget_style_get(widget,
- "typing-notification-font", &string,
- "typing-notification-color", &color,
- "typing-notification-enable", &enable,
- NULL);
- font_desc = pango_font_description_from_string(string);
- g_free(string);
- if (color == NULL) {
- GdkColor def = {0, 0x8888, 0x8888, 0x8888};
- color = gdk_color_copy(&def);
- }
- }
-
- gtk_text_buffer_create_tag(GTK_IMHTML(widget)->text_buffer, "TYPING-NOTIFICATION",
- "foreground-gdk", color,
- "font-desc", font_desc,
- NULL);
-
- if (!enable) {
- g_object_set_data(G_OBJECT(widget), "disable-typing-notification", GINT_TO_POINTER(TRUE));
- /* or may be 'gtkconv->disable_typing = TRUE;' instead? */
- }
-
- g_signal_handlers_disconnect_by_func(G_OBJECT(widget), set_typing_font, gtkconv);
}
/**************************************************************************
@@ -5260,9 +5139,6 @@ private_gtkconv_new(PurpleConversation *conv, gboolean hidden)
}
pane = setup_common_pane(gtkconv);
- gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->imhtml),
- gtk_imhtml_get_format_functions(GTK_IMHTML(gtkconv->imhtml)) | GTK_IMHTML_IMAGE);
-
if (pane == NULL) {
if (conv_type == PURPLE_CONV_TYPE_CHAT)
g_free(gtkconv->u.chat);
@@ -5285,7 +5161,7 @@ private_gtkconv_new(PurpleConversation *conv, gboolean hidden)
GTK_DEST_DEFAULT_DROP,
te, sizeof(te) / sizeof(GtkTargetEntry),
GDK_ACTION_COPY);
- gtk_drag_dest_set(gtkconv->imhtml, 0,
+ gtk_drag_dest_set(gtkconv->webview, 0,
te, sizeof(te) / sizeof(GtkTargetEntry),
GDK_ACTION_COPY);
@@ -5297,12 +5173,12 @@ private_gtkconv_new(PurpleConversation *conv, gboolean hidden)
G_CALLBACK(ignore_middle_click), NULL);
g_signal_connect(G_OBJECT(pane), "drag_data_received",
G_CALLBACK(conv_dnd_recv), gtkconv);
- g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received",
+ g_signal_connect(G_OBJECT(gtkconv->webview), "drag_data_received",
G_CALLBACK(conv_dnd_recv), gtkconv);
g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received",
G_CALLBACK(conv_dnd_recv), gtkconv);
- g_signal_connect(gtkconv->imhtml, "style-set", G_CALLBACK(set_typing_font), gtkconv);
+ g_signal_connect(gtkconv->webview, "style-set", G_CALLBACK(set_typing_font), gtkconv);
/* Setup the container for the tab. */
gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
@@ -5332,10 +5208,6 @@ private_gtkconv_new(PurpleConversation *conv, gboolean hidden)
else
gtk_widget_hide(gtkconv->infopane_hbox);
- gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps"));
- gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml),
- purple_account_get_protocol_name(conv->account));
g_signal_connect_swapped(G_OBJECT(pane), "focus",
G_CALLBACK(gtk_widget_grab_focus),
@@ -5348,7 +5220,7 @@ private_gtkconv_new(PurpleConversation *conv, gboolean hidden)
if (nick_colors == NULL) {
nbr_nick_colors = NUM_NICK_COLORS;
- nick_colors = generate_nick_colors(&nbr_nick_colors, gtk_widget_get_style(gtkconv->imhtml)->base[GTK_STATE_NORMAL]);
+ nick_colors = generate_nick_colors(&nbr_nick_colors, gtk_widget_get_style(gtkconv->webview)->base[GTK_STATE_NORMAL]);
}
if (conv->features & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY)
@@ -5547,43 +5419,6 @@ static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml,
return FALSE;
}
-static GtkTextTag *get_buddy_tag(PurpleConversation *conv, const char *who, PurpleMessageFlags flag,
- gboolean create)
-{
- PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv);
- GtkTextTag *buddytag;
- gchar *str;
- gboolean highlight = (flag & PURPLE_MESSAGE_NICK);
- GtkTextBuffer *buffer = GTK_IMHTML(gtkconv->imhtml)->text_buffer;
-
- str = g_strdup_printf(highlight ? "HILIT %s" : "BUDDY %s", who);
-
- buddytag = gtk_text_tag_table_lookup(
- gtk_text_buffer_get_tag_table(buffer), str);
-
- if (buddytag == NULL && create) {
- if (highlight)
- buddytag = gtk_text_buffer_create_tag(buffer, str,
- "foreground", get_text_tag_color(gtk_text_tag_table_lookup(
- gtk_text_buffer_get_tag_table(buffer), "highlight-name")),
- "weight", PANGO_WEIGHT_BOLD,
- NULL);
- else
- buddytag = gtk_text_buffer_create_tag(
- buffer, str,
- "foreground-gdk", get_nick_color(gtkconv, who),
- "weight", purple_find_buddy(purple_conversation_get_account(conv), who) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL,
- NULL);
-
- g_signal_connect(G_OBJECT(buddytag), "event",
- G_CALLBACK(buddytag_event), conv);
- }
-
- g_free(str);
-
- return buddytag;
-}
-
static void pidgin_conv_calculate_newday(PidginConversation *gtkconv, time_t mtime)
{
struct tm *tm = localtime(&mtime);
@@ -5640,10 +5475,6 @@ pidgin_conv_write_conv(PurpleConversation *conv, const char *name, const char *a
PurpleConnection *gc;
PurpleAccount *account;
PurplePluginProtocolInfo *prpl_info;
- int gtk_font_options = 0;
- int gtk_font_options_all = 0;
- int max_scrollback_lines;
- int line_count;
char buf2[BUF_LONG];
gboolean show_date;
char *mdate;
@@ -5654,8 +5485,6 @@ pidgin_conv_write_conv(PurpleConversation *conv, const char *name, const char *a
PurpleConversationType type;
char *displaying;
gboolean plugin_return;
- char *bracket;
- int tag_count = 0;
gboolean is_rtl_message = FALSE;
g_return_if_fail(conv != NULL);
@@ -5713,59 +5542,13 @@ pidgin_conv_write_conv(PurpleConversation *conv, const char *name, const char *a
}
length = strlen(displaying) + 1;
- /* Awful hack to work around GtkIMHtml's inefficient rendering of messages with lots of formatting changes.
- * If a message has over 100 '<' characters, strip formatting before appending it. Hopefully nobody actually
- * needs that much formatting, anyway.
- */
- for (bracket = strchr(displaying, '<'); bracket && *(bracket + 1); bracket = strchr(bracket + 1, '<'))
- tag_count++;
-
- if (tag_count > 100) {
- char *tmp = displaying;
- displaying = purple_markup_strip_html(tmp);
- g_free(tmp);
- }
win = gtkconv->win;
prpl_info = gc ? PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl) : NULL;
- line_count = gtk_text_buffer_get_line_count(
- gtk_text_view_get_buffer(GTK_TEXT_VIEW(
- gtkconv->imhtml)));
-
- max_scrollback_lines = purple_prefs_get_int(
- PIDGIN_PREFS_ROOT "/conversations/scrollback_lines");
- /* If we're sitting at more than 100 lines more than the
- max scrollback, trim down to max scrollback */
- if (max_scrollback_lines > 0
- && line_count > (max_scrollback_lines + 100)) {
- GtkTextBuffer *text_buffer = gtk_text_view_get_buffer(
- GTK_TEXT_VIEW(gtkconv->imhtml));
- GtkTextIter start, end;
-
- gtk_text_buffer_get_start_iter(text_buffer, &start);
- gtk_text_buffer_get_iter_at_line(text_buffer, &end,
- (line_count - max_scrollback_lines));
- gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end);
- }
-
- if (type == PURPLE_CONV_TYPE_CHAT)
- {
- /* Create anchor for user */
- GtkTextIter iter;
- char *tmp = g_strconcat("user:", name, NULL);
-
- gtk_text_buffer_get_end_iter(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)), &iter);
- gtk_text_buffer_create_mark(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)),
- tmp, &iter, TRUE);
- g_free(tmp);
- }
-
- if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/use_smooth_scrolling"))
- gtk_font_options_all |= GTK_IMHTML_USE_SMOOTHSCROLLING;
-
- if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml))))
- gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "
", gtk_font_options_all | GTK_IMHTML_NO_SCROLL);
+ /* if the buffer is not empty add a
*/
+ if (!gtk_webview_is_empty (GTK_WEBVIEW(gtkconv->webview)))
+ gtk_webview_append_html (GTK_WEBVIEW(gtkconv->webview), "
");
/* First message in a conversation. */
if (gtkconv->newday == 0)
@@ -5801,47 +5584,29 @@ pidgin_conv_write_conv(PurpleConversation *conv, const char *name, const char *a
sml_attrib = g_strdup_printf("sml=\"%s\"", purple_account_get_protocol_name(account));
- gtk_font_options |= GTK_IMHTML_NO_COMMENTS;
-
- if ((flags & PURPLE_MESSAGE_RECV) &&
- !purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting"))
- gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING;
-
- /* this is gonna crash one day, I can feel it. */
- if (PURPLE_PLUGIN_PROTOCOL_INFO(purple_find_prpl(purple_account_get_protocol_id(conv->account)))->options &
- OPT_PROTO_USE_POINTSIZE) {
- gtk_font_options |= GTK_IMHTML_USE_POINTSIZE;
- }
-
- if (!(flags & PURPLE_MESSAGE_RECV) && (conv->features & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY))
- {
- /* We want to see our own smileys. Need to revert it after send*/
- pidgin_themes_smiley_themeize_custom(gtkconv->imhtml);
- }
-
/* TODO: These colors should not be hardcoded so log.c can use them */
if (flags & PURPLE_MESSAGE_RAW) {
- gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, gtk_font_options_all);
+ gtk_webview_append_html (GTK_WEBVIEW(gtkconv->webview), message);
} else if (flags & PURPLE_MESSAGE_SYSTEM) {
g_snprintf(buf2, sizeof(buf2),
- "%s",
+ "%s%s",
sml_attrib ? sml_attrib : "", mdate, displaying);
- gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all);
+ gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), buf2);
} else if (flags & PURPLE_MESSAGE_ERROR) {
g_snprintf(buf2, sizeof(buf2),
- "%s",
+ "%s %s",
sml_attrib ? sml_attrib : "", mdate, displaying);
- gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all);
+ gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), buf2);
} else if (flags & PURPLE_MESSAGE_NO_LOG) {
g_snprintf(buf2, BUF_LONG,
- "%s",
+ "%s",
sml_attrib ? sml_attrib : "", displaying);
- gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all);
+ gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), buf2);
} else {
char *new_message = g_memdup(displaying, length);
char *alias_escaped = (alias ? g_markup_escape_text(alias, strlen(alias)) : g_strdup(""));
@@ -5851,11 +5616,6 @@ pidgin_conv_write_conv(PurpleConversation *conv, const char *name, const char *a
int tag_end_offset = 0;
const char *tagname = NULL;
- GtkTextIter start, end;
- GtkTextMark *mark;
- GtkTextTag *tag;
- GtkTextBuffer *buffer = GTK_IMHTML(gtkconv->imhtml)->text_buffer;
-
/* Enforce direction on alias */
if (is_rtl_message)
str_embed_direction_chars(&alias_escaped);
@@ -5916,55 +5676,27 @@ pidgin_conv_write_conv(PurpleConversation *conv, const char *name, const char *a
g_free(alias_escaped);
- if (tagname)
- tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(buffer), tagname);
- else
- tag = get_buddy_tag(conv, name, flags, TRUE);
-
- if (GTK_IMHTML(gtkconv->imhtml)->show_comments) {
- /* The color for the timestamp has to be set in the font-tags, unfortunately.
- * Applying the nick-tag to timestamps would work, but that can make it
- * bold. I thought applying the "comment" tag again, which has "weight" set
- * to PANGO_WEIGHT_NORMAL, would remove the boldness. But it doesn't. So
- * this will have to do. I don't terribly like it. -- sadrul */
- const char *color = get_text_tag_color(tag);
- g_snprintf(buf2, BUF_LONG, "",
- color ? "COLOR=\"" : "", color ? color : "", color ? "\"" : "", mdate);
- gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all | GTK_IMHTML_NO_SCROLL);
- }
-
- gtk_text_buffer_get_end_iter(buffer, &end);
- mark = gtk_text_buffer_create_mark(buffer, NULL, &end, TRUE);
-
- g_snprintf(buf2, BUF_LONG, "%s ", sml_attrib ? sml_attrib : "", str);
- gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all | GTK_IMHTML_NO_SCROLL);
+ /* timestamp */
+ {
+ g_snprintf (buf2, BUF_LONG, "%s ", mdate);
- gtk_text_buffer_get_end_iter(buffer, &end);
- gtk_text_buffer_get_iter_at_mark(buffer, &start, mark);
- gtk_text_buffer_apply_tag(buffer, tag, &start, &end);
- gtk_text_buffer_delete_mark(buffer, mark);
+ gtk_webview_append_html (GTK_WEBVIEW(gtkconv->webview), buf2);
+ }
+ g_snprintf(buf2, BUF_LONG, "%s ", sml_attrib ? sml_attrib : "", str);
+ gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), buf2);
g_free(str);
if(gc){
char *pre = g_strdup_printf("", sml_attrib ? sml_attrib : "");
char *post = "";
- int pre_len = strlen(pre);
- int post_len = strlen(post);
-
- with_font_tag = g_malloc(length + pre_len + post_len + 1);
-
- strcpy(with_font_tag, pre);
- memcpy(with_font_tag + pre_len, new_message, length);
- strcpy(with_font_tag + pre_len + length, post);
-
- length += pre_len + post_len;
+ with_font_tag = g_strdup_printf ("%s%s%s", pre, new_message, post);
g_free(pre);
} else
with_font_tag = g_memdup(new_message, length);
- gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml),
- with_font_tag, gtk_font_options | gtk_font_options_all);
+ gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview),
+ with_font_tag);
g_free(with_font_tag);
g_free(new_message);
@@ -5991,12 +5723,6 @@ pidgin_conv_write_conv(PurpleConversation *conv, const char *name, const char *a
gtkconv_set_unseen(gtkconv, unseen);
}
- if (!(flags & PURPLE_MESSAGE_RECV) && (conv->features & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY))
- {
- /* Restore the smiley-data */
- pidgin_themes_smiley_themeize(gtkconv->imhtml);
- }
-
purple_signal_emit(pidgin_conversations_get_handle(),
(type == PURPLE_CONV_TYPE_IM ? "displayed-im-msg" : "displayed-chat-msg"),
account, name, displaying, conv, flags);
@@ -6088,10 +5814,6 @@ pidgin_conv_chat_rename_user(PurpleConversation *conv, const char *old_name,
g_free(val);
}
- if ((tag = get_buddy_tag(conv, old_name, 0, FALSE)))
- g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL);
- if ((tag = get_buddy_tag(conv, old_name, PURPLE_MESSAGE_NICK, FALSE)))
- g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL);
if (!purple_conv_chat_find_user(chat, old_name))
return;
@@ -6149,10 +5871,7 @@ pidgin_conv_chat_remove_users(PurpleConversation *conv, GList *users)
g_free(val);
} while (f);
- if ((tag = get_buddy_tag(conv, l->data, 0, FALSE)))
- g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL);
- if ((tag = get_buddy_tag(conv, l->data, PURPLE_MESSAGE_NICK, FALSE)))
- g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL);
+
}
g_snprintf(tmp, sizeof(tmp),
@@ -6256,99 +5975,17 @@ add_custom_smiley_for_imhtml(GtkIMHtml *imhtml, const char *sml, const char *smi
return TRUE;
}
-static gboolean
-pidgin_conv_custom_smiley_add(PurpleConversation *conv, const char *smile, gboolean remote)
-{
- PidginConversation *gtkconv;
- struct smiley_list *list;
- const char *sml = NULL, *conv_sml;
-
- if (!conv || !smile || !*smile) {
- return FALSE;
- }
-
- /* If smileys are off, return false */
- if (pidgin_themes_smileys_disabled())
- return FALSE;
-
- /* If possible add this smiley to the current theme.
- * The addition is only temporary: custom smilies aren't saved to disk. */
- conv_sml = purple_account_get_protocol_name(conv->account);
- gtkconv = PIDGIN_CONVERSATION(conv);
-
- for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) {
- if (!strcmp(list->sml, conv_sml)) {
- sml = list->sml;
- break;
- }
- }
-
- if (!add_custom_smiley_for_imhtml(GTK_IMHTML(gtkconv->imhtml), sml, smile))
- return FALSE;
-
- if (!remote) /* If it's a local custom smiley, then add it for the entry */
- if (!add_custom_smiley_for_imhtml(GTK_IMHTML(gtkconv->entry), sml, smile))
- return FALSE;
-
- return TRUE;
-}
-
static void
pidgin_conv_custom_smiley_write(PurpleConversation *conv, const char *smile,
const guchar *data, gsize size)
{
- PidginConversation *gtkconv;
- GtkIMHtmlSmiley *smiley;
- GdkPixbufLoader *loader;
- const char *sml;
-
- sml = purple_account_get_protocol_name(conv->account);
- gtkconv = PIDGIN_CONVERSATION(conv);
- smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile);
-
- if (!smiley)
- return;
-
- smiley->data = g_realloc(smiley->data, smiley->datasize + size);
- g_memmove((guchar *)smiley->data + smiley->datasize, data, size);
- smiley->datasize += size;
-
- loader = smiley->loader;
- if (!loader)
- return;
-
- gdk_pixbuf_loader_write(loader, data, size, NULL);
+ return;
}
static void
pidgin_conv_custom_smiley_close(PurpleConversation *conv, const char *smile)
{
- PidginConversation *gtkconv;
- GtkIMHtmlSmiley *smiley;
- GdkPixbufLoader *loader;
- const char *sml;
-
- g_return_if_fail(conv != NULL);
- g_return_if_fail(smile != NULL);
-
- sml = purple_account_get_protocol_name(conv->account);
- gtkconv = PIDGIN_CONVERSATION(conv);
- smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile);
-
- if (!smiley)
- return;
-
- loader = smiley->loader;
-
- if (!loader)
- return;
-
-
-
- purple_debug_info("gtkconv", "About to close the smiley pixbuf\n");
-
- gdk_pixbuf_loader_close(loader, NULL);
-
+ return;
}
static void
@@ -6646,8 +6283,6 @@ pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields)
}
}
- if (fields & PIDGIN_CONV_SMILEY_THEME)
- pidgin_themes_smiley_themeize(PIDGIN_CONVERSATION(conv)->imhtml);
if ((fields & PIDGIN_CONV_COLORIZE_TITLE) ||
(fields & PIDGIN_CONV_SET_TITLE) ||
@@ -6872,7 +6507,7 @@ static PurpleConversationUiOps conversation_ui_ops =
pidgin_conv_chat_update_user, /* chat_update_user */
pidgin_conv_present_conversation, /* present */
pidgin_conv_has_focus, /* has_focus */
- pidgin_conv_custom_smiley_add, /* custom_smiley_add */
+ NULL, /* custom_smiley_add */
pidgin_conv_custom_smiley_write, /* custom_smiley_write */
pidgin_conv_custom_smiley_close, /* custom_smiley_close */
pidgin_conv_send_confirm, /* send_confirm */
@@ -7278,8 +6913,6 @@ show_timestamps_pref_cb(const char *name, PurplePrefType type,
GTK_CHECK_MENU_ITEM(win->menu.show_timestamps),
(gboolean)GPOINTER_TO_INT(value));
- gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),
- (gboolean)GPOINTER_TO_INT(value));
}
}
@@ -7674,7 +7307,7 @@ add_message_history_to_gtkconv(gpointer data)
while (gtkconv->attach.current && count < 100) { /* XXX: 100 is a random value here */
PurpleConvMessage *msg = gtkconv->attach.current->data;
if (!im && when && when < msg->when) {
- gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "
", 0);
+ gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), "
");
g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL);
}
pidgin_conv_write_conv(msg->conv, msg->who, msg->alias, msg->what, msg->flags, msg->when);
@@ -7709,7 +7342,7 @@ add_message_history_to_gtkconv(gpointer data)
PurpleConvMessage *msg = msgs->data;
pidgin_conv_write_conv(msg->conv, msg->who, msg->alias, msg->what, msg->flags, msg->when);
}
- gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "
", 0);
+ gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), "
");
g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL);
}
diff --git a/pidgin/gtkconv.h b/pidgin/gtkconv.h
index afe2a21651..c5821e2304 100644
--- a/pidgin/gtkconv.h
+++ b/pidgin/gtkconv.h
@@ -128,7 +128,7 @@ struct _PidginConversation
GtkWidget *tabby;
GtkWidget *menu_tabby;
- GtkWidget *imhtml;
+ GtkWidget *webview;
GtkTextBuffer *entry_buffer;
GtkWidget *entry;
gboolean auto_resize; /* this is set to TRUE if the conversation
diff --git a/pidgin/gtkdialogs.c b/pidgin/gtkdialogs.c
index 429c9fc6bb..16b1058b25 100644
--- a/pidgin/gtkdialogs.c
+++ b/pidgin/gtkdialogs.c
@@ -37,12 +37,13 @@
#include "gtkblist.h"
#include "gtkdialogs.h"
-#include "gtkimhtml.h"
-#include "gtkimhtmltoolbar.h"
#include "gtklog.h"
#include "gtkutils.h"
+#include "gtkwebview.h"
#include "pidginstock.h"
+
+
static GList *dialogwindows = NULL;
static GtkWidget *about = NULL;
@@ -398,10 +399,10 @@ void pidgin_dialogs_about()
{
GtkWidget *vbox;
GtkWidget *logo;
- GtkWidget *frame;
- GtkWidget *text;
+ GtkWidget *scrolled_window;
GtkWidget *button;
- GtkTextIter iter;
+ GtkWidget *web_view;
+
GString *str;
AtkObject *obj;
char* filename, *tmp;
@@ -439,9 +440,14 @@ void pidgin_dialogs_about()
g_free(tmp);
gtk_box_pack_start(GTK_BOX(vbox), logo, FALSE, FALSE, 0);
- frame = pidgin_create_imhtml(FALSE, &text, NULL, NULL);
- gtk_imhtml_set_format_functions(GTK_IMHTML(text), GTK_IMHTML_ALL ^ GTK_IMHTML_SMILEY);
- gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_IN);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ web_view = gtk_webview_new ();
+ gtk_container_add (GTK_CONTAINER (scrolled_window), web_view);
+
+ gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
str = g_string_sized_new(4096);
@@ -682,11 +688,9 @@ if (purple_plugins_find_with_id("core-tcl") != NULL) {
/* End of not to be translated section */
- gtk_imhtml_append_text(GTK_IMHTML(text), str->str, GTK_IMHTML_NO_SCROLL);
+ webkit_web_view_load_html_string (WEBKIT_WEB_VIEW(web_view), str->str, "");
g_string_free(str, TRUE);
- gtk_text_buffer_get_start_iter(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)), &iter);
- gtk_text_buffer_place_cursor(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)), &iter);
/* Close Button */
button = pidgin_dialog_add_button(GTK_DIALOG(about), GTK_STOCK_CLOSE,
diff --git a/pidgin/gtklog.c b/pidgin/gtklog.c
index aed4f054e0..55c1467226 100644
--- a/pidgin/gtklog.c
+++ b/pidgin/gtklog.c
@@ -35,9 +35,9 @@
#include "pidginstock.h"
#include "gtkblist.h"
-#include "gtkimhtml.h"
#include "gtklog.h"
#include "gtkutils.h"
+#include "gtkwebview.h"
static GHashTable *log_viewers = NULL;
static void populate_log_tree(PidginLogViewer *lv);
@@ -130,7 +130,7 @@ static void search_cb(GtkWidget *button, PidginLogViewer *lv)
populate_log_tree(lv);
g_free(lv->search);
lv->search = NULL;
- gtk_imhtml_search_clear(GTK_IMHTML(lv->imhtml));
+ webkit_web_view_unmark_text_matches(WEBKIT_WEB_VIEW(lv->web_view));
select_first_log(lv);
return;
}
@@ -138,7 +138,7 @@ static void search_cb(GtkWidget *button, PidginLogViewer *lv)
if (lv->search != NULL && !strcmp(lv->search, search_term))
{
/* Searching for the same term acts as "Find Next" */
- gtk_imhtml_search_find(GTK_IMHTML(lv->imhtml), lv->search);
+ webkit_web_view_search_text (WEBKIT_WEB_VIEW(lv->web_view), lv->search, FALSE, TRUE, TRUE);
return;
}
@@ -148,7 +148,7 @@ static void search_cb(GtkWidget *button, PidginLogViewer *lv)
lv->search = g_strdup(search_term);
gtk_tree_store_clear(lv->treestore);
- gtk_imhtml_clear(GTK_IMHTML(lv->imhtml));
+ webkit_web_view_open (WEBKIT_WEB_VIEW (lv->web_view), "about:blank"); /* clear the view */
for (logs = lv->logs; logs != NULL; logs = logs->next) {
char *read = purple_log_read((PurpleLog*)logs->data, NULL);
@@ -422,7 +422,9 @@ static gboolean log_popup_menu_cb(GtkWidget *treeview, PidginLogViewer *lv)
static gboolean search_find_cb(gpointer data)
{
PidginLogViewer *viewer = data;
- gtk_imhtml_search_find(GTK_IMHTML(viewer->imhtml), viewer->search);
+ webkit_web_view_mark_text_matches (WEBKIT_WEB_VIEW (viewer->web_view), viewer->search, FALSE, 0);
+ webkit_web_view_set_highlight_text_matches (WEBKIT_WEB_VIEW (viewer->web_view), TRUE);
+ webkit_web_view_search_text (WEBKIT_WEB_VIEW (viewer->web_view), viewer->search, FALSE, TRUE, TRUE);
return FALSE;
}
@@ -463,19 +465,15 @@ static void log_select_cb(GtkTreeSelection *sel, PidginLogViewer *viewer) {
read = purple_log_read(log, &flags);
viewer->flags = flags;
- gtk_imhtml_clear(GTK_IMHTML(viewer->imhtml));
- gtk_imhtml_set_protocol_name(GTK_IMHTML(viewer->imhtml),
- purple_account_get_protocol_name(log->account));
+ webkit_web_view_open (WEBKIT_WEB_VIEW(viewer->web_view), "about:blank");
purple_signal_emit(pidgin_log_get_handle(), "log-displaying", viewer, log);
- gtk_imhtml_append_text(GTK_IMHTML(viewer->imhtml), read,
- GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_TITLE | GTK_IMHTML_NO_SCROLL |
- ((flags & PURPLE_LOG_READ_NO_NEWLINE) ? GTK_IMHTML_NO_NEWLINE : 0));
+ webkit_web_view_load_html_string (WEBKIT_WEB_VIEW(viewer->web_view), read, "");
g_free(read);
if (viewer->search != NULL) {
- gtk_imhtml_search_clear(GTK_IMHTML(viewer->imhtml));
+ webkit_web_view_unmark_text_matches(WEBKIT_WEB_VIEW(viewer->web_view));
g_idle_add(search_find_cb, viewer);
}
@@ -658,11 +656,16 @@ static PidginLogViewer *display_log_viewer(struct log_viewer_hash_t *ht, GList *
gtk_paned_add2(GTK_PANED(pane), vbox);
/* Viewer ************/
- frame = pidgin_create_imhtml(FALSE, &lv->imhtml, NULL, NULL);
- gtk_widget_set_name(lv->imhtml, "pidgin_log_imhtml");
- gtk_widget_set_size_request(lv->imhtml, 320, 200);
- gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
- gtk_widget_show(frame);
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
+
+ lv->web_view = gtk_webview_new ();
+ gtk_container_add (GTK_CONTAINER (sw), lv->web_view);
+ gtk_widget_set_name(lv->web_view, "pidgin_log_web_view");
+ gtk_widget_set_size_request(lv->web_view, 320, 200);
+ gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
+ gtk_widget_show(sw);
/* Search box **********/
hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
diff --git a/pidgin/gtklog.h b/pidgin/gtklog.h
index 77917a8a15..3fd56484b0 100644
--- a/pidgin/gtklog.h
+++ b/pidgin/gtklog.h
@@ -43,7 +43,7 @@ struct _PidginLogViewer {
GtkWidget *window; /**< The viewer's window */
GtkTreeStore *treestore; /**< The treestore containing said logs */
GtkWidget *treeview; /**< The treeview representing said treestore */
- GtkWidget *imhtml; /**< The imhtml to display said logs */
+ GtkWidget *web_view; /**< The webkit web view to display said logs */
GtkWidget *entry; /**< The search entry, in which search terms
* are entered */
PurpleLogReadFlags flags; /**< The most recently used log flags */
diff --git a/pidgin/gtknotify.c b/pidgin/gtknotify.c
index b12669316b..93c8bf2f2a 100644
--- a/pidgin/gtknotify.c
+++ b/pidgin/gtknotify.c
@@ -36,10 +36,10 @@
#include "util.h"
#include "gtkblist.h"
-#include "gtkimhtml.h"
#include "gtknotify.h"
#include "gtkpounce.h"
#include "gtkutils.h"
+#include "gtkwebview.h"
typedef struct
{
@@ -738,21 +738,6 @@ formatted_input_cb(GtkWidget *win, GdkEventKey *event, gpointer data)
return FALSE;
}
-static GtkIMHtmlOptions
-notify_imhtml_options(void)
-{
- GtkIMHtmlOptions options = 0;
-
- if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting"))
- options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES;
-
- options |= GTK_IMHTML_NO_COMMENTS;
- options |= GTK_IMHTML_NO_TITLE;
- options |= GTK_IMHTML_NO_NEWLINE;
- options |= GTK_IMHTML_NO_SCROLL;
- return options;
-}
-
static void *
pidgin_notify_formatted(const char *title, const char *primary,
const char *secondary, const char *text)
@@ -761,8 +746,8 @@ pidgin_notify_formatted(const char *title, const char *primary,
GtkWidget *vbox;
GtkWidget *label;
GtkWidget *button;
- GtkWidget *imhtml;
- GtkWidget *frame;
+ GtkWidget *web_view;
+ GtkWidget *scrolled_window;
char label_text[2048];
char *linked_text, *primary_esc, *secondary_esc;
@@ -797,14 +782,18 @@ pidgin_notify_formatted(const char *title, const char *primary,
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
gtk_widget_show(label);
- /* Add the imhtml */
- frame = pidgin_create_imhtml(FALSE, &imhtml, NULL, NULL);
- gtk_widget_set_name(imhtml, "pidgin_notify_imhtml");
- gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml),
- gtk_imhtml_get_format_functions(GTK_IMHTML(imhtml)) | GTK_IMHTML_IMAGE);
- gtk_widget_set_size_request(imhtml, 300, 250);
- gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
- gtk_widget_show(frame);
+ /* Add the webview */
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_IN);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ web_view = gtk_webview_new ();
+ gtk_container_add (GTK_CONTAINER (scrolled_window), web_view);
+
+ gtk_widget_set_name(web_view, "pidgin_notify_webview");
+ gtk_widget_set_size_request(web_view, 300, 250);
+ gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
+ gtk_widget_show_all(scrolled_window);
/* Add the Close button. */
button = gtk_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
@@ -817,10 +806,10 @@ pidgin_notify_formatted(const char *title, const char *primary,
/* Make sure URLs are clickable */
linked_text = purple_markup_linkify(text);
- gtk_imhtml_append_text(GTK_IMHTML(imhtml), linked_text, notify_imhtml_options());
+ webkit_web_view_load_html_string (WEBKIT_WEB_VIEW (web_view), linked_text, "");
g_free(linked_text);
- g_object_set_data(G_OBJECT(window), "info-widget", imhtml);
+ g_object_set_data(G_OBJECT(window), "webview-widget", web_view);
/* Show the window */
pidgin_auto_parent_window(window);
@@ -1079,10 +1068,11 @@ pidgin_notify_userinfo(PurpleConnection *gc, const char *who,
info = purple_notify_user_info_get_text_with_newline(user_info, "
");
pinfo = g_hash_table_lookup(userinfo, key);
if (pinfo != NULL) {
- GtkIMHtml *imhtml = g_object_get_data(G_OBJECT(pinfo->window), "info-widget");
+ GtkWidget *webview = g_object_get_data(G_OBJECT(pinfo->window), "webview-widget");
char *linked_text = purple_markup_linkify(info);
- gtk_imhtml_clear(imhtml);
- gtk_imhtml_append_text(imhtml, linked_text, notify_imhtml_options());
+ g_assert (webview);
+ printf ("%s\n", linked_text);
+ gtk_webview_load_html_string_with_imgstore (GTK_WEBVIEW (webview), linked_text);
g_free(linked_text);
g_free(key);
ui_handle = pinfo->window;
diff --git a/pidgin/gtkthemes.c b/pidgin/gtkthemes.c
index c194a70ecc..901ef8398d 100644
--- a/pidgin/gtkthemes.c
+++ b/pidgin/gtkthemes.c
@@ -270,6 +270,8 @@ void pidgin_themes_load_smiley_theme(const char *file, gboolean load)
if (*i == '[' && strchr(i, ']') && load) {
struct smiley_list *child = g_new0(struct smiley_list, 1);
child->sml = g_strndup(i+1, strchr(i, ']') - i - 1);
+ child->files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
if (theme->list)
list->next = child;
else
@@ -320,6 +322,7 @@ void pidgin_themes_load_smiley_theme(const char *file, gboolean load)
} else {
GtkIMHtmlSmiley *smiley = gtk_imhtml_smiley_create(sfile, l, hidden, 0);
list->smileys = g_slist_prepend(list->smileys, smiley);
+ g_hash_table_insert (list->files, g_strdup(l), g_strdup(sfile));
}
while (isspace(*i))
i++;
@@ -361,7 +364,6 @@ void pidgin_themes_load_smiley_theme(const char *file, gboolean load)
if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
/* We want to see our custom smileys on our entry if we write the shortcut */
- pidgin_themes_smiley_themeize(PIDGIN_CONVERSATION(conv)->imhtml);
pidgin_themes_smiley_themeize_custom(PIDGIN_CONVERSATION(conv)->entry);
}
}
diff --git a/pidgin/gtkthemes.h b/pidgin/gtkthemes.h
index 138edbbeb0..8cf4b1dff7 100644
--- a/pidgin/gtkthemes.h
+++ b/pidgin/gtkthemes.h
@@ -29,6 +29,7 @@
struct smiley_list {
char *sml;
GSList *smileys;
+ GHashTable *files; /**< map from smiley shortcut to filename */
struct smiley_list *next;
};
diff --git a/pidgin/plugins/Makefile.am b/pidgin/plugins/Makefile.am
index eec8ea2c61..681ee2d2bc 100644
--- a/pidgin/plugins/Makefile.am
+++ b/pidgin/plugins/Makefile.am
@@ -1,4 +1,4 @@
-DIST_SUBDIRS = cap disco gestures gevolution musicmessaging perl ticker
+DIST_SUBDIRS = adiumthemes cap disco gestures gevolution musicmessaging perl ticker
if BUILD_GEVOLUTION
GEVOLUTION_DIR = gevolution
@@ -16,9 +16,6 @@ if USE_PERL
PERL_DIR = perl
endif
-if ENABLE_GESTURES
-GESTURE_DIR = gestures
-endif
SUBDIRS = \
$(CAP_DIR) \
@@ -27,7 +24,8 @@ SUBDIRS = \
$(MUSICMESSAGING_DIR) \
$(PERL_DIR) \
disco \
- ticker
+ ticker \
+ adiumthemes
plugindir = $(libdir)/pidgin
@@ -36,17 +34,12 @@ contact_priority_la_LDFLAGS = -module -avoid-version
extplacement_la_LDFLAGS = -module -avoid-version
gtk_signals_test_la_LDFLAGS = -module -avoid-version
gtkbuddynote_la_LDFLAGS = -module -avoid-version
-history_la_LDFLAGS = -module -avoid-version
iconaway_la_LDFLAGS = -module -avoid-version
-markerline_la_LDFLAGS = -module -avoid-version
-notify_la_LDFLAGS = -module -avoid-version
pidginrc_la_LDFLAGS = -module -avoid-version
relnot_la_LDFLAGS = -module -avoid-version
sendbutton_la_LDFLAGS = -module -avoid-version
spellchk_la_LDFLAGS = -module -avoid-version
themeedit_la_LDFLAGS = -module -avoid-version
-timestamp_la_LDFLAGS = -module -avoid-version
-timestamp_format_la_LDFLAGS = -module -avoid-version
xmppconsole_la_LDFLAGS = -module -avoid-version
if PLUGINS
@@ -55,17 +48,12 @@ plugin_LTLIBRARIES = \
convcolors.la \
extplacement.la \
gtkbuddynote.la \
- history.la \
iconaway.la \
- markerline.la \
- notify.la \
pidginrc.la \
relnot.la \
sendbutton.la \
spellchk.la \
themeedit.la \
- timestamp.la \
- timestamp_format.la \
xmppconsole.la
noinst_LTLIBRARIES = \
@@ -77,35 +65,12 @@ contact_priority_la_SOURCES = contact_priority.c
extplacement_la_SOURCES = extplacement.c
gtk_signals_test_la_SOURCES = gtk-signals-test.c
gtkbuddynote_la_SOURCES = gtkbuddynote.c
-history_la_SOURCES = history.c
iconaway_la_SOURCES = iconaway.c
-markerline_la_SOURCES = markerline.c
-notify_la_SOURCES = notify.c
pidginrc_la_SOURCES = pidginrc.c
relnot_la_SOURCES = relnot.c
sendbutton_la_SOURCES = sendbutton.c
spellchk_la_SOURCES = spellchk.c
themeedit_la_SOURCES = themeedit.c themeedit-icon.c themeedit-icon.h
-timestamp_la_SOURCES = timestamp.c
-timestamp_format_la_SOURCES = timestamp_format.c
-xmppconsole_la_SOURCES = xmppconsole.c
-
-convcolors_la_LIBADD = $(GTK_LIBS)
-contact_priority_la_LIBADD = $(GTK_LIBS)
-extplacement_la_LIBADD = $(GTK_LIBS)
-gtk_signals_test_la_LIBADD = $(GTK_LIBS)
-gtkbuddynote_la_LIBADD = $(GTK_LIBS)
-history_la_LIBADD = $(GTK_LIBS)
-iconaway_la_LIBADD = $(GTK_LIBS)
-markerline_la_LIBADD = $(GTK_LIBS)
-notify_la_LIBADD = $(GTK_LIBS)
-pidginrc_la_LIBADD = $(GTK_LIBS)
-relnot_la_LIBADD = $(GLIB_LIBS)
-sendbutton_la_LIBADD = $(GTK_LIBS)
-spellchk_la_LIBADD = $(GTK_LIBS)
-themeedit_la_LIBADD = $(GTK_LIBS)
-timestamp_la_LIBADD = $(GTK_LIBS)
-timestamp_format_la_LIBADD = $(GTK_LIBS)
xmppconsole_la_LIBADD = $(GTK_LIBS)
endif # PLUGINS
--
cgit v1.2.1
From 3003edd93c1f8cf18dbd920db946b65541367926 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Sun, 26 Jul 2009 06:10:10 +0000
Subject: Start converting Buddy List to new UI Manager code. Some
auto-generated sections are not done yet.
---
pidgin/gtkblist.c | 338 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
pidgin/gtkblist.h | 8 ++
2 files changed, 339 insertions(+), 7 deletions(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index 6aa541e4c8..a6a143604b 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -2057,6 +2057,67 @@ pidgin_blist_popup_menu_cb(GtkWidget *tv, void *user_data)
return handled;
}
+#if GTK_CHECK_VERSION(2,4,0)
+
+static void gtk_blist_show_xfer_dialog_cb(GtkAction *item, gpointer data)
+{
+ pidgin_xfer_dialog_show(NULL);
+}
+
+static void pidgin_blist_buddy_details_cb(GtkToggleAction *item, gpointer data)
+{
+ pidgin_set_cursor(gtkblist->window, GDK_WATCH);
+
+ purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons",
+ gtk_toggle_action_get_active(item));
+
+ pidgin_clear_cursor(gtkblist->window);
+}
+
+static void pidgin_blist_show_idle_time_cb(GtkToggleAction *item, gpointer data)
+{
+ pidgin_set_cursor(gtkblist->window, GDK_WATCH);
+
+ purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_idle_time",
+ gtk_toggle_action_get_active(item));
+
+ pidgin_clear_cursor(gtkblist->window);
+}
+
+static void pidgin_blist_show_protocol_icons_cb(GtkToggleAction *item, gpointer data)
+{
+ purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_protocol_icons",
+ gtk_toggle_action_get_active(item));
+}
+
+static void pidgin_blist_show_empty_groups_cb(GtkToggleAction *item, gpointer data)
+{
+ pidgin_set_cursor(gtkblist->window, GDK_WATCH);
+
+ purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_empty_groups",
+ gtk_toggle_action_get_active(item));
+
+ pidgin_clear_cursor(gtkblist->window);
+}
+
+static void pidgin_blist_edit_mode_cb(GtkToggleAction *checkitem, gpointer data)
+{
+ pidgin_set_cursor(gtkblist->window, GDK_WATCH);
+
+ purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_offline_buddies",
+ gtk_toggle_action_get_active(checkitem));
+
+ pidgin_clear_cursor(gtkblist->window);
+}
+
+static void pidgin_blist_mute_sounds_cb(GtkToggleAction *item, gpointer data)
+{
+ purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/sound/mute",
+ gtk_toggle_action_get_active(item));
+}
+
+#else /* GTK_CHECK_VERSION(2,4,0) */
+
static void pidgin_blist_buddy_details_cb(gpointer data, guint action, GtkWidget *item)
{
pidgin_set_cursor(gtkblist->window, GDK_WATCH);
@@ -2106,15 +2167,23 @@ static void pidgin_blist_edit_mode_cb(gpointer callback_data, guint callback_act
static void pidgin_blist_mute_sounds_cb(gpointer data, guint action, GtkWidget *item)
{
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/sound/mute", GTK_CHECK_MENU_ITEM(item)->active);
+ purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/sound/mute",
+ gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)));
}
+#endif /* GTK_CHECK_VERSION(2,4,0) */
+
static void
pidgin_blist_mute_pref_cb(const char *name, PurplePrefType type,
gconstpointer value, gpointer data)
{
+#if GTK_CHECK_VERSION(2,4,0)
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtk_ui_manager_get_action(gtkblist->ui,
+ "/BList/ToolsMenu/MuteSounds")), (gboolean)GPOINTER_TO_INT(value));
+#else
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(gtkblist->ift,
N_("/Tools/Mute Sounds"))), (gboolean)GPOINTER_TO_INT(value));
+#endif
}
static void
@@ -2126,7 +2195,11 @@ pidgin_blist_sound_method_pref_cb(const char *name, PurplePrefType type,
if(!strcmp(value, "none"))
sensitive = FALSE;
+#if GTK_CHECK_VERSION(2,4,0)
+ gtk_action_set_sensitive(gtk_ui_manager_get_action(gtkblist->ui, "/BList/ToolsMenu/MuteSounds"), sensitive);
+#else
gtk_widget_set_sensitive(gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Mute Sounds")), sensitive);
+#endif
}
static void
@@ -3424,6 +3497,110 @@ toggle_debug(void)
/***************************************************
* Crap *
***************************************************/
+#if GTK_CHECK_VERSION(2,4,0)
+/* TODO: fill out tooltips... */
+static const GtkActionEntry blist_menu_entries[] = {
+ /* Buddies menu */
+ { "BuddiesMenu", NULL, N_("_Buddies"), NULL, NULL, NULL },
+ { "NewInstantMessage", PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW, N_("New Instant _Message..."), "M", NULL, pidgin_dialogs_im },
+ { "JoinAChat", PIDGIN_STOCK_CHAT, N_("Join a _Chat..."), "C", NULL, pidgin_blist_joinchat_show },
+ { "GetUserInfo", PIDGIN_STOCK_TOOLBAR_USER_INFO, N_("Get User _Info..."), "I", NULL, pidgin_dialogs_info },
+ { "ViewUserLog", NULL, N_("View User _Log..."), "L", NULL, pidgin_dialogs_log },
+ { "ShowMenu", NULL, N_("Sh_ow"), NULL, NULL, NULL },
+ { "SortMenu", NULL, N_("_Sort Buddies"), NULL, NULL, NULL },
+ { "AddBuddy", GTK_STOCK_ADD, N_("_Add Buddy..."), "B", NULL, pidgin_blist_add_buddy_cb },
+ { "AddChat", GTK_STOCK_ADD, N_("Add C_hat..."), NULL, NULL, pidgin_blist_add_chat_cb },
+ { "AddGroup", GTK_STOCK_ADD, N_("Add _Group..."), NULL, NULL, purple_blist_request_add_group },
+ { "Quit", GTK_STOCK_QUIT, N_("_Quit"), "Q", NULL, purple_core_quit },
+
+ /* Accounts menu */
+ { "AccountsMenu", NULL, N_("_Accounts"), NULL, NULL, NULL },
+ { "ManageAccounts", NULL, N_("Manage Accounts"), "A", NULL, pidgin_accounts_window_show },
+
+ /* Tools */
+ { "ToolsMenu", NULL, N_("_Tools"), NULL, NULL, NULL },
+ { "BuddyPounces", NULL, N_("Buddy _Pounces"), NULL, NULL, pidgin_pounces_manager_show },
+ { "Certificates", NULL, N_("_Certificates"), NULL, NULL, pidgin_certmgr_show },
+ { "CustomSmileys", PIDGIN_STOCK_TOOLBAR_SMILEY, N_("Custom Smile_ys"), "Y", NULL, pidgin_smiley_manager_show },
+ { "Plugins", PIDGIN_STOCK_TOOLBAR_PLUGINS, N_("Plu_gins"), "U", NULL, pidgin_plugin_dialog_show },
+ { "Preferences", GTK_STOCK_PREFERENCES, N_("Pr_eferences"), "P", NULL, pidgin_prefs_show },
+ { "Privacy", NULL, N_("Pr_ivacy"), NULL, NULL, pidgin_privacy_dialog_show },
+ { "FileTransfers", PIDGIN_STOCK_TOOLBAR_TRANSFER, N_("_File Transfers"), "T", NULL, gtk_blist_show_xfer_dialog_cb },
+ { "RoomList", NULL, N_("R_oom List"), NULL, NULL, pidgin_roomlist_dialog_show },
+ { "SystemLog", NULL, N_("System _Log"), NULL, NULL, gtk_blist_show_systemlog_cb },
+
+ /* Help */
+ { "HelpMenu", NULL, N_("_Help"), NULL, NULL, NULL },
+ { "OnlineHelp", GTK_STOCK_HELP, N_("Online _Help"), "F1", NULL, gtk_blist_show_onlinehelp_cb },
+ { "DebugWindow", NULL, N_("_Debug Window"), NULL, NULL, toggle_debug },
+ { "About", GTK_STOCK_ABOUT, N_("_About"), NULL, NULL, pidgin_dialogs_about },
+};
+
+/* Toggle items */
+static const GtkToggleActionEntry blist_menu_toggle_entries[] = {
+ /* Buddies->Show menu */
+ { "ShowOffline", NULL, N_("_Offline Buddies"), NULL, NULL, pidgin_blist_edit_mode_cb, FALSE },
+ { "ShowEmptyGroups", NULL, N_("_Empty Groups"), NULL, NULL, pidgin_blist_show_empty_groups_cb, FALSE },
+ { "ShowBuddyDetails", NULL, N_("Buddy _Details"), NULL, NULL, pidgin_blist_buddy_details_cb, FALSE },
+ { "ShowIdleTimes", NULL, N_("Idle _Times"), NULL, NULL, pidgin_blist_show_idle_time_cb, FALSE },
+ { "ShowProtocolIcons", NULL, N_("_Protocol Icons"), NULL, NULL, pidgin_blist_show_protocol_icons_cb, FALSE },
+
+ /* Tools menu */
+ { "MuteSounds", NULL, N_("Mute _Sounds"), NULL, NULL, pidgin_blist_mute_sounds_cb, FALSE },
+};
+
+static const char *blist_menu =
+""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+"";
+
+#else
static GtkItemFactoryEntry blist_menu[] =
{
/* Buddies menu */
@@ -3469,12 +3646,9 @@ static GtkItemFactoryEntry blist_menu[] =
{ N_("/_Help"), NULL, NULL, 0, "", NULL },
{ N_("/Help/Online _Help"), "F1", gtk_blist_show_onlinehelp_cb, 0, "", GTK_STOCK_HELP },
{ N_("/Help/_Debug Window"), NULL, toggle_debug, 0, "- ", NULL },
-#if GTK_CHECK_VERSION(2,6,0)
- { N_("/Help/_About"), NULL, pidgin_dialogs_about, 4, "", GTK_STOCK_ABOUT },
-#else
{ N_("/Help/_About"), NULL, pidgin_dialogs_about, 4, "
- ", NULL },
-#endif
};
+#endif
/*********************************************************
* Private Utility functions *
@@ -4299,12 +4473,21 @@ static void pidgin_blist_hide_node(PurpleBuddyList *list, PurpleBlistNode *node,
static const char *require_connection[] =
{
+#if GTK_CHECK_VERSION(2,4,0)
+ "/BList/BuddiesMenu/NewInstantMessage",
+ "/BList/BuddiesMenu/JoinAChat",
+ "/BList/BuddiesMenu/GetUserInfo",
+ "/BList/BuddiesMenu/AddBuddy",
+ "/BList/BuddiesMenu/AddChat",
+ "/BList/BuddiesMenu/AddGroup",
+#else
N_("/Buddies/New Instant Message..."),
N_("/Buddies/Join a Chat..."),
N_("/Buddies/Get User Info..."),
N_("/Buddies/Add Buddy..."),
N_("/Buddies/Add Chat..."),
N_("/Buddies/Add Group..."),
+#endif
};
static const int require_connection_size = sizeof(require_connection)
@@ -4317,7 +4500,11 @@ static const int require_connection_size = sizeof(require_connection)
static void
update_menu_bar(PidginBuddyList *gtkblist)
{
+#if GTK_CHECK_VERSION(2,4,0)
+ GtkAction *action;
+#else
GtkWidget *widget;
+#endif
gboolean sensitive;
int i;
@@ -4327,6 +4514,25 @@ update_menu_bar(PidginBuddyList *gtkblist)
sensitive = (purple_connections_get_all() != NULL);
+#if GTK_CHECK_VERSION(2,4,0)
+ for (i = 0; i < require_connection_size; i++)
+ {
+ action = gtk_ui_manager_get_action(gtkblist->ui, require_connection[i]);
+ gtk_action_set_sensitive(action, sensitive);
+ }
+
+ action = gtk_ui_manager_get_action(gtkblist->ui, "/BList/BuddiesMenu/JoinAChat");
+ gtk_action_set_sensitive(action, pidgin_blist_joinchat_is_showable());
+
+ action = gtk_ui_manager_get_action(gtkblist->ui, "/BList/BuddiesMenu/AddChat");
+ gtk_action_set_sensitive(action, pidgin_blist_joinchat_is_showable());
+
+ action = gtk_ui_manager_get_action(gtkblist->ui, "/BList/ToolsMenu/Privacy");
+ gtk_action_set_sensitive(action, sensitive);
+
+ action = gtk_ui_manager_get_action(gtkblist->ui, "/BList/ToolsMenu/RoomList");
+ gtk_action_set_sensitive(action, pidgin_roomlist_is_showable());
+#else
for (i = 0; i < require_connection_size; i++)
{
widget = gtk_item_factory_get_widget(gtkblist->ift, require_connection[i]);
@@ -4344,6 +4550,7 @@ update_menu_bar(PidginBuddyList *gtkblist)
widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Room List"));
gtk_widget_set_sensitive(widget, pidgin_roomlist_is_showable());
+#endif
}
static void
@@ -4634,11 +4841,13 @@ enum {
NUM_TARGETS
};
+#if !GTK_CHECK_VERSION(2,4,0)
static const char *
item_factory_translate_func (const char *path, gpointer func_data)
{
return _((char *)path);
}
+#endif
void pidgin_blist_setup_sort_methods()
{
@@ -5623,6 +5832,10 @@ static void pidgin_blist_show(PurpleBuddyList *list)
GtkWidget *label;
char *pretty, *tmp;
const char *theme_name;
+#if GTK_CHECK_VERSION(2,4,0)
+ GtkActionGroup *action_group;
+ GError *error;
+#endif
GtkAccelGroup *accel_group;
GtkTreeSelection *selection;
GtkTargetEntry dte[] = {{"PURPLE_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW},
@@ -5672,6 +5885,44 @@ static void pidgin_blist_show(PurpleBuddyList *list)
gtk_widget_add_events(gtkblist->window, GDK_VISIBILITY_NOTIFY_MASK);
/******************************* Menu bar *************************************/
+#if GTK_CHECK_VERSION(2,4,0)
+ action_group = gtk_action_group_new("BListActions");
+ gtk_action_group_add_actions(action_group,
+ blist_menu_entries,
+ G_N_ELEMENTS(blist_menu_entries),
+ GTK_WINDOW(gtkblist->window));
+ gtk_action_group_add_toggle_actions(action_group,
+ blist_menu_toggle_entries,
+ G_N_ELEMENTS(blist_menu_toggle_entries),
+ GTK_WINDOW(gtkblist->window));
+#ifdef ENABLE_NLS
+ gtk_action_group_set_translation_domain(action_group,
+ PACKAGE);
+#endif
+
+ gtkblist->ui = gtk_ui_manager_new();
+ gtk_ui_manager_insert_action_group(gtkblist->ui, action_group, 0);
+
+ accel_group = gtk_ui_manager_get_accel_group(gtkblist->ui);
+ gtk_window_add_accel_group(GTK_WINDOW(gtkblist->window), accel_group);
+
+ error = NULL;
+ if (!gtk_ui_manager_add_ui_from_string(gtkblist->ui, blist_menu, -1, &error))
+ {
+ g_message("building menus failed: %s", error->message);
+ g_error_free(error);
+ exit(EXIT_FAILURE);
+ }
+
+ menu = gtk_ui_manager_get_widget(gtkblist->ui, "/BList");
+ gtkblist->menutray = pidgin_menu_tray_new();
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtkblist->menutray);
+ gtk_widget_show(gtkblist->menutray);
+ gtk_widget_show(menu);
+ gtk_box_pack_start(GTK_BOX(gtkblist->main_vbox), menu, FALSE, FALSE, 0);
+
+ accountmenu = gtk_ui_manager_get_widget(gtkblist->ui, "/BList/AccountsMenu");
+#else
accel_group = gtk_accel_group_new();
gtk_window_add_accel_group(GTK_WINDOW (gtkblist->window), accel_group);
g_object_unref(accel_group);
@@ -5679,7 +5930,7 @@ static void pidgin_blist_show(PurpleBuddyList *list)
gtk_item_factory_set_translate_func(gtkblist->ift,
(GtkTranslateFunc)item_factory_translate_func,
NULL, NULL);
- gtk_item_factory_create_items(gtkblist->ift, sizeof(blist_menu) / sizeof(*blist_menu),
+ gtk_item_factory_create_items(gtkblist->ift, G_N_ENTRIES(blist_menu),
blist_menu, NULL);
pidgin_load_accels();
g_signal_connect(G_OBJECT(accel_group), "accel-changed", G_CALLBACK(pidgin_save_accels_cb), NULL);
@@ -5692,7 +5943,7 @@ static void pidgin_blist_show(PurpleBuddyList *list)
gtk_box_pack_start(GTK_BOX(gtkblist->main_vbox), menu, FALSE, FALSE, 0);
accountmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Accounts"));
-
+#endif
/****************************** Notebook *************************************/
gtkblist->notebook = gtk_notebook_new();
@@ -5881,6 +6132,30 @@ static void pidgin_blist_show(PurpleBuddyList *list)
/* set the Show Offline Buddies option. must be done
* after the treeview or faceprint gets mad. -Robot101
*/
+#if GTK_CHECK_VERSION(2,4,0)
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtk_ui_manager_get_action(gtkblist->ui, "/BList/BuddiesMenu/ShowMenu/ShowOffline")),
+ purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_offline_buddies"));
+
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtk_ui_manager_get_action(gtkblist->ui, "/BList/BuddiesMenu/ShowMenu/ShowEmptyGroups")),
+ purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_empty_groups"));
+
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtk_ui_manager_get_action(gtkblist->ui, "/BList/ToolsMenu/MuteSounds")),
+ purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/sound/mute"));
+
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtk_ui_manager_get_action(gtkblist->ui, "/BList/BuddiesMenu/ShowMenu/ShowBuddyDetails")),
+ purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons"));
+
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtk_ui_manager_get_action(gtkblist->ui, "/BList/BuddiesMenu/ShowMenu/ShowIdleTimes")),
+ purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_idle_time"));
+
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtk_ui_manager_get_action(gtkblist->ui, "/BList/BuddiesMenu/ShowMenu/ShowProtocolIcons")),
+ purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_protocol_icons"));
+
+ if(!strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"), "none"))
+ gtk_action_set_sensitive(gtk_ui_manager_get_action(gtkblist->ui, "/BList/ToolsMenu/MuteSounds"), FALSE);
+
+#else
+
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show/Offline Buddies"))),
purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_offline_buddies"));
@@ -5901,6 +6176,7 @@ static void pidgin_blist_show(PurpleBuddyList *list)
if(!strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"), "none"))
gtk_widget_set_sensitive(gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Mute Sounds")), FALSE);
+#endif
/* Update some dynamic things */
update_menu_bar(gtkblist);
@@ -6777,7 +7053,11 @@ static void pidgin_blist_destroy(PurpleBuddyList *list)
gtkblist->window = gtkblist->vbox = gtkblist->treeview = NULL;
g_object_unref(G_OBJECT(gtkblist->treemodel));
gtkblist->treemodel = NULL;
+#if GTK_CHECK_VERSION(2,4,0)
+ g_object_unref(G_OBJECT(gtkblist->ui));
+#else
g_object_unref(G_OBJECT(gtkblist->ift));
+#endif
g_object_unref(G_OBJECT(gtkblist->empty_avatar));
gdk_cursor_unref(gtkblist->hand_cursor);
@@ -7868,6 +8148,9 @@ pidgin_blist_update_accounts_menu(void)
if (accountmenu == NULL)
return;
+#if GTK_CHECK_VERSION(2,4,0)
+/* TODO: Update Accounts... */
+#else
/* Clear the old Accounts menu */
for (l = gtk_container_get_children(GTK_CONTAINER(accountmenu)); l; l = g_list_delete_link(l, l)) {
menuitem = l->data;
@@ -7990,6 +8273,7 @@ pidgin_blist_update_accounts_menu(void)
gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem);
}
gtk_widget_show_all(accountmenu);
+#endif
}
static GList *plugin_submenus = NULL;
@@ -8002,6 +8286,9 @@ pidgin_blist_update_plugin_actions(void)
GList *l;
GtkAccelGroup *accel_group;
+#if GTK_CHECK_VERSION(2,4,0)
+/* TODO: Update Plugin */
+#else
GtkWidget *pluginmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools"));
g_return_if_fail(pluginmenu != NULL);
@@ -8042,6 +8329,7 @@ pidgin_blist_update_plugin_actions(void)
build_plugin_actions(submenu, plugin, NULL);
}
gtk_widget_show_all(pluginmenu);
+#endif
}
static void
@@ -8068,6 +8356,41 @@ pidgin_blist_update_sort_methods(void)
GtkWidget *sortmenu;
const char *m = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/blist/sort_type");
+#if GTK_CHECK_VERSION(2,4,0)
+ GtkActionGroup *sort_group;
+ GtkAction *activeaction = NULL;
+ GtkAction *action;
+ GString *ui_string;
+
+ if ((gtkblist == NULL) || (gtkblist->ui == NULL))
+ return;
+
+ /* Clear the old menu */
+ gtk_ui_manager_remove_ui(gtkblist->ui, gtkblist->sort_methods_merge_id);
+
+ sort_group = gtk_action_group_new("SortMethods");
+ ui_string = g_string_new("");
+ for (l = pidgin_blist_sort_methods; l; l = l->next) {
+ method = (PidginBlistSortMethod *)l->data;
+ action = gtk_radio_action_new(method->id,
+ _(method->name),
+ NULL,
+ NULL,
+ 0);
+ gtk_action_group_add_action_with_accel(sort_group, action, NULL);
+ if (!strcmp(m, method->id))
+ activeaction = action;
+ g_signal_connect(G_OBJECT(action), "activate",
+ G_CALLBACK(sortmethod_act), method->id);
+ g_string_append_printf(ui_string, "", method->id);
+ }
+ g_string_append(ui_string, "");
+ purple_debug_info("BList", "BList sort is %s\n", ui_string->str);
+ gtkblist->sort_methods_merge_id = gtk_ui_manager_add_ui_from_string(gtkblist->ui, ui_string->str, -1, NULL);
+ gtk_ui_manager_insert_action_group(gtkblist->ui, sort_group, 1);
+ if (activeaction)
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(activeaction), TRUE);
+#else
if ((gtkblist == NULL) || (gtkblist->ift == NULL))
return;
@@ -8097,4 +8420,5 @@ pidgin_blist_update_sort_methods(void)
}
if (activeitem)
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(activeitem), TRUE);
+#endif
}
diff --git a/pidgin/gtkblist.h b/pidgin/gtkblist.h
index bda0ef77d8..4c65deec21 100644
--- a/pidgin/gtkblist.h
+++ b/pidgin/gtkblist.h
@@ -82,7 +82,15 @@ struct _PidginBuddyList {
GtkCellRenderer *text_rend;
+#if GTK_CHECK_VERSION(2,4,0)
+ GtkUIManager *ui;
+ /* Hmm, can I put these here? */
+ guint plugins_merge_id;
+ guint accounts_merge_id;
+ guint sort_methods_merge_id;
+#else
GtkItemFactory *ift;
+#endif
GtkWidget *menutray; /**< The menu tray widget. */
GtkWidget *menutrayicon; /**< The menu tray icon. */
--
cgit v1.2.1
From 36b4ce68ed9c82975f698022032500e6c8477020 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 28 Jul 2009 00:50:25 +0000
Subject: Move some UI manager stuff out of the blist structure and into the
source as static variables. At the structure keeps the same size this way.
---
pidgin/gtkblist.c | 19 ++++++++++++++++---
pidgin/gtkblist.h | 4 ----
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index a6a143604b..8d018f5716 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -126,6 +126,10 @@ typedef struct
#define PIDGIN_BUDDY_LIST_GET_PRIVATE(list) \
((PidginBuddyListPrivate *)((list)->priv))
+#if GTK_CHECK_VERSION(2,4,0)
+static guint accounts_merge_id;
+static GtkActionGroup *accounts_action_group = NULL;
+#endif
static GtkWidget *accountmenu = NULL;
static guint visibility_manager_count = 0;
@@ -136,7 +140,6 @@ static gboolean editing_blist = FALSE;
static GList *pidgin_blist_sort_methods = NULL;
static struct pidgin_blist_sort_method *current_sort_method = NULL;
static void sort_method_none(PurpleBlistNode *node, PurpleBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter);
-
/* The functions we use for sorting aren't available in gtk 2.0.x, and
* segfault in 2.2.0. 2.2.1 is known to work, so I'll require that */
#if GTK_CHECK_VERSION(2,2,1)
@@ -144,6 +147,11 @@ static void sort_method_alphabetical(PurpleBlistNode *node, PurpleBuddyList *bli
static void sort_method_status(PurpleBlistNode *node, PurpleBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter);
static void sort_method_log_activity(PurpleBlistNode *node, PurpleBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter);
#endif
+#if GTK_CHECK_VERSION(2,4,0)
+static guint sort_merge_id;
+static GtkActionGroup *sort_action_group = NULL;
+#endif
+
static PidginBuddyList *gtkblist = NULL;
static GList *groups_tree(void);
@@ -8276,7 +8284,12 @@ pidgin_blist_update_accounts_menu(void)
#endif
}
+#if GTK_CHECK_VERSION(2,4,0)
+static guint plugins_merge_id;
+static GtkActionGroup *plugins_action_group = NULL;
+#else
static GList *plugin_submenus = NULL;
+#endif
void
pidgin_blist_update_plugin_actions(void)
@@ -8366,7 +8379,7 @@ pidgin_blist_update_sort_methods(void)
return;
/* Clear the old menu */
- gtk_ui_manager_remove_ui(gtkblist->ui, gtkblist->sort_methods_merge_id);
+ gtk_ui_manager_remove_ui(gtkblist->ui, sort_merge_id);
sort_group = gtk_action_group_new("SortMethods");
ui_string = g_string_new("");
@@ -8386,7 +8399,7 @@ pidgin_blist_update_sort_methods(void)
}
g_string_append(ui_string, "");
purple_debug_info("BList", "BList sort is %s\n", ui_string->str);
- gtkblist->sort_methods_merge_id = gtk_ui_manager_add_ui_from_string(gtkblist->ui, ui_string->str, -1, NULL);
+ sort_merge_id = gtk_ui_manager_add_ui_from_string(gtkblist->ui, ui_string->str, -1, NULL);
gtk_ui_manager_insert_action_group(gtkblist->ui, sort_group, 1);
if (activeaction)
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(activeaction), TRUE);
diff --git a/pidgin/gtkblist.h b/pidgin/gtkblist.h
index 4c65deec21..0c5b0ad723 100644
--- a/pidgin/gtkblist.h
+++ b/pidgin/gtkblist.h
@@ -84,10 +84,6 @@ struct _PidginBuddyList {
#if GTK_CHECK_VERSION(2,4,0)
GtkUIManager *ui;
- /* Hmm, can I put these here? */
- guint plugins_merge_id;
- guint accounts_merge_id;
- guint sort_methods_merge_id;
#else
GtkItemFactory *ift;
#endif
--
cgit v1.2.1
From df7da708b0afc1cd3dc54f36ce653500b4d1dc05 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 28 Jul 2009 00:53:15 +0000
Subject: Get BList sort methods actually working, and clean up the warnings
that were caused by those code changes.
---
pidgin/gtkblist.c | 67 +++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 48 insertions(+), 19 deletions(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index 8d018f5716..f5d4d1a80f 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -3573,7 +3573,7 @@ static const char *blist_menu =
""
""
""
- ""
+ ""
""
""
""
@@ -8345,6 +8345,21 @@ pidgin_blist_update_plugin_actions(void)
#endif
}
+#if GTK_CHECK_VERSION(2,4,0)
+static void
+sortmethod_act(GtkRadioAction *action, GtkRadioAction *current, char *id)
+{
+ if (action == current)
+ {
+ pidgin_set_cursor(gtkblist->window, GDK_WATCH);
+ /* This is redundant. I think. */
+ /* pidgin_blist_sort_method_set(id); */
+ purple_prefs_set_string(PIDGIN_PREFS_ROOT "/blist/sort_type", id);
+
+ pidgin_clear_cursor(gtkblist->window);
+ }
+}
+#else
static void
sortmethod_act(GtkCheckMenuItem *checkmenuitem, char *id)
{
@@ -8358,21 +8373,18 @@ sortmethod_act(GtkCheckMenuItem *checkmenuitem, char *id)
pidgin_clear_cursor(gtkblist->window);
}
}
+#endif
void
pidgin_blist_update_sort_methods(void)
{
- GtkWidget *menuitem = NULL, *activeitem = NULL;
PidginBlistSortMethod *method = NULL;
GList *l;
GSList *sl = NULL;
- GtkWidget *sortmenu;
const char *m = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/blist/sort_type");
#if GTK_CHECK_VERSION(2,4,0)
- GtkActionGroup *sort_group;
- GtkAction *activeaction = NULL;
- GtkAction *action;
+ GtkRadioAction *action;
GString *ui_string;
if ((gtkblist == NULL) || (gtkblist->ui == NULL))
@@ -8380,30 +8392,47 @@ pidgin_blist_update_sort_methods(void)
/* Clear the old menu */
gtk_ui_manager_remove_ui(gtkblist->ui, sort_merge_id);
+ gtk_ui_manager_remove_action_group(gtkblist->ui, sort_action_group);
+
+ sort_action_group = gtk_action_group_new("SortMethods");
+#ifdef ENABLE_NLS
+ gtk_action_group_set_translation_domain(sort_action_group, PACKAGE);
+#endif
+ ui_string = g_string_new(""
+ "");
- sort_group = gtk_action_group_new("SortMethods");
- ui_string = g_string_new("");
for (l = pidgin_blist_sort_methods; l; l = l->next) {
method = (PidginBlistSortMethod *)l->data;
+
+ g_string_append_printf(ui_string, "", method->id);
action = gtk_radio_action_new(method->id,
- _(method->name),
+ method->name,
NULL,
NULL,
0);
- gtk_action_group_add_action_with_accel(sort_group, action, NULL);
+ gtk_action_group_add_action_with_accel(sort_action_group, GTK_ACTION(action), NULL);
+
+ gtk_radio_action_set_group(action, sl);
+ sl = gtk_radio_action_get_group(action);
+
if (!strcmp(m, method->id))
- activeaction = action;
- g_signal_connect(G_OBJECT(action), "activate",
- G_CALLBACK(sortmethod_act), method->id);
- g_string_append_printf(ui_string, "", method->id);
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE);
+ else
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), FALSE);
+
+ g_signal_connect(G_OBJECT(action), "changed",
+ G_CALLBACK(sortmethod_act), method->id);
}
- g_string_append(ui_string, "");
- purple_debug_info("BList", "BList sort is %s\n", ui_string->str);
+
+ g_string_append(ui_string, "");
+ gtk_ui_manager_insert_action_group(gtkblist->ui, sort_action_group, 1);
sort_merge_id = gtk_ui_manager_add_ui_from_string(gtkblist->ui, ui_string->str, -1, NULL);
- gtk_ui_manager_insert_action_group(gtkblist->ui, sort_group, 1);
- if (activeaction)
- gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(activeaction), TRUE);
+
+ g_string_free(ui_string, TRUE);
#else
+ GtkWidget *menuitem = NULL, *activeitem = NULL;
+ GtkWidget *sortmenu;
+
if ((gtkblist == NULL) || (gtkblist->ift == NULL))
return;
--
cgit v1.2.1
From f35cc8e04f71c17e6d773333d00ecd0844110434 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 28 Jul 2009 01:33:55 +0000
Subject: Sort of get the accounts menu working again. Except UI manager
insists on adding mnemonics, and merging seems to unwind the order of the
menus.
---
pidgin/gtkblist.c | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 149 insertions(+), 7 deletions(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index f5d4d1a80f..df0bfbba40 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -129,8 +129,9 @@ typedef struct
#if GTK_CHECK_VERSION(2,4,0)
static guint accounts_merge_id;
static GtkActionGroup *accounts_action_group = NULL;
-#endif
+#else
static GtkWidget *accountmenu = NULL;
+#endif
static guint visibility_manager_count = 0;
static GdkVisibilityState gtk_blist_visibility = GDK_VISIBILITY_UNOBSCURED;
@@ -3524,6 +3525,7 @@ static const GtkActionEntry blist_menu_entries[] = {
/* Accounts menu */
{ "AccountsMenu", NULL, N_("_Accounts"), NULL, NULL, NULL },
{ "ManageAccounts", NULL, N_("Manage Accounts"), "A", NULL, pidgin_accounts_window_show },
+ { "EnableAccountMenu", NULL, N_("Enable Account"), NULL, NULL, NULL },
/* Tools */
{ "ToolsMenu", NULL, N_("_Tools"), NULL, NULL, NULL },
@@ -3583,6 +3585,8 @@ static const char *blist_menu =
""
""
""
+ ""
+ ""
""
""
""
@@ -5928,8 +5932,6 @@ static void pidgin_blist_show(PurpleBuddyList *list)
gtk_widget_show(gtkblist->menutray);
gtk_widget_show(menu);
gtk_box_pack_start(GTK_BOX(gtkblist->main_vbox), menu, FALSE, FALSE, 0);
-
- accountmenu = gtk_ui_manager_get_widget(gtkblist->ui, "/BList/AccountsMenu");
#else
accel_group = gtk_accel_group_new();
gtk_window_add_accel_group(GTK_WINDOW (gtkblist->window), accel_group);
@@ -7079,7 +7081,9 @@ static void pidgin_blist_destroy(PurpleBuddyList *list)
g_free(priv);
g_free(gtkblist);
+#if !GTK_CHECK_VERSION(2,4,0)
accountmenu = NULL;
+#endif
gtkblist = NULL;
purple_prefs_disconnect_by_handle(pidgin_blist_get_handle());
}
@@ -8083,6 +8087,45 @@ plugin_act(GtkObject *obj, PurplePluginAction *pam)
pam->callback(pam);
}
+#if GTK_CHECK_VERSION(2,4,0)
+static void
+build_plugin_actions(GtkActionGroup *action_group, GString *ui, int parent,
+ PurplePlugin *plugin, gpointer context)
+{
+ GtkAction *menuaction;
+ PurplePluginAction *action = NULL;
+ GList *actions, *l;
+ char *name;
+ int count = 0;
+
+ actions = PURPLE_PLUGIN_ACTIONS(plugin, context);
+
+ for (l = actions; l != NULL; l = l->next) {
+ if (l->data) {
+ action = (PurplePluginAction *)l->data;
+ action->plugin = plugin;
+ action->context = context;
+
+ name = g_strdup_printf("plugin-%d-action-%d", parent, count++);
+ menuaction = gtk_action_new(name, action->label, NULL, NULL);
+ gtk_action_group_add_action(action_group, menuaction);
+ g_string_append_printf(ui, "", name);
+
+ g_signal_connect(G_OBJECT(menuaction), "activate",
+ G_CALLBACK(plugin_act), action);
+ g_object_set_data_full(G_OBJECT(menuaction), "plugin_action",
+ action,
+ (GDestroyNotify)purple_plugin_action_free);
+ g_free(name);
+ }
+ else
+ g_string_append(ui, "");
+ }
+
+ g_list_free(actions);
+}
+
+#else
static void
build_plugin_actions(GtkWidget *menu, PurplePlugin *plugin,
gpointer context)
@@ -8117,6 +8160,7 @@ build_plugin_actions(GtkWidget *menu, PurplePlugin *plugin,
g_list_free(actions);
}
+#endif
static void
modify_account_cb(GtkWidget *widget, gpointer data)
@@ -8147,18 +8191,116 @@ disable_account_cb(GtkCheckMenuItem *widget, gpointer data)
void
pidgin_blist_update_accounts_menu(void)
{
+ GList *accounts = NULL;
+
+#if GTK_CHECK_VERSION(2,4,0)
+ GtkAction *action;
+ GString *accounts_ui;
+ GString *enable_ui;
+ gchar *ui_string;
+ int count = 0;
+
+ if ((gtkblist == NULL) || (gtkblist->ui == NULL))
+ return;
+
+ /* Clear the old menu */
+ gtk_ui_manager_remove_ui(gtkblist->ui, accounts_merge_id);
+ gtk_ui_manager_remove_action_group(gtkblist->ui, accounts_action_group);
+ g_object_unref(G_OBJECT(accounts_action_group));
+
+ accounts_action_group = gtk_action_group_new("Accounts");
+#ifdef ENABLE_NLS
+ gtk_action_group_set_translation_domain(accounts_action_group, PACKAGE);
+#endif
+ accounts_ui = g_string_new(NULL);
+ enable_ui = g_string_new(NULL);
+
+ action = gtk_action_new("none-available", N_("No actions available"), NULL, NULL);
+ gtk_action_group_add_action(accounts_action_group, action);
+ gtk_action_set_sensitive(action, FALSE);
+
+ for (accounts = purple_accounts_get_all(); accounts; accounts = accounts->next) {
+ char *label;
+ char *name;
+ PurpleAccount *account = NULL;
+
+ account = accounts->data;
+
+ name = g_strdup_printf("account%d", count);
+ label = g_strconcat(purple_account_get_username(account), " (",
+ purple_account_get_protocol_name(account), ")", NULL);
+ action = gtk_action_new(name, label, NULL, NULL);
+ g_free(label);
+ gtk_action_group_add_action(accounts_action_group, action);
+
+ if (!purple_account_get_enabled(account, PIDGIN_UI)) {
+ g_string_append_printf(enable_ui, "", name);
+ g_signal_connect(G_OBJECT(action), "activate",
+ G_CALLBACK(enable_account_cb), account);
+ g_free(name);
+
+ } else {
+ PurpleConnection *gc = NULL;
+ PurplePlugin *plugin = NULL;
+
+ g_string_append_printf(accounts_ui, "", name);
+ g_free(name);
+
+ name = g_strdup_printf("account%d-edit", count);
+ action = gtk_action_new(name, N_("_Edit Account"), NULL, NULL);
+ gtk_action_group_add_action(accounts_action_group, action);
+ g_signal_connect(G_OBJECT(action), "activate",
+ G_CALLBACK(modify_account_cb), account);
+ g_string_append_printf(accounts_ui, "", name);
+ g_free(name);
+
+ g_string_append(accounts_ui, "");
+
+ gc = purple_account_get_connection(account);
+ plugin = gc && PURPLE_CONNECTION_IS_CONNECTED(gc) ? gc->prpl : NULL;
+ if (plugin && PURPLE_PLUGIN_HAS_ACTIONS(plugin)) {
+ build_plugin_actions(accounts_action_group, accounts_ui, count, plugin, gc);
+ } else {
+ g_string_append(accounts_ui, "");
+ }
+
+ g_string_append(accounts_ui, "");
+
+ name = g_strdup_printf("account%d-disable", count);
+ action = gtk_action_new(name, N_("_Disable"), NULL, NULL);
+ gtk_action_group_add_action(accounts_action_group, action);
+ g_signal_connect(G_OBJECT(action), "activate",
+ G_CALLBACK(disable_account_cb), account);
+ g_string_append_printf(accounts_ui, "", name);
+ g_free(name);
+
+ g_string_append(accounts_ui, "");
+ }
+ count++;
+ }
+
+ ui_string = g_strconcat("",
+ enable_ui->str,
+ "",
+ accounts_ui->str,
+ "",
+ NULL);
+ gtk_ui_manager_insert_action_group(gtkblist->ui, accounts_action_group, 1);
+ accounts_merge_id = gtk_ui_manager_add_ui_from_string(gtkblist->ui, ui_string, -1, NULL);
+purple_debug_info("blist", "The account menu is {%s}\n", ui_string);
+ g_string_free(enable_ui, TRUE);
+ g_string_free(accounts_ui, TRUE);
+ g_free(ui_string);
+#else
GtkWidget *menuitem = NULL, *submenu = NULL;
+ GList *l = NULL;
GtkAccelGroup *accel_group = NULL;
- GList *l = NULL, *accounts = NULL;
gboolean disabled_accounts = FALSE;
gboolean enabled_accounts = FALSE;
if (accountmenu == NULL)
return;
-#if GTK_CHECK_VERSION(2,4,0)
-/* TODO: Update Accounts... */
-#else
/* Clear the old Accounts menu */
for (l = gtk_container_get_children(GTK_CONTAINER(accountmenu)); l; l = g_list_delete_link(l, l)) {
menuitem = l->data;
--
cgit v1.2.1
From 37f3eaa2794649bfb53a4ebb445425f5e69b7dfd Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 28 Jul 2009 01:50:42 +0000
Subject: Re-enable the plugin sub-menus. Even though it's similar to the
accounts code, it seems to work correctly, so there must be some other bug
there.
---
pidgin/gtkblist.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 55 insertions(+), 3 deletions(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index df0bfbba40..ae863a6a88 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -8436,14 +8436,66 @@ static GList *plugin_submenus = NULL;
void
pidgin_blist_update_plugin_actions(void)
{
- GtkWidget *menuitem, *submenu;
PurplePlugin *plugin = NULL;
GList *l;
- GtkAccelGroup *accel_group;
#if GTK_CHECK_VERSION(2,4,0)
-/* TODO: Update Plugin */
+ GtkAction *action;
+ GString *plugins_ui;
+ gchar *ui_string;
+ int count = 0;
+
+ if ((gtkblist == NULL) || (gtkblist->ui == NULL))
+ return;
+
+ /* Clear the old menu */
+ gtk_ui_manager_remove_ui(gtkblist->ui, plugins_merge_id);
+ gtk_ui_manager_remove_action_group(gtkblist->ui, plugins_action_group);
+ g_object_unref(G_OBJECT(plugins_action_group));
+
+ plugins_action_group = gtk_action_group_new("Accounts");
+#ifdef ENABLE_NLS
+ gtk_action_group_set_translation_domain(plugins_action_group, PACKAGE);
+#endif
+ plugins_ui = g_string_new(NULL);
+
+ /* Add a submenu for each plugin with custom actions */
+ for (l = purple_plugins_get_loaded(); l; l = l->next) {
+ char *name;
+
+ plugin = (PurplePlugin *)l->data;
+
+ if (PURPLE_IS_PROTOCOL_PLUGIN(plugin))
+ continue;
+
+ if (!PURPLE_PLUGIN_HAS_ACTIONS(plugin))
+ continue;
+
+ name = g_strdup_printf("plugin%d", count);
+ action = gtk_action_new(name, plugin->info->name, NULL, NULL);
+ gtk_action_group_add_action(plugins_action_group, action);
+ g_string_append_printf(plugins_ui, "", name);
+ g_free(name);
+
+ build_plugin_actions(plugins_action_group, plugins_ui, count, plugin, NULL);
+
+ g_string_append(plugins_ui, "");
+ count++;
+ }
+
+ ui_string = g_strconcat("",
+ plugins_ui->str,
+ "",
+ NULL);
+ gtk_ui_manager_insert_action_group(gtkblist->ui, plugins_action_group, 1);
+ plugins_merge_id = gtk_ui_manager_add_ui_from_string(gtkblist->ui, ui_string, -1, NULL);
+purple_debug_info("blist", "The plugins menu is {%s}\n", ui_string);
+
+ g_string_free(plugins_ui, TRUE);
+ g_free(ui_string);
#else
+ GtkWidget *menuitem, *submenu;
+ GtkAccelGroup *accel_group;
GtkWidget *pluginmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools"));
g_return_if_fail(pluginmenu != NULL);
--
cgit v1.2.1
From 62bcadff8691ab7e92001b12d243b059ad82eb33 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 28 Jul 2009 01:52:46 +0000
Subject: Cleanup things in a slightly less (non-fatal) error-producing way.
---
pidgin/gtkblist.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index ae863a6a88..baa3264fe4 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -8204,9 +8204,11 @@ pidgin_blist_update_accounts_menu(void)
return;
/* Clear the old menu */
- gtk_ui_manager_remove_ui(gtkblist->ui, accounts_merge_id);
- gtk_ui_manager_remove_action_group(gtkblist->ui, accounts_action_group);
- g_object_unref(G_OBJECT(accounts_action_group));
+ if (accounts_action_group) {
+ gtk_ui_manager_remove_ui(gtkblist->ui, accounts_merge_id);
+ gtk_ui_manager_remove_action_group(gtkblist->ui, accounts_action_group);
+ g_object_unref(G_OBJECT(accounts_action_group));
+ }
accounts_action_group = gtk_action_group_new("Accounts");
#ifdef ENABLE_NLS
@@ -8449,9 +8451,11 @@ pidgin_blist_update_plugin_actions(void)
return;
/* Clear the old menu */
- gtk_ui_manager_remove_ui(gtkblist->ui, plugins_merge_id);
- gtk_ui_manager_remove_action_group(gtkblist->ui, plugins_action_group);
- g_object_unref(G_OBJECT(plugins_action_group));
+ if (plugins_action_group) {
+ gtk_ui_manager_remove_ui(gtkblist->ui, plugins_merge_id);
+ gtk_ui_manager_remove_action_group(gtkblist->ui, plugins_action_group);
+ g_object_unref(G_OBJECT(plugins_action_group));
+ }
plugins_action_group = gtk_action_group_new("Accounts");
#ifdef ENABLE_NLS
@@ -8585,8 +8589,11 @@ pidgin_blist_update_sort_methods(void)
return;
/* Clear the old menu */
- gtk_ui_manager_remove_ui(gtkblist->ui, sort_merge_id);
- gtk_ui_manager_remove_action_group(gtkblist->ui, sort_action_group);
+ if (sort_action_group) {
+ gtk_ui_manager_remove_ui(gtkblist->ui, sort_merge_id);
+ gtk_ui_manager_remove_action_group(gtkblist->ui, sort_action_group);
+ g_object_unref(G_OBJECT(sort_action_group));
+ }
sort_action_group = gtk_action_group_new("SortMethods");
#ifdef ENABLE_NLS
--
cgit v1.2.1
From 7c5832614a31d05401a90c509624c1052f282a9b Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 28 Jul 2009 02:41:18 +0000
Subject: Get rid of the remaining warnings in gtkblist.c.
---
pidgin/gtkblist.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index baa3264fe4..0606251aaf 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -163,7 +163,9 @@ static void pidgin_blist_update(PurpleBuddyList *list, PurpleBlistNode *node);
static void pidgin_blist_update_group(PurpleBuddyList *list, PurpleBlistNode *node);
static void pidgin_blist_update_contact(PurpleBuddyList *list, PurpleBlistNode *node);
static char *pidgin_get_tooltip_text(PurpleBlistNode *node, gboolean full);
+#if !GTK_CHECK_VERSION(2,4,0)
static const char *item_factory_translate_func (const char *path, gpointer func_data);
+#endif
static gboolean get_iter_from_node(PurpleBlistNode *node, GtkTreeIter *iter);
static gboolean buddy_is_displayable(PurpleBuddy *buddy);
static void redo_buddy_list(PurpleBuddyList *list, gboolean remove, gboolean rerender);
@@ -3535,7 +3537,7 @@ static const GtkActionEntry blist_menu_entries[] = {
{ "Plugins", PIDGIN_STOCK_TOOLBAR_PLUGINS, N_("Plu_gins"), "U", NULL, pidgin_plugin_dialog_show },
{ "Preferences", GTK_STOCK_PREFERENCES, N_("Pr_eferences"), "P", NULL, pidgin_prefs_show },
{ "Privacy", NULL, N_("Pr_ivacy"), NULL, NULL, pidgin_privacy_dialog_show },
- { "FileTransfers", PIDGIN_STOCK_TOOLBAR_TRANSFER, N_("_File Transfers"), "T", NULL, gtk_blist_show_xfer_dialog_cb },
+ { "FileTransfers", PIDGIN_STOCK_TOOLBAR_TRANSFER, N_("_File Transfers"), "T", NULL, G_CALLBACK(gtk_blist_show_xfer_dialog_cb) },
{ "RoomList", NULL, N_("R_oom List"), NULL, NULL, pidgin_roomlist_dialog_show },
{ "SystemLog", NULL, N_("System _Log"), NULL, NULL, gtk_blist_show_systemlog_cb },
@@ -3549,14 +3551,14 @@ static const GtkActionEntry blist_menu_entries[] = {
/* Toggle items */
static const GtkToggleActionEntry blist_menu_toggle_entries[] = {
/* Buddies->Show menu */
- { "ShowOffline", NULL, N_("_Offline Buddies"), NULL, NULL, pidgin_blist_edit_mode_cb, FALSE },
- { "ShowEmptyGroups", NULL, N_("_Empty Groups"), NULL, NULL, pidgin_blist_show_empty_groups_cb, FALSE },
- { "ShowBuddyDetails", NULL, N_("Buddy _Details"), NULL, NULL, pidgin_blist_buddy_details_cb, FALSE },
- { "ShowIdleTimes", NULL, N_("Idle _Times"), NULL, NULL, pidgin_blist_show_idle_time_cb, FALSE },
- { "ShowProtocolIcons", NULL, N_("_Protocol Icons"), NULL, NULL, pidgin_blist_show_protocol_icons_cb, FALSE },
+ { "ShowOffline", NULL, N_("_Offline Buddies"), NULL, NULL, G_CALLBACK(pidgin_blist_edit_mode_cb), FALSE },
+ { "ShowEmptyGroups", NULL, N_("_Empty Groups"), NULL, NULL, G_CALLBACK(pidgin_blist_show_empty_groups_cb), FALSE },
+ { "ShowBuddyDetails", NULL, N_("Buddy _Details"), NULL, NULL, G_CALLBACK(pidgin_blist_buddy_details_cb), FALSE },
+ { "ShowIdleTimes", NULL, N_("Idle _Times"), NULL, NULL, G_CALLBACK(pidgin_blist_show_idle_time_cb), FALSE },
+ { "ShowProtocolIcons", NULL, N_("_Protocol Icons"), NULL, NULL, G_CALLBACK(pidgin_blist_show_protocol_icons_cb), FALSE },
/* Tools menu */
- { "MuteSounds", NULL, N_("Mute _Sounds"), NULL, NULL, pidgin_blist_mute_sounds_cb, FALSE },
+ { "MuteSounds", NULL, N_("Mute _Sounds"), NULL, NULL, G_CALLBACK(pidgin_blist_mute_sounds_cb), FALSE },
};
static const char *blist_menu =
--
cgit v1.2.1
From 8a0f7e2bce2208060a5feff7ba048542c5866799 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 28 Jul 2009 02:48:40 +0000
Subject: Don't get account and plugin actions confused by using the same
action name for both of them.
---
pidgin/gtkblist.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index 0606251aaf..a08e84db33 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -8091,7 +8091,7 @@ plugin_act(GtkObject *obj, PurplePluginAction *pam)
#if GTK_CHECK_VERSION(2,4,0)
static void
-build_plugin_actions(GtkActionGroup *action_group, GString *ui, int parent,
+build_plugin_actions(GtkActionGroup *action_group, GString *ui, char *parent,
PurplePlugin *plugin, gpointer context)
{
GtkAction *menuaction;
@@ -8108,7 +8108,7 @@ build_plugin_actions(GtkActionGroup *action_group, GString *ui, int parent,
action->plugin = plugin;
action->context = context;
- name = g_strdup_printf("plugin-%d-action-%d", parent, count++);
+ name = g_strdup_printf("%s-action-%d", parent, count++);
menuaction = gtk_action_new(name, action->label, NULL, NULL);
gtk_action_group_add_action(action_group, menuaction);
g_string_append_printf(ui, "", name);
@@ -8263,7 +8263,9 @@ pidgin_blist_update_accounts_menu(void)
gc = purple_account_get_connection(account);
plugin = gc && PURPLE_CONNECTION_IS_CONNECTED(gc) ? gc->prpl : NULL;
if (plugin && PURPLE_PLUGIN_HAS_ACTIONS(plugin)) {
- build_plugin_actions(accounts_action_group, accounts_ui, count, plugin, gc);
+ name = g_strdup_printf("account%d", count);
+ build_plugin_actions(accounts_action_group, accounts_ui, name, plugin, gc);
+ g_free(name);
} else {
g_string_append(accounts_ui, "");
}
@@ -8481,12 +8483,13 @@ pidgin_blist_update_plugin_actions(void)
action = gtk_action_new(name, plugin->info->name, NULL, NULL);
gtk_action_group_add_action(plugins_action_group, action);
g_string_append_printf(plugins_ui, "", name);
- g_free(name);
- build_plugin_actions(plugins_action_group, plugins_ui, count, plugin, NULL);
+ build_plugin_actions(plugins_action_group, plugins_ui, name, plugin, NULL);
g_string_append(plugins_ui, "");
count++;
+
+ g_free(name);
}
ui_string = g_strconcat("",
--
cgit v1.2.1
From 3ee3f0beadcc0ff3ac0f3afd0086d0ae4c894e7f Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 28 Jul 2009 03:02:29 +0000
Subject: Try to reduce the printf'ing a little in the account menu creation.
---
pidgin/gtkblist.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index a08e84db33..2ca1cc4eb6 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -8225,12 +8225,13 @@ pidgin_blist_update_accounts_menu(void)
for (accounts = purple_accounts_get_all(); accounts; accounts = accounts->next) {
char *label;
+ char *base;
char *name;
PurpleAccount *account = NULL;
account = accounts->data;
- name = g_strdup_printf("account%d", count);
+ base = name = g_strdup_printf("account%d", count);
label = g_strconcat(purple_account_get_username(account), " (",
purple_account_get_protocol_name(account), ")", NULL);
action = gtk_action_new(name, label, NULL, NULL);
@@ -8241,16 +8242,14 @@ pidgin_blist_update_accounts_menu(void)
g_string_append_printf(enable_ui, "", name);
g_signal_connect(G_OBJECT(action), "activate",
G_CALLBACK(enable_account_cb), account);
- g_free(name);
} else {
PurpleConnection *gc = NULL;
PurplePlugin *plugin = NULL;
g_string_append_printf(accounts_ui, "", name);
- g_free(name);
- name = g_strdup_printf("account%d-edit", count);
+ name = g_strconcat(base, "-edit", NULL);
action = gtk_action_new(name, N_("_Edit Account"), NULL, NULL);
gtk_action_group_add_action(accounts_action_group, action);
g_signal_connect(G_OBJECT(action), "activate",
@@ -8263,16 +8262,14 @@ pidgin_blist_update_accounts_menu(void)
gc = purple_account_get_connection(account);
plugin = gc && PURPLE_CONNECTION_IS_CONNECTED(gc) ? gc->prpl : NULL;
if (plugin && PURPLE_PLUGIN_HAS_ACTIONS(plugin)) {
- name = g_strdup_printf("account%d", count);
- build_plugin_actions(accounts_action_group, accounts_ui, name, plugin, gc);
- g_free(name);
+ build_plugin_actions(accounts_action_group, accounts_ui, base, plugin, gc);
} else {
g_string_append(accounts_ui, "");
}
g_string_append(accounts_ui, "");
- name = g_strdup_printf("account%d-disable", count);
+ name = g_strconcat(base, "-disable", NULL);
action = gtk_action_new(name, N_("_Disable"), NULL, NULL);
gtk_action_group_add_action(accounts_action_group, action);
g_signal_connect(G_OBJECT(action), "activate",
@@ -8282,6 +8279,8 @@ pidgin_blist_update_accounts_menu(void)
g_string_append(accounts_ui, "");
}
+
+ g_free(base);
count++;
}
@@ -8294,6 +8293,7 @@ pidgin_blist_update_accounts_menu(void)
gtk_ui_manager_insert_action_group(gtkblist->ui, accounts_action_group, 1);
accounts_merge_id = gtk_ui_manager_add_ui_from_string(gtkblist->ui, ui_string, -1, NULL);
purple_debug_info("blist", "The account menu is {%s}\n", ui_string);
+
g_string_free(enable_ui, TRUE);
g_string_free(accounts_ui, TRUE);
g_free(ui_string);
--
cgit v1.2.1
From 1932b3cd933825c91df0fe419b26447455bbd528 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 28 Jul 2009 03:43:45 +0000
Subject: Fix the Pause button in the debug window.
---
pidgin/gtkdebug.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pidgin/gtkdebug.c b/pidgin/gtkdebug.c
index 97d38fe48d..d851eff65d 100644
--- a/pidgin/gtkdebug.c
+++ b/pidgin/gtkdebug.c
@@ -818,7 +818,7 @@ debug_window_new(void)
/* Pause */
#if GTK_CHECK_VERSION(2,4,0)
- item = gtk_tool_button_new_from_stock(PIDGIN_STOCK_PAUSE);
+ item = gtk_toggle_tool_button_new_from_stock(PIDGIN_STOCK_PAUSE);
#if GTK_CHECK_VERSION(2,12,0)
gtk_tool_item_set_tooltip_text(item, _("Pause"));
#else
--
cgit v1.2.1
From d0d65a2276cc7f88003dfef276ec7cdb58ac7984 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 28 Jul 2009 04:30:58 +0000
Subject: Start converting the conversation window to UI manager. The
auto-generated parts are not done yet.
---
pidgin/gtkconv.c | 350 +++++++++++++++++++++++++++++++++++++++++++++++++++-
pidgin/gtkconvwin.h | 4 +
2 files changed, 353 insertions(+), 1 deletion(-)
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
index 22fcd3bd01..a9b17e7025 100644
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -160,7 +160,9 @@ static void conv_set_unseen(PurpleConversation *gtkconv, PidginUnseenState state
static void gtkconv_set_unseen(PidginConversation *gtkconv, PidginUnseenState state);
static void update_typing_icon(PidginConversation *gtkconv);
static void update_typing_message(PidginConversation *gtkconv, const char *message);
+#if !GTK_CHECK_VERSION(2,4,0)
static const char *item_factory_translate_func (const char *path, gpointer func_data);
+#endif
gboolean pidgin_conv_has_focus(PurpleConversation *conv);
static GdkColor* generate_nick_colors(guint *numcolors, GdkColor background);
static gboolean color_is_visible(GdkColor foreground, GdkColor background, int color_contrast, int brightness_contrast);
@@ -953,7 +955,11 @@ invite_cb(GtkWidget *widget, PidginConversation *gtkconv)
}
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_new_conv_cb(GtkAction *action, gpointer data)
+#else
menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
pidgin_dialogs_im();
}
@@ -994,7 +1000,11 @@ savelog_writefile_cb(void *user_data, const char *filename)
* plaintext v. HTML file.
*/
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_save_as_cb(GtkAction *action, gpointer data)
+#else
menu_save_as_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *win = data;
PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
@@ -1024,7 +1034,11 @@ menu_save_as_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_view_log_cb(GtkAction *action, gpointer data)
+#else
menu_view_log_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1052,7 +1066,7 @@ menu_view_log_cb(gpointer data, guint action, GtkWidget *widget)
gdk_window_set_cursor(win->window->window, cursor);
gdk_cursor_unref(cursor);
#if GTK_CHECK_VERSION(2,4,0)
- gdk_display_flush(gdk_drawable_get_display(GDK_DRAWABLE(widget->window)));
+//FIXME: gdk_display_flush(gdk_drawable_get_display(GDK_DRAWABLE(widget->window)));
#else
gdk_flush();
#endif
@@ -1082,7 +1096,11 @@ menu_view_log_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_clear_cb(GtkAction *action, gpointer data)
+#else
menu_clear_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1143,7 +1161,11 @@ static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s)
}
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_find_cb(GtkAction *action, gpointer data)
+#else
menu_find_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *gtkwin = data;
GtkWidget *hbox;
@@ -1203,12 +1225,17 @@ menu_find_cb(gpointer data, guint action, GtkWidget *widget)
#ifdef USE_VV
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_initiate_media_call_cb(GtkAction *action, gpointer data)
+#else
menu_initiate_media_call_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *win = (PidginWindow *)data;
PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
PurpleAccount *account = purple_conversation_get_account(conv);
+ /* FIXME: action is not an int... */
purple_prpl_initiate_media(account,
purple_conversation_get_name(conv),
action == 0 ? PURPLE_MEDIA_AUDIO :
@@ -1219,7 +1246,11 @@ menu_initiate_media_call_cb(gpointer data, guint action, GtkWidget *widget)
#endif
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_send_file_cb(GtkAction *action, gpointer data)
+#else
menu_send_file_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *win = data;
PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
@@ -1231,7 +1262,11 @@ menu_send_file_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_add_pounce_cb(GtkAction *action, gpointer data)
+#else
menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1243,7 +1278,11 @@ menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_insert_link_cb(GtkAction *action, gpointer data)
+#else
menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *win = data;
PidginConversation *gtkconv;
@@ -1257,7 +1296,11 @@ menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_insert_image_cb(GtkAction *action, gpointer data)
+#else
menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1274,7 +1317,11 @@ menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget)
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_alias_cb(GtkAction *action, gpointer data)
+#else
menu_alias_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1301,7 +1348,11 @@ menu_alias_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_get_info_cb(GtkAction *action, gpointer data)
+#else
menu_get_info_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1312,7 +1363,11 @@ menu_get_info_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_invite_cb(GtkAction *action, gpointer data)
+#else
menu_invite_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1323,7 +1378,11 @@ menu_invite_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_block_cb(GtkAction *action, gpointer data)
+#else
menu_block_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1334,7 +1393,11 @@ menu_block_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_unblock_cb(GtkAction *action, gpointer data)
+#else
menu_unblock_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1345,7 +1408,11 @@ menu_unblock_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_add_remove_cb(GtkAction *action, gpointer data)
+#else
menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1390,7 +1457,11 @@ hide_conv(PidginConversation *gtkconv, gboolean closetimer)
}
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_close_conv_cb(GtkAction *action, gpointer data)
+#else
menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *win = data;
@@ -1398,7 +1469,11 @@ menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_logging_cb(GtkAction *action, gpointer data)
+#else
menu_logging_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1410,7 +1485,11 @@ menu_logging_cb(gpointer data, guint action, GtkWidget *widget)
if (conv == NULL)
return;
+#if GTK_CHECK_VERSION(2,4,0)
+ logging = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
+#else
logging = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
+#endif
if (logging == purple_conversation_is_logging(conv))
return;
@@ -1463,14 +1542,26 @@ menu_logging_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_toolbar_cb(GtkAction *action, gpointer data)
+{
+ purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar",
+ gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)));
+}
+#else
menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget)
{
purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar",
gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)));
}
+#endif
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_sounds_cb(GtkAction *action, gpointer data)
+#else
menu_sounds_cb(gpointer data, guint action, GtkWidget *widget)
+#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1485,18 +1576,30 @@ menu_sounds_cb(gpointer data, guint action, GtkWidget *widget)
gtkconv = PIDGIN_CONVERSATION(conv);
gtkconv->make_sound =
+#if GTK_CHECK_VERSION(2,4,0)
+ gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
+#else
gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
+#endif
node = get_conversation_blist_node(conv);
if (node)
purple_blist_node_set_bool(node, "gtk-mute-sound", !gtkconv->make_sound);
}
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_timestamps_cb(GtkAction *action, gpointer data)
+{
+ purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps",
+ gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)));
+}
+#else
menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget)
{
purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps",
gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)));
}
+#endif
static void
chat_do_im(PidginConversation *gtkconv, const char *who)
@@ -3126,6 +3229,99 @@ pidgin_conv_get_window(PidginConversation *gtkconv)
return gtkconv->win;
}
+#if GTK_CHECK_VERSION(2,4,0)
+
+static GtkActionEntry menu_entries[] =
+/* TODO: fill out tooltips... */
+{
+ /* Conversation menu */
+ { "ConversationMenu", NULL, N_("_Conversation"), NULL, NULL, NULL },
+ { "NewInstantMessage", PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW, N_("New Instant _Message..."), "M", NULL, menu_new_conv_cb },
+ { "Find", GTK_STOCK_FIND, N_("_Find..."), NULL, NULL, menu_find_cb },
+ { "ViewLog", NULL, N_("View _Log"), NULL, NULL, menu_view_log_cb },
+ { "SaveAs", GTK_STOCK_SAVE_AS, N_("_Save As..."), NULL, NULL, menu_save_as_cb },
+ { "ClearScrollback", GTK_STOCK_CLEAR, N_("Clea_r Scrollback"), "L", NULL, menu_clear_cb },
+
+#ifdef USE_VV
+ { "MediaMenu", NULL, N_("M_edia"), NULL, NULL, NULL },
+ { "AudioCall", PIDGIN_STOCK_TOOLBAR_AUDIO_CALL, N_("_Audio Call"), NULL, NULL, menu_initiate_media_call_cb },
+ { "VideoCall", PIDGIN_STOCK_TOOLBAR_VIDEO_CALL, N_("_Video Call"), NULL, NULL, menu_initiate_media_call_cb },
+ { "AudioVideoCall", PIDGIN_STOCK_TOOLBAR_VIDEO_CALL, N_("Audio\\/Video _Call"), NULL, NULL, menu_initiate_media_call_cb },
+#endif
+
+ { "SendFile", PIDGIN_STOCK_TOOLBAR_SEND_FILE, N_("Se_nd File..."), NULL, NULL, menu_send_file_cb },
+ { "AddBuddyPounce", NULL, N_("Add Buddy _Pounce..."), NULL, NULL, menu_add_pounce_cb },
+ { "GetInfo", PIDGIN_STOCK_TOOLBAR_USER_INFO, N_("_Get Info"), "O", NULL, menu_get_info_cb },
+ { "Invite", NULL, N_("In_vite..."), NULL, NULL, menu_invite_cb },
+ { "MoreMenu", NULL, N_("M_ore"), NULL, NULL, NULL },
+ { "Alias", NULL, N_("Al_ias..."), NULL, NULL, menu_alias_cb },
+ { "Block", PIDGIN_STOCK_TOOLBAR_BLOCK, N_("_Block..."), NULL, NULL, menu_block_cb },
+ { "Unblock", PIDGIN_STOCK_TOOLBAR_UNBLOCK, N_("_Unblock..."), NULL, NULL, menu_unblock_cb },
+ { "Add", GTK_STOCK_ADD, N_("_Add..."), NULL, NULL, menu_add_remove_cb },
+ { "Remove", GTK_STOCK_REMOVE, N_("_Remove..."), NULL, NULL, menu_add_remove_cb },
+ { "InsertLink", PIDGIN_STOCK_TOOLBAR_INSERT_LINK, N_("Insert Lin_k..."), NULL, NULL, menu_insert_link_cb },
+ { "InsertImage", PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE, N_("Insert Imag_e..."), NULL, NULL, menu_insert_image_cb },
+ { "Close", GTK_STOCK_CLOSE, N_("_Close"), NULL, NULL, menu_close_conv_cb },
+
+ /* Options */
+ { "OptionsMenu", NULL, N_("_Options"), NULL, NULL, NULL },
+};
+
+/* Toggle items */
+static const GtkToggleActionEntry menu_toggle_entries[] = {
+ { "EnableLogging", NULL, N_("Enable _Logging"), NULL, NULL, menu_logging_cb, FALSE },
+ { "EnableSounds", NULL, N_("Enable _Sounds"), NULL, NULL, menu_sounds_cb, FALSE },
+ { "ShowFormattingToolbars", NULL, N_("Show Formatting _Toolbars"), NULL, NULL, menu_toolbar_cb, FALSE },
+ { "ShowTimestamps", NULL, N_("Show Ti_mestamps"), NULL, NULL, menu_timestamps_cb, FALSE },
+};
+
+static const char *conversation_menu =
+""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+#ifdef USE_VV
+ ""
+ ""
+ ""
+ ""
+ ""
+#endif
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+"";
+
+#else
+
static GtkItemFactoryEntry menu_items[] =
{
/* Conversation menu */
@@ -3209,6 +3405,8 @@ item_factory_translate_func (const char *path, gpointer func_data)
return _(path);
}
+#endif
+
static void
sound_method_pref_changed_cb(const char *name, PurplePrefType type,
gconstpointer value, gpointer data)
@@ -3328,6 +3526,8 @@ populate_menu_with_options(GtkWidget *menu, PidginConversation *gtkconv, gboolea
static void
regenerate_options_items(PidginWindow *win)
{
+#if GTK_CHECK_VERSION(2,4,0)
+#else
GtkWidget *menu;
PidginConversation *gtkconv;
GList *list;
@@ -3351,6 +3551,7 @@ regenerate_options_items(PidginWindow *win)
}
gtk_widget_show_all(menu);
+#endif
}
static void
@@ -3364,6 +3565,8 @@ remove_from_list(GtkWidget *widget, PidginWindow *win)
static void
regenerate_plugins_items(PidginWindow *win)
{
+#if GTK_CHECK_VERSION(2,4,0)
+#else
GList *action_items;
GtkWidget *menu;
GList *list;
@@ -3405,8 +3608,10 @@ regenerate_plugins_items(PidginWindow *win)
g_signal_connect(G_OBJECT(item), "destroy", G_CALLBACK(remove_from_list), win);
}
g_object_set_data(G_OBJECT(win->window), "plugin-actions", action_items);
+#endif
}
+#if !GTK_CHECK_VERSION(2,4,0)
static void menubar_activated(GtkWidget *item, gpointer data)
{
PidginWindow *win = data;
@@ -3429,12 +3634,146 @@ focus_out_from_menubar(GtkWidget *wid, PidginWindow *win)
g_signal_handlers_disconnect_by_func(G_OBJECT(win->menu.menubar),
G_CALLBACK(focus_out_from_menubar), win);
}
+#endif
static GtkWidget *
setup_menubar(PidginWindow *win)
{
GtkAccelGroup *accel_group;
const char *method;
+
+#if GTK_CHECK_VERSION(2,4,0)
+ GtkActionGroup *action_group;
+ GError *error;
+
+ action_group = gtk_action_group_new("ConversationActions");
+ gtk_action_group_add_actions(action_group,
+ menu_entries,
+ G_N_ELEMENTS(menu_entries),
+ win);
+ gtk_action_group_add_toggle_actions(action_group,
+ menu_toggle_entries,
+ G_N_ELEMENTS(menu_toggle_entries),
+ win);
+#ifdef ENABLE_NLS
+ gtk_action_group_set_translation_domain(action_group,
+ PACKAGE);
+#endif
+
+ win->menu.ui = gtk_ui_manager_new();
+ gtk_ui_manager_insert_action_group(win->menu.ui, action_group, 0);
+
+ accel_group = gtk_ui_manager_get_accel_group(win->menu.ui);
+ gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group);
+ g_signal_connect(G_OBJECT(accel_group), "accel-changed",
+ G_CALLBACK(pidgin_save_accels_cb), NULL);
+
+ error = NULL;
+ if (!gtk_ui_manager_add_ui_from_string(win->menu.ui, conversation_menu, -1, &error))
+ {
+ g_message("building menus failed: %s", error->message);
+ g_error_free(error);
+ exit(EXIT_FAILURE);
+ }
+
+ win->menu.menubar =
+ gtk_ui_manager_get_widget(win->menu.ui, "/Conversation");
+
+ win->menu.view_log =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/ConversationMenu/ViewLog");
+
+#ifdef USE_VV
+ win->audio_call =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/ConversationMenu/MediaMenu/AudioCall");
+ win->video_call =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/ConversationMenu/MediaMenu/VideoCall");
+ win->audio_video_call =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/ConversationMenu/MediaMenu/AudioVideoCall");
+#endif
+
+ /* --- */
+
+ win->menu.send_file =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/ConversationMenu/SendFile");
+
+ win->menu.add_pounce =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/ConversationMenu/AddBuddyPounce");
+
+ /* --- */
+
+ win->menu.get_info =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/ConversationMenu/GetInfo");
+
+ win->menu.invite =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/ConversationMenu/Invite");
+
+ /* --- */
+
+ win->menu.alias =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/ConversationMenu/Alias");
+
+ win->menu.block =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/ConversationMenu/Block");
+
+ win->menu.unblock =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/ConversationMenu/Unblock");
+
+ win->menu.add =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/ConversationMenu/Add");
+
+ win->menu.remove =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/ConversationMenu/Remove");
+
+ /* --- */
+
+ win->menu.insert_link =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/ConversationMenu/InsertLink");
+
+ win->menu.insert_image =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/ConversationMenu/InsertImage");
+
+ /* --- */
+
+ win->menu.logging =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/OptionsMenu/EnableLogging");
+ win->menu.sounds =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/OptionsMenu/EnableSounds");
+ method = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method");
+ if (method != NULL && !strcmp(method, "none"))
+ {
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.sounds),
+ FALSE);
+ gtk_widget_set_sensitive(win->menu.sounds, FALSE);
+ }
+ purple_prefs_connect_callback(win, PIDGIN_PREFS_ROOT "/sound/method",
+ sound_method_pref_changed_cb, win);
+
+ win->menu.show_formatting_toolbar =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/OptionsMenu/ShowFormattingToolbars");
+ win->menu.show_timestamps =
+ gtk_ui_manager_get_widget(win->menu.ui,
+ "/Conversation/OptionsMenu/ShowTimestamps");
+ win->menu.show_icon = NULL;
+
+#else
GtkWidget *menuitem;
accel_group = gtk_accel_group_new ();
@@ -3556,6 +3895,8 @@ setup_menubar(PidginWindow *win)
N_("/Options/Show Timestamps"));
win->menu.show_icon = NULL;
+#endif
+
win->menu.tray = pidgin_menu_tray_new();
gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar),
win->menu.tray);
@@ -3869,6 +4210,8 @@ compare_buddy_presence(PurplePresence *p1, PurplePresence *p2)
static void
generate_send_to_items(PidginWindow *win)
{
+#if GTK_CHECK_VERSION(2,4,0)
+#else
GtkWidget *menu;
GSList *group = NULL;
GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
@@ -3953,6 +4296,7 @@ generate_send_to_items(PidginWindow *win)
if (!group)
gtk_widget_set_sensitive(win->menu.send_to, FALSE);
update_send_to_selection(win);
+#endif
}
static const char *
@@ -9337,7 +9681,11 @@ pidgin_conv_window_destroy(PidginWindow *win)
}
gtk_widget_destroy(win->window);
+#if GTK_CHECK_VERSION(2,4,0)
+ g_object_unref(G_OBJECT(win->menu.ui));
+#else
g_object_unref(G_OBJECT(win->menu.item_factory));
+#endif
purple_notify_close_with_handle(win);
purple_signals_disconnect_by_handle(win);
diff --git a/pidgin/gtkconvwin.h b/pidgin/gtkconvwin.h
index 986b1ca28f..35e7776c16 100644
--- a/pidgin/gtkconvwin.h
+++ b/pidgin/gtkconvwin.h
@@ -76,7 +76,11 @@ struct _PidginWindow
GtkWidget *typing_icon;
+#if GTK_CHECK_VERSION(2,4,0)
+ GtkUIManager *ui;
+#else
GtkItemFactory *item_factory;
+#endif
} menu;
--
cgit v1.2.1
From 83c7ac1d0b82a29aa4171ffb3774b02692f821c9 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 28 Jul 2009 05:28:46 +0000
Subject: Use GtkActions instead of GtkWidgets for the shortcuts to items in
the menu on the conversation window for GTK+ 2.6+. I don't think it works
properly for 2.4active_conv = conv;
+#if GTK_CHECK_VERSION(2,6,0)
+ purple_conversation_set_logging(conv,
+ gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(gtkconv->win->menu.logging)));
+#else
purple_conversation_set_logging(conv,
gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtkconv->win->menu.logging)));
+#endif
entry = GTK_IMHTML(gtkconv->entry);
protocol_name = purple_account_get_protocol_name(conv->account);
@@ -3416,19 +3421,31 @@ sound_method_pref_changed_cb(const char *name, PurplePrefType type,
if (!strcmp(method, "none"))
{
+#if GTK_CHECK_VERSION(2,6,0)
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.sounds),
+ FALSE);
+ gtk_action_set_sensitive(win->menu.sounds, FALSE);
+#else
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds),
FALSE);
gtk_widget_set_sensitive(win->menu.sounds, FALSE);
+#endif
}
else
{
PidginConversation *gtkconv = pidgin_conv_window_get_active_gtkconv(win);
+#if GTK_CHECK_VERSION(2,6,0)
+ if (gtkconv != NULL)
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.sounds),
+ gtkconv->make_sound);
+ gtk_action_set_sensitive(win->menu.sounds, TRUE);
+#else
if (gtkconv != NULL)
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds),
gtkconv->make_sound);
gtk_widget_set_sensitive(win->menu.sounds, TRUE);
-
+#endif
}
}
@@ -3680,96 +3697,96 @@ setup_menubar(PidginWindow *win)
gtk_ui_manager_get_widget(win->menu.ui, "/Conversation");
win->menu.view_log =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/ConversationMenu/ViewLog");
#ifdef USE_VV
win->audio_call =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/ConversationMenu/MediaMenu/AudioCall");
win->video_call =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/ConversationMenu/MediaMenu/VideoCall");
win->audio_video_call =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/ConversationMenu/MediaMenu/AudioVideoCall");
#endif
/* --- */
win->menu.send_file =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/ConversationMenu/SendFile");
win->menu.add_pounce =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/ConversationMenu/AddBuddyPounce");
/* --- */
win->menu.get_info =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/ConversationMenu/GetInfo");
win->menu.invite =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/ConversationMenu/Invite");
/* --- */
win->menu.alias =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/ConversationMenu/Alias");
win->menu.block =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/ConversationMenu/Block");
win->menu.unblock =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/ConversationMenu/Unblock");
win->menu.add =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/ConversationMenu/Add");
win->menu.remove =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/ConversationMenu/Remove");
/* --- */
win->menu.insert_link =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/ConversationMenu/InsertLink");
win->menu.insert_image =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/ConversationMenu/InsertImage");
/* --- */
win->menu.logging =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/OptionsMenu/EnableLogging");
win->menu.sounds =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/OptionsMenu/EnableSounds");
method = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method");
if (method != NULL && !strcmp(method, "none"))
{
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.sounds),
FALSE);
- gtk_widget_set_sensitive(win->menu.sounds, FALSE);
+ gtk_action_set_sensitive(win->menu.sounds, FALSE);
}
purple_prefs_connect_callback(win, PIDGIN_PREFS_ROOT "/sound/method",
sound_method_pref_changed_cb, win);
win->menu.show_formatting_toolbar =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/OptionsMenu/ShowFormattingToolbars");
win->menu.show_timestamps =
- gtk_ui_manager_get_widget(win->menu.ui,
+ gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/OptionsMenu/ShowTimestamps");
win->menu.show_icon = NULL;
@@ -4078,7 +4095,8 @@ update_send_to_selection(PidginWindow *win)
if (!(b = purple_find_buddy(account, conv->name)))
return FALSE;
-
+#if GTK_CHECK_VERSION(2,4,0)
+#else
gtk_widget_show(win->menu.send_to);
menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(win->menu.send_to));
@@ -4100,6 +4118,7 @@ update_send_to_selection(PidginWindow *win)
break;
}
}
+#endif
return FALSE;
}
@@ -6707,6 +6726,16 @@ pidgin_conv_send_confirm(PurpleConversation *conv, const char *message)
gtk_imhtml_append_text(GTK_IMHTML(gtkconv->entry), message, 0);
}
+/* Mask functions with ones from newer GTK+ */
+#if GTK_CHECK_VERSION(2,6,0)
+#define gtk_widget_set_sensitive_ gtk_widget_set_sensitive
+#define gtk_widget_show_ gtk_widget_show
+#define gtk_widget_hide_ gtk_widget_hide
+#define gtk_widget_set_sensitive gtk_action_set_sensitive
+#define gtk_widget_show(x) gtk_action_set_visible((x), TRUE)
+#define gtk_widget_hide(x) gtk_action_set_visible((x), FALSE)
+#endif
+
/*
* Makes sure all the menu items and all the buttons are hidden/shown and
* sensitive/insensitive. This is called after changing tabs and when an
@@ -6941,6 +6970,17 @@ gray_stuff_out(PidginConversation *gtkconv)
}
}
+/* Restore the functions */
+#if GTK_CHECK_VERSION(2,6,0)
+#undef gtk_widget_set_sensitive
+#undef gtk_widget_show
+#undef gtk_widget_hide
+
+#define gtk_widget_set_sensitive gtk_widget_set_sensitive_
+#define gtk_widget_show gtk_widget_show_
+#define gtk_widget_hide gtk_widget_hide_
+#endif
+
static void
pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields)
{
@@ -7627,9 +7667,15 @@ show_timestamps_pref_cb(const char *name, PurplePrefType type,
gtkconv = PIDGIN_CONVERSATION(conv);
win = gtkconv->win;
+#if GTK_CHECK_VERSION(2,6,0)
+ gtk_toggle_action_set_active(
+ GTK_TOGGLE_ACTION(win->menu.show_timestamps),
+ (gboolean)GPOINTER_TO_INT(value));
+#else
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(win->menu.show_timestamps),
(gboolean)GPOINTER_TO_INT(value));
+#endif
gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),
(gboolean)GPOINTER_TO_INT(value));
@@ -7655,9 +7701,15 @@ show_formatting_toolbar_pref_cb(const char *name, PurplePrefType type,
gtkconv = PIDGIN_CONVERSATION(conv);
win = gtkconv->win;
+#if GTK_CHECK_VERSION(2,6,0)
+ gtk_toggle_action_set_active(
+ GTK_TOGGLE_ACTION(win->menu.show_formatting_toolbar),
+ (gboolean)GPOINTER_TO_INT(value));
+#else
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar),
(gboolean)GPOINTER_TO_INT(value));
+#endif
if ((gboolean)GPOINTER_TO_INT(value))
gtk_widget_show(gtkconv->toolbar);
@@ -8886,6 +8938,8 @@ infopane_press_cb(GtkWidget *widget, GdkEventButton *e, PidginConversation *gtkc
/* Right click was pressed. Popup the context menu. */
GtkWidget *menu = gtk_menu_new(), *sub;
gboolean populated = populate_menu_with_options(menu, gtkconv, TRUE);
+#if GTK_CHECK_VERSION(2,4,0)
+#else
sub = gtk_menu_item_get_submenu(GTK_MENU_ITEM(gtkconv->win->menu.send_to));
if (sub && GTK_WIDGET_IS_SENSITIVE(gtkconv->win->menu.send_to)) {
@@ -8900,7 +8954,7 @@ infopane_press_cb(GtkWidget *widget, GdkEventButton *e, PidginConversation *gtkc
gtk_widget_destroy(menu);
return FALSE;
}
-
+#endif
gtk_widget_show_all(menu);
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time);
return TRUE;
@@ -9410,8 +9464,13 @@ switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num,
/* Update the menubar */
+#if GTK_CHECK_VERSION(2,6,0)
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtkconv->win->menu.logging),
+ purple_conversation_is_logging(conv));
+#else
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkconv->win->menu.logging),
purple_conversation_is_logging(conv));
+#endif
generate_send_to_items(win);
regenerate_options_items(win);
@@ -9420,6 +9479,17 @@ switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num,
pidgin_conv_switch_active_conversation(conv);
sound_method = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method");
+#if GTK_CHECK_VERSION(2,6,0)
+ if (strcmp(sound_method, "none") != 0)
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.sounds),
+ gtkconv->make_sound);
+
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.show_formatting_toolbar),
+ purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar"));
+
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.show_timestamps),
+ purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps"));
+#else
if (strcmp(sound_method, "none") != 0)
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds),
gtkconv->make_sound);
@@ -9429,6 +9499,7 @@ switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num,
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps),
purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps"));
+#endif
/*
* We pause icons when they are not visible. If this icon should
diff --git a/pidgin/gtkconvwin.h b/pidgin/gtkconvwin.h
index 35e7776c16..e440502302 100644
--- a/pidgin/gtkconvwin.h
+++ b/pidgin/gtkconvwin.h
@@ -46,8 +46,31 @@ struct _PidginWindow
struct
{
+/* Some necessary functions were only added in 2.6.0 */
GtkWidget *menubar;
+#if GTK_CHECK_VERSION(2,6,0)
+ GtkAction *view_log;
+
+ GtkAction *send_file;
+ GtkAction *add_pounce;
+ GtkAction *get_info;
+ GtkAction *invite;
+
+ GtkAction *alias;
+ GtkAction *block;
+ GtkAction *unblock;
+ GtkAction *add;
+ GtkAction *remove;
+
+ GtkAction *insert_link;
+ GtkAction *insert_image;
+
+ GtkAction *logging;
+ GtkAction *sounds;
+ GtkAction *show_formatting_toolbar;
+ GtkAction *show_timestamps;
+#else
GtkWidget *view_log;
GtkWidget *send_file;
@@ -68,6 +91,7 @@ struct _PidginWindow
GtkWidget *sounds;
GtkWidget *show_formatting_toolbar;
GtkWidget *show_timestamps;
+#endif
GtkWidget *show_icon;
GtkWidget *send_to;
@@ -102,9 +126,15 @@ struct _PidginWindow
gint drag_leave_signal;
/* Media menu options. */
+#if GTK_CHECK_VERSION(2,4,0)
+ GtkAction *audio_call;
+ GtkAction *video_call;
+ GtkAction *audio_video_call;
+#else
GtkWidget *audio_call;
GtkWidget *video_call;
GtkWidget *audio_video_call;
+#endif
};
/*@}*/
--
cgit v1.2.1
From 018da9b995e2f8cbf28fababc71805ca89829763 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 28 Jul 2009 05:33:03 +0000
Subject: Fix up some simple warnings for the conversation UI.
---
pidgin/gtkconv.c | 48 ++++++++++++++++++++++++------------------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
index e6b852183d..6eb4a016f7 100644
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -3241,32 +3241,32 @@ static GtkActionEntry menu_entries[] =
{
/* Conversation menu */
{ "ConversationMenu", NULL, N_("_Conversation"), NULL, NULL, NULL },
- { "NewInstantMessage", PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW, N_("New Instant _Message..."), "M", NULL, menu_new_conv_cb },
- { "Find", GTK_STOCK_FIND, N_("_Find..."), NULL, NULL, menu_find_cb },
- { "ViewLog", NULL, N_("View _Log"), NULL, NULL, menu_view_log_cb },
- { "SaveAs", GTK_STOCK_SAVE_AS, N_("_Save As..."), NULL, NULL, menu_save_as_cb },
- { "ClearScrollback", GTK_STOCK_CLEAR, N_("Clea_r Scrollback"), "L", NULL, menu_clear_cb },
+ { "NewInstantMessage", PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW, N_("New Instant _Message..."), "M", NULL, G_CALLBACK(menu_new_conv_cb) },
+ { "Find", GTK_STOCK_FIND, N_("_Find..."), NULL, NULL, G_CALLBACK(menu_find_cb) },
+ { "ViewLog", NULL, N_("View _Log"), NULL, NULL, G_CALLBACK(menu_view_log_cb) },
+ { "SaveAs", GTK_STOCK_SAVE_AS, N_("_Save As..."), NULL, NULL, G_CALLBACK(menu_save_as_cb) },
+ { "ClearScrollback", GTK_STOCK_CLEAR, N_("Clea_r Scrollback"), "L", NULL, G_CALLBACK(menu_clear_cb) },
#ifdef USE_VV
{ "MediaMenu", NULL, N_("M_edia"), NULL, NULL, NULL },
- { "AudioCall", PIDGIN_STOCK_TOOLBAR_AUDIO_CALL, N_("_Audio Call"), NULL, NULL, menu_initiate_media_call_cb },
- { "VideoCall", PIDGIN_STOCK_TOOLBAR_VIDEO_CALL, N_("_Video Call"), NULL, NULL, menu_initiate_media_call_cb },
- { "AudioVideoCall", PIDGIN_STOCK_TOOLBAR_VIDEO_CALL, N_("Audio\\/Video _Call"), NULL, NULL, menu_initiate_media_call_cb },
+ { "AudioCall", PIDGIN_STOCK_TOOLBAR_AUDIO_CALL, N_("_Audio Call"), NULL, NULL, G_CALLBACK(menu_initiate_media_call_cb) },
+ { "VideoCall", PIDGIN_STOCK_TOOLBAR_VIDEO_CALL, N_("_Video Call"), NULL, NULL, G_CALLBACK(menu_initiate_media_call_cb) },
+ { "AudioVideoCall", PIDGIN_STOCK_TOOLBAR_VIDEO_CALL, N_("Audio\\/Video _Call"), NULL, NULL, G_CALLBACK(menu_initiate_media_call_cb) },
#endif
- { "SendFile", PIDGIN_STOCK_TOOLBAR_SEND_FILE, N_("Se_nd File..."), NULL, NULL, menu_send_file_cb },
- { "AddBuddyPounce", NULL, N_("Add Buddy _Pounce..."), NULL, NULL, menu_add_pounce_cb },
- { "GetInfo", PIDGIN_STOCK_TOOLBAR_USER_INFO, N_("_Get Info"), "O", NULL, menu_get_info_cb },
- { "Invite", NULL, N_("In_vite..."), NULL, NULL, menu_invite_cb },
+ { "SendFile", PIDGIN_STOCK_TOOLBAR_SEND_FILE, N_("Se_nd File..."), NULL, NULL, G_CALLBACK(menu_send_file_cb) },
+ { "AddBuddyPounce", NULL, N_("Add Buddy _Pounce..."), NULL, NULL, G_CALLBACK(menu_add_pounce_cb) },
+ { "GetInfo", PIDGIN_STOCK_TOOLBAR_USER_INFO, N_("_Get Info"), "O", NULL, G_CALLBACK(menu_get_info_cb) },
+ { "Invite", NULL, N_("In_vite..."), NULL, NULL, G_CALLBACK(menu_invite_cb) },
{ "MoreMenu", NULL, N_("M_ore"), NULL, NULL, NULL },
- { "Alias", NULL, N_("Al_ias..."), NULL, NULL, menu_alias_cb },
- { "Block", PIDGIN_STOCK_TOOLBAR_BLOCK, N_("_Block..."), NULL, NULL, menu_block_cb },
- { "Unblock", PIDGIN_STOCK_TOOLBAR_UNBLOCK, N_("_Unblock..."), NULL, NULL, menu_unblock_cb },
- { "Add", GTK_STOCK_ADD, N_("_Add..."), NULL, NULL, menu_add_remove_cb },
- { "Remove", GTK_STOCK_REMOVE, N_("_Remove..."), NULL, NULL, menu_add_remove_cb },
- { "InsertLink", PIDGIN_STOCK_TOOLBAR_INSERT_LINK, N_("Insert Lin_k..."), NULL, NULL, menu_insert_link_cb },
- { "InsertImage", PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE, N_("Insert Imag_e..."), NULL, NULL, menu_insert_image_cb },
- { "Close", GTK_STOCK_CLOSE, N_("_Close"), NULL, NULL, menu_close_conv_cb },
+ { "Alias", NULL, N_("Al_ias..."), NULL, NULL, G_CALLBACK(menu_alias_cb) },
+ { "Block", PIDGIN_STOCK_TOOLBAR_BLOCK, N_("_Block..."), NULL, NULL, G_CALLBACK(menu_block_cb) },
+ { "Unblock", PIDGIN_STOCK_TOOLBAR_UNBLOCK, N_("_Unblock..."), NULL, NULL, G_CALLBACK(menu_unblock_cb) },
+ { "Add", GTK_STOCK_ADD, N_("_Add..."), NULL, NULL, G_CALLBACK(menu_add_remove_cb) },
+ { "Remove", GTK_STOCK_REMOVE, N_("_Remove..."), NULL, NULL, G_CALLBACK(menu_add_remove_cb) },
+ { "InsertLink", PIDGIN_STOCK_TOOLBAR_INSERT_LINK, N_("Insert Lin_k..."), NULL, NULL, G_CALLBACK(menu_insert_link_cb) },
+ { "InsertImage", PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE, N_("Insert Imag_e..."), NULL, NULL, G_CALLBACK(menu_insert_image_cb) },
+ { "Close", GTK_STOCK_CLOSE, N_("_Close"), NULL, NULL, G_CALLBACK(menu_close_conv_cb) },
/* Options */
{ "OptionsMenu", NULL, N_("_Options"), NULL, NULL, NULL },
@@ -3274,10 +3274,10 @@ static GtkActionEntry menu_entries[] =
/* Toggle items */
static const GtkToggleActionEntry menu_toggle_entries[] = {
- { "EnableLogging", NULL, N_("Enable _Logging"), NULL, NULL, menu_logging_cb, FALSE },
- { "EnableSounds", NULL, N_("Enable _Sounds"), NULL, NULL, menu_sounds_cb, FALSE },
- { "ShowFormattingToolbars", NULL, N_("Show Formatting _Toolbars"), NULL, NULL, menu_toolbar_cb, FALSE },
- { "ShowTimestamps", NULL, N_("Show Ti_mestamps"), NULL, NULL, menu_timestamps_cb, FALSE },
+ { "EnableLogging", NULL, N_("Enable _Logging"), NULL, NULL, G_CALLBACK(menu_logging_cb), FALSE },
+ { "EnableSounds", NULL, N_("Enable _Sounds"), NULL, NULL, G_CALLBACK(menu_sounds_cb), FALSE },
+ { "ShowFormattingToolbars", NULL, N_("Show Formatting _Toolbars"), NULL, NULL, G_CALLBACK(menu_toolbar_cb), FALSE },
+ { "ShowTimestamps", NULL, N_("Show Ti_mestamps"), NULL, NULL, G_CALLBACK(menu_timestamps_cb), FALSE },
};
static const char *conversation_menu =
--
cgit v1.2.1
From 36ffbe5d2d534c2e4863420795e13ba95d81d5c6 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 28 Jul 2009 05:38:26 +0000
Subject: Make the conversation UI manager stuff depend on GTK+ 2.6 instead of
2.4, since there would be inconsistencies otherwise.
---
pidgin/gtkconv.c | 70 ++++++++++++++++++++++++++---------------------------
pidgin/gtkconvwin.h | 4 +--
2 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
index 6eb4a016f7..e1ed241be9 100644
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -160,7 +160,7 @@ static void conv_set_unseen(PurpleConversation *gtkconv, PidginUnseenState state
static void gtkconv_set_unseen(PidginConversation *gtkconv, PidginUnseenState state);
static void update_typing_icon(PidginConversation *gtkconv);
static void update_typing_message(PidginConversation *gtkconv, const char *message);
-#if !GTK_CHECK_VERSION(2,4,0)
+#if !GTK_CHECK_VERSION(2,6,0)
static const char *item_factory_translate_func (const char *path, gpointer func_data);
#endif
gboolean pidgin_conv_has_focus(PurpleConversation *conv);
@@ -955,7 +955,7 @@ invite_cb(GtkWidget *widget, PidginConversation *gtkconv)
}
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_new_conv_cb(GtkAction *action, gpointer data)
#else
menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1000,7 +1000,7 @@ savelog_writefile_cb(void *user_data, const char *filename)
* plaintext v. HTML file.
*/
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_save_as_cb(GtkAction *action, gpointer data)
#else
menu_save_as_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1034,7 +1034,7 @@ menu_save_as_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_view_log_cb(GtkAction *action, gpointer data)
#else
menu_view_log_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1065,8 +1065,8 @@ menu_view_log_cb(gpointer data, guint action, GtkWidget *widget)
gdk_window_set_cursor(gtkblist->window->window, cursor);
gdk_window_set_cursor(win->window->window, cursor);
gdk_cursor_unref(cursor);
-#if GTK_CHECK_VERSION(2,4,0)
-//FIXME: gdk_display_flush(gdk_drawable_get_display(GDK_DRAWABLE(widget->window)));
+#if GTK_CHECK_VERSION(2,4,0) && !GTK_CHECK_VERSION(2,6,0) //FIXME: What?
+ gdk_display_flush(gdk_drawable_get_display(GDK_DRAWABLE(widget->window)));
#else
gdk_flush();
#endif
@@ -1096,7 +1096,7 @@ menu_view_log_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_clear_cb(GtkAction *action, gpointer data)
#else
menu_clear_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1161,7 +1161,7 @@ static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s)
}
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_find_cb(GtkAction *action, gpointer data)
#else
menu_find_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1225,7 +1225,7 @@ menu_find_cb(gpointer data, guint action, GtkWidget *widget)
#ifdef USE_VV
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_initiate_media_call_cb(GtkAction *action, gpointer data)
#else
menu_initiate_media_call_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1246,7 +1246,7 @@ menu_initiate_media_call_cb(gpointer data, guint action, GtkWidget *widget)
#endif
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_send_file_cb(GtkAction *action, gpointer data)
#else
menu_send_file_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1262,7 +1262,7 @@ menu_send_file_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_add_pounce_cb(GtkAction *action, gpointer data)
#else
menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1278,7 +1278,7 @@ menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_insert_link_cb(GtkAction *action, gpointer data)
#else
menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1296,7 +1296,7 @@ menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_insert_image_cb(GtkAction *action, gpointer data)
#else
menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1317,7 +1317,7 @@ menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget)
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_alias_cb(GtkAction *action, gpointer data)
#else
menu_alias_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1348,7 +1348,7 @@ menu_alias_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_get_info_cb(GtkAction *action, gpointer data)
#else
menu_get_info_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1363,7 +1363,7 @@ menu_get_info_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_invite_cb(GtkAction *action, gpointer data)
#else
menu_invite_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1378,7 +1378,7 @@ menu_invite_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_block_cb(GtkAction *action, gpointer data)
#else
menu_block_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1393,7 +1393,7 @@ menu_block_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_unblock_cb(GtkAction *action, gpointer data)
#else
menu_unblock_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1408,7 +1408,7 @@ menu_unblock_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_add_remove_cb(GtkAction *action, gpointer data)
#else
menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1457,7 +1457,7 @@ hide_conv(PidginConversation *gtkconv, gboolean closetimer)
}
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_close_conv_cb(GtkAction *action, gpointer data)
#else
menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1469,7 +1469,7 @@ menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_logging_cb(GtkAction *action, gpointer data)
#else
menu_logging_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1485,7 +1485,7 @@ menu_logging_cb(gpointer data, guint action, GtkWidget *widget)
if (conv == NULL)
return;
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
logging = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
#else
logging = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
@@ -1542,7 +1542,7 @@ menu_logging_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_toolbar_cb(GtkAction *action, gpointer data)
{
purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar",
@@ -1557,7 +1557,7 @@ menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget)
#endif
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_sounds_cb(GtkAction *action, gpointer data)
#else
menu_sounds_cb(gpointer data, guint action, GtkWidget *widget)
@@ -1576,7 +1576,7 @@ menu_sounds_cb(gpointer data, guint action, GtkWidget *widget)
gtkconv = PIDGIN_CONVERSATION(conv);
gtkconv->make_sound =
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
#else
gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
@@ -1587,7 +1587,7 @@ menu_sounds_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
menu_timestamps_cb(GtkAction *action, gpointer data)
{
purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps",
@@ -3234,7 +3234,7 @@ pidgin_conv_get_window(PidginConversation *gtkconv)
return gtkconv->win;
}
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
static GtkActionEntry menu_entries[] =
/* TODO: fill out tooltips... */
@@ -3543,7 +3543,7 @@ populate_menu_with_options(GtkWidget *menu, PidginConversation *gtkconv, gboolea
static void
regenerate_options_items(PidginWindow *win)
{
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
#else
GtkWidget *menu;
PidginConversation *gtkconv;
@@ -3582,7 +3582,7 @@ remove_from_list(GtkWidget *widget, PidginWindow *win)
static void
regenerate_plugins_items(PidginWindow *win)
{
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
#else
GList *action_items;
GtkWidget *menu;
@@ -3628,7 +3628,7 @@ regenerate_plugins_items(PidginWindow *win)
#endif
}
-#if !GTK_CHECK_VERSION(2,4,0)
+#if !GTK_CHECK_VERSION(2,6,0)
static void menubar_activated(GtkWidget *item, gpointer data)
{
PidginWindow *win = data;
@@ -3659,7 +3659,7 @@ setup_menubar(PidginWindow *win)
GtkAccelGroup *accel_group;
const char *method;
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
GtkActionGroup *action_group;
GError *error;
@@ -4095,7 +4095,7 @@ update_send_to_selection(PidginWindow *win)
if (!(b = purple_find_buddy(account, conv->name)))
return FALSE;
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
#else
gtk_widget_show(win->menu.send_to);
@@ -4229,7 +4229,7 @@ compare_buddy_presence(PurplePresence *p1, PurplePresence *p2)
static void
generate_send_to_items(PidginWindow *win)
{
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
#else
GtkWidget *menu;
GSList *group = NULL;
@@ -8938,7 +8938,7 @@ infopane_press_cb(GtkWidget *widget, GdkEventButton *e, PidginConversation *gtkc
/* Right click was pressed. Popup the context menu. */
GtkWidget *menu = gtk_menu_new(), *sub;
gboolean populated = populate_menu_with_options(menu, gtkconv, TRUE);
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
#else
sub = gtk_menu_item_get_submenu(GTK_MENU_ITEM(gtkconv->win->menu.send_to));
@@ -9752,7 +9752,7 @@ pidgin_conv_window_destroy(PidginWindow *win)
}
gtk_widget_destroy(win->window);
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
g_object_unref(G_OBJECT(win->menu.ui));
#else
g_object_unref(G_OBJECT(win->menu.item_factory));
diff --git a/pidgin/gtkconvwin.h b/pidgin/gtkconvwin.h
index e440502302..5dc0718949 100644
--- a/pidgin/gtkconvwin.h
+++ b/pidgin/gtkconvwin.h
@@ -100,7 +100,7 @@ struct _PidginWindow
GtkWidget *typing_icon;
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
GtkUIManager *ui;
#else
GtkItemFactory *item_factory;
@@ -126,7 +126,7 @@ struct _PidginWindow
gint drag_leave_signal;
/* Media menu options. */
-#if GTK_CHECK_VERSION(2,4,0)
+#if GTK_CHECK_VERSION(2,6,0)
GtkAction *audio_call;
GtkAction *video_call;
GtkAction *audio_video_call;
--
cgit v1.2.1
From ae7365b6aabecca49894b628e34462606be4379a Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 28 Jul 2009 05:47:09 +0000
Subject: Fix media call initiation for UI manager.
---
pidgin/gtkconv.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
index e1ed241be9..7a871e9342 100644
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -1227,15 +1227,25 @@ menu_find_cb(gpointer data, guint action, GtkWidget *widget)
static void
#if GTK_CHECK_VERSION(2,6,0)
menu_initiate_media_call_cb(GtkAction *action, gpointer data)
+{
+ PidginWindow *win = (PidginWindow *)data;
+ PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
+ PurpleAccount *account = purple_conversation_get_account(conv);
+
+ purple_prpl_initiate_media(account,
+ purple_conversation_get_name(conv),
+ action == win->audio_call ? PURPLE_MEDIA_AUDIO :
+ action == win->video_call ? PURPLE_MEDIA_VIDEO :
+ action == win->audio_video_call ? PURPLE_MEDIA_AUDIO |
+ PURPLE_MEDIA_VIDEO : PURPLE_MEDIA_NONE);
+}
#else
menu_initiate_media_call_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = (PidginWindow *)data;
PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
PurpleAccount *account = purple_conversation_get_account(conv);
- /* FIXME: action is not an int... */
purple_prpl_initiate_media(account,
purple_conversation_get_name(conv),
action == 0 ? PURPLE_MEDIA_AUDIO :
@@ -1244,6 +1254,7 @@ menu_initiate_media_call_cb(gpointer data, guint action, GtkWidget *widget)
PURPLE_MEDIA_VIDEO : PURPLE_MEDIA_NONE);
}
#endif
+#endif
static void
#if GTK_CHECK_VERSION(2,6,0)
--
cgit v1.2.1
From 5389acce1d689b91e13de3cd27efda11fe81b309 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Wed, 29 Jul 2009 04:17:40 +0000
Subject: Fix copy+paste typo. Doesn't seem to make a real difference though.
---
pidgin/gtkblist.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index 2ca1cc4eb6..7469baa226 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -8461,7 +8461,7 @@ pidgin_blist_update_plugin_actions(void)
g_object_unref(G_OBJECT(plugins_action_group));
}
- plugins_action_group = gtk_action_group_new("Accounts");
+ plugins_action_group = gtk_action_group_new("PluginActions");
#ifdef ENABLE_NLS
gtk_action_group_set_translation_domain(plugins_action_group, PACKAGE);
#endif
--
cgit v1.2.1
From 7738f802db646f3df75ba2195d393ef8cccab3c5 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Fri, 7 Aug 2009 18:27:41 +0000
Subject: Apparently I missed these in my previous commit. Also changed the
gtkwebview.h to be javadoc'ed.
---
pidgin/gtkwebview.c | 264 ++++++++++++++++++++++++++++++++++++++++++++++++++++
pidgin/gtkwebview.h | 146 +++++++++++++++++++++++++++++
2 files changed, 410 insertions(+)
create mode 100644 pidgin/gtkwebview.c
create mode 100644 pidgin/gtkwebview.h
diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
new file mode 100644
index 0000000000..1c3dc1057e
--- /dev/null
+++ b/pidgin/gtkwebview.c
@@ -0,0 +1,264 @@
+
+#include
+#include
+#include
+#include
+#include
+
+#include "util.h"
+#include "gtkwebview.h"
+
+static WebKitWebViewClass *parent_class = NULL;
+
+GtkWidget* gtk_webview_new ()
+{
+ return GTK_WIDGET(g_object_new(gtk_webview_get_type(), NULL));
+}
+
+static char*
+get_img_filename_by_id (GtkWebView* view, int id)
+{
+ char *filename = NULL;
+ FILE *file;
+ PurpleStoredImage* img;
+
+ if (!view->images)
+ view->images = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
+
+ filename = (char*) g_hash_table_lookup (view->images, GINT_TO_POINTER (id));
+ if (filename) return filename;
+
+ /* else get from img store */
+ file = purple_mkstemp (&filename, TRUE);
+
+ img = purple_imgstore_find_by_id (id);
+
+ fwrite (purple_imgstore_get_data (img), purple_imgstore_get_size (img), 1, file);
+ g_hash_table_insert (view->images, GINT_TO_POINTER (id), filename);
+ fclose (file);
+ return filename;
+}
+
+static void
+clear_single_image (gpointer key, gpointer value, gpointer userdata)
+{
+ g_unlink ((char*) value);
+}
+
+static void
+clear_images (GtkWebView* view)
+{
+ if (!view->images) return;
+ g_hash_table_foreach (view->images, clear_single_image, NULL);
+ g_hash_table_unref (view->images);
+}
+
+/*
+ * Replace all tags with . I hoped to never
+ * write any HTML parsing code, but I'm forced to do this, until
+ * purple changes the way it works.
+ */
+static char*
+replace_img_id_with_src (GtkWebView *view, const char* html)
+{
+ GString *buffer = g_string_sized_new (strlen (html));
+ const char* cur = html;
+ char *id;
+ int nid;
+
+ while (*cur) {
+ const char* img = strstr (cur, "");
+ if (!cur)
+ cur = strstr (img, ">");
+
+ if (!cur) { /*oops, invalid html */
+ g_string_printf (buffer, "%s", html);
+ break;
+ }
+
+ if (strstr (img, "src=") || !strstr (img, "id=")) {
+ g_string_printf (buffer, "%s", html);
+ break;
+ }
+
+ /* now I _kinda_ know that it has an id=, and does not have a src= */
+ /* todo: take care of src= and id= appearing in strings? */
+ id = strstr (img, "id=") + 3;
+
+ /* *id can't be \0, since a ">" appears after this */
+ if (isdigit (*id))
+ nid = atoi (id);
+ else
+ nid = atoi (id+1);
+
+ /* let's dump this, tag and then dump the src information */
+ g_string_append_len (buffer, img, cur - img);
+
+ g_string_append_printf (buffer, " src='file://%s' ", get_img_filename_by_id (view, nid));
+ }
+ return g_string_free (buffer, FALSE);
+}
+
+static void
+gtk_webview_finalize (GObject *view)
+{
+ clear_images (GTK_WEBVIEW (view));
+ G_OBJECT_CLASS (parent_class)->finalize (G_OBJECT(view));
+}
+
+static void
+gtk_webview_class_init (GtkWebViewClass *klass, gpointer userdata)
+{
+ parent_class = g_type_class_ref (webkit_web_view_get_type ());
+ G_OBJECT_CLASS (klass)->finalize = gtk_webview_finalize;
+}
+
+static gboolean
+webview_link_clicked (WebKitWebView *view,
+ WebKitWebFrame *frame,
+ WebKitNetworkRequest *request,
+ WebKitWebNavigationAction *navigation_action,
+ WebKitWebPolicyDecision *policy_decision)
+{
+ const gchar *uri;
+
+ uri = webkit_network_request_get_uri (request);
+
+ /* the gtk imhtml way was to create an idle cb, not sure
+ * why, so right now just using purple_notify_uri directly */
+ purple_notify_uri (NULL, uri);
+ return TRUE;
+}
+
+char*
+gtk_webview_execute_script (GtkWebView *view, const char *script)
+{
+ JSStringRef js_script = JSStringCreateWithUTF8CString (script);
+ JSContextRef ctxt = webkit_web_frame_get_global_context (
+ webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view))
+ );
+ JSValueRef ret = JSEvaluateScript (ctxt, js_script, NULL, NULL, 0, NULL);
+ JSStringRef ret_as_str = JSValueToStringCopy (ctxt, ret, NULL);
+
+ size_t cstr_len = JSStringGetMaximumUTF8CStringSize (ret_as_str);
+ char *cstr = g_new0(char, cstr_len + 1);
+
+ JSStringGetUTF8CString (ret_as_str, cstr, cstr_len);
+
+ /* TODO: I'm not sure what, if at all, I need to free here! */
+ return cstr;
+}
+
+static void
+gtk_webview_init (GtkWebView *view, gpointer userdata)
+{
+ g_signal_connect (view, "navigation-policy-decision-requested",
+ G_CALLBACK (webview_link_clicked),
+ view);
+ view->empty = TRUE;
+}
+
+
+void
+gtk_webview_load_html_string_with_imgstore (GtkWebView* view, const char* html)
+{
+ char* html_imged;
+
+ clear_images (view);
+ html_imged = replace_img_id_with_src (view, html);
+ printf ("%s\n", html_imged);
+ webkit_web_view_load_html_string (WEBKIT_WEB_VIEW (view), html_imged, "file:///");
+ g_free (html_imged);
+}
+
+/* taken from sean's webkit plugin */
+char *gtk_webview_quote_js_string(const char *text)
+{
+ GString *str = g_string_new("\"");
+ const char *cur = text;
+
+ while (cur && *cur) {
+ switch (*cur) {
+ case '\\':
+ g_string_append(str, "\\\\");
+ break;
+ case '\"':
+ g_string_append(str, "\\\"");
+ break;
+ case '\r':
+ g_string_append(str, "
");
+ break;
+ case '\n':
+ break;
+ default:
+ g_string_append_c(str, *cur);
+ }
+ cur ++;
+ }
+ g_string_append_c (str, '"');
+ return g_string_free (str, FALSE);
+}
+
+
+/* this is a "hack", my plan is to eventually handle this
+ * correctly using a signals and a plugin: the plugin will have
+ * the information as to what javascript function to call. It seems
+ * wrong to hardcode that here.
+ */
+void
+gtk_webview_append_html (GtkWebView* view, const char* html)
+{
+ char* escaped = gtk_webview_quote_js_string (html);
+ char* script = g_strdup_printf ("document.write(%s)", escaped);
+ printf ("script: %s\n", script);
+ webkit_web_view_execute_script (WEBKIT_WEB_VIEW (view), script);
+ view->empty = FALSE;
+ g_free (script);
+ g_free (escaped);
+}
+
+char*
+gtk_webview_get_markup (GtkWebView *view)
+{
+ return gtk_webview_execute_script (view, "document.body.innerHTML");
+}
+
+char*
+gtk_webview_get_text (GtkWebView *view)
+{
+ return gtk_webview_execute_script (view, "document.body.textContent");
+}
+
+gboolean gtk_webview_is_empty (GtkWebView *view)
+{
+ return view->empty;
+}
+
+GType gtk_webview_get_type ()
+{
+ static GType mview_type = 0;
+ if (!mview_type) {
+ static const GTypeInfo mview_info = {
+ sizeof (GtkWebViewClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) gtk_webview_class_init,
+ NULL,
+ NULL,
+ sizeof (GtkWebView),
+ 0,
+ (GInstanceInitFunc) gtk_webview_init,
+ NULL
+ };
+ mview_type = g_type_register_static(webkit_web_view_get_type (),
+ "GtkWebView", &mview_info, 0);
+ }
+ return mview_type;
+}
diff --git a/pidgin/gtkwebview.h b/pidgin/gtkwebview.h
new file mode 100644
index 0000000000..bd0df4c770
--- /dev/null
+++ b/pidgin/gtkwebview.h
@@ -0,0 +1,146 @@
+/**
+ * @file gtkwebview.h Wrapper over the Gtk WebKitWebView component
+ * @ingroup pidgin
+ */
+
+/* Pidgin is the legal property of its developers, whose names are too numerous
+ * to list here. Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+
+#ifndef _PIDGIN_WEBVIEW_H_
+#define _PIDGIN_WEBVIEW_H_
+
+#include
+#include
+#include
+
+#include "notify.h"
+
+#define GTK_TYPE_WEBVIEW (gtk_webview_get_type())
+#define GTK_WEBVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_WEBVIEW, GtkWebView))
+#define GTK_WEBVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_WEBVIEW, GtkWebViewClass))
+#define GTK_IS_WEBVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_WEBVIEW))
+#define GTK_IS_IMHTML_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_WEBVIEW))
+
+
+struct _GtkWebView
+{
+ WebKitWebView webkit_web_view;
+
+ /*< private >*/
+ GHashTable *images; /**< a map from id to temporary file for the image */
+ gboolean empty; /**< whether anything has been appended **/
+ char *script_return; /**< the last value returned from a script **/
+};
+
+typedef struct _GtkWebView GtkWebView;
+
+struct _GtkWebViewClass
+{
+ WebKitWebViewClass parent;
+};
+
+typedef struct _GtkWebViewClass GtkWebViewClass;
+
+
+/**
+ * Returns the GType for a GtkWebView widget
+ *
+ * @return the GType for GtkWebView widget
+ */
+GType gtk_webview_get_type ();
+
+/**
+ * Create a new GtkWebView object
+ *
+ * @return a GtkWidget corresponding to the GtkWebView object
+ */
+GtkWidget* gtk_webview_new ();
+
+/**
+ * A very basic routine to append html, which can be considered
+ * equivalent to a "document.write" using JavaScript.
+ *
+ * @param webview The GtkWebView object
+ * @param markup The html markup to append
+ */
+void gtk_webview_append_html (GtkWebView *webview, const char* markup);
+
+/**
+ * Rather than use webkit_webview_load_string, this routine
+ * parses and displays the tags that make use of the
+ * Pidgin imgstore.
+ *
+ * @param webview The GtkWebView object
+ * @param html The HTML content to load
+ */
+void gtk_webview_load_html_string_with_imgstore (GtkWebView* webview, const char* html);
+
+/**
+ * (To be changed, right now it just tests whether an append has been
+ * called since the last clear or since the Widget was created. So it
+ * does not test for load_string's called in between.
+ *
+ * @param webview The GtkWebView object
+ *
+ * @return gboolean indicating whether the webview is empty.
+ */
+gboolean gtk_webview_is_empty (GtkWebView *webview);
+
+/**
+ * Executes javascript and returns the answer of the script
+ * formatted as string. The return value needs to be freed using
+ * g_free. If the return values is not required you may instead
+ * use webkit_web_view_execute_script.
+ *
+ * @param webview The GtkWebView object
+ * @param script The JavaScript to execute
+ *
+ * @return the return value of the script.
+ */
+char* gtk_webview_execute_script (GtkWebView *webview, const char *script);
+
+/**
+ * Get the current contents of the GtkWebView object.
+ *
+ * @param webview The GtkWebView object
+ *
+ * @return a string with the contents. Needs to be g_free'd after use.
+ */
+char* gtk_webview_get_markup (GtkWebView *webview);
+
+/**
+ * Returns the contents of the GtkWebView object, stripped of markups
+ *
+ * @param webview The GtkWebView object
+ *
+ * @return a string with the contents. Needs to be g_free'd after use.
+ */
+char* gtk_webview_get_text (GtkWebView *view);
+
+/**
+ * A convenience routine to quote a string for use as a JavaScript
+ * string. For instance, "hello 'world'" becomes "'hello \\'world\\''"
+ *
+ * @param str The string to escape and quote
+ *
+ * @return the quoted string.
+ */
+char* gtk_webview_quote_js_string (const char* str);
+
+#endif /* _PIDGIN_WEBVIEW_H_ */
--
cgit v1.2.1
From dbb2b0b514522a53b4c4868f871694a6a6537b90 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Fri, 7 Aug 2009 18:29:52 +0000
Subject: other files that missed my main major commit.
---
pidgin/plugins/adiumthemes/Makefile.am | 28 ++
pidgin/plugins/adiumthemes/Template.html | 164 +++++++
pidgin/plugins/adiumthemes/webkit.c | 738 +++++++++++++++++++++++++++++++
3 files changed, 930 insertions(+)
create mode 100644 pidgin/plugins/adiumthemes/Makefile.am
create mode 100644 pidgin/plugins/adiumthemes/Template.html
create mode 100644 pidgin/plugins/adiumthemes/webkit.c
diff --git a/pidgin/plugins/adiumthemes/Makefile.am b/pidgin/plugins/adiumthemes/Makefile.am
new file mode 100644
index 0000000000..e9d0b8a5d6
--- /dev/null
+++ b/pidgin/plugins/adiumthemes/Makefile.am
@@ -0,0 +1,28 @@
+
+webkittemplatedir = $(datadir)/pidgin/webkit
+webkittemplate_DATA = Template.html
+
+webkitdir = $(libdir)/pidgin
+
+webkit_la_LDFLAGS = -module -avoid-version
+
+EXTRA_DIST = $(webkittemplate_DATA)
+
+if PLUGINS
+
+webkit_LTLIBRARIES = webkit.la
+
+webkit_la_SOURCES = webkit.c
+
+endif
+
+webkit_la_LIBADD = $(GTK_LIBS) $(WEBKIT_LIBS)
+
+AM_CPPFLAGS = \
+ -DDATADIR=\"$(datadir)\" \
+ -I$(top_srcdir)/libpurple \
+ -I$(top_builddir)/libpurple \
+ -I$(top_srcdir)/pidgin \
+ $(DEBUG_CFLAGS) \
+ $(GTK_CFLAGS) \
+ $(WEBKIT_CFLAGS)
diff --git a/pidgin/plugins/adiumthemes/Template.html b/pidgin/plugins/adiumthemes/Template.html
new file mode 100644
index 0000000000..0a7f9d6662
--- /dev/null
+++ b/pidgin/plugins/adiumthemes/Template.html
@@ -0,0 +1,164 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+%@
+
+
+%@
+
+
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
new file mode 100644
index 0000000000..7a6b96b2a6
--- /dev/null
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -0,0 +1,738 @@
+/*
+ * Adium Webkit views
+ * Copyright (C) 2007
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+/* This plugins is basically Sadrul's x-chat plugin, but with Webkit
+ * instead of xtext.
+ */
+
+#define PLUGIN_ID "gtk-webview-adium-ims"
+#define PLUGIN_NAME "webview-adium-ims"
+#define PLUGIN_AUTHOR "Sean Egan "
+#define PURPLE_PLUGINS "Hell yeah"
+
+/* System headers */
+#include
+#include
+#include
+
+#include
+
+/* Purple headers */
+#include
+#include
+#include
+#include
+
+/* Pidgin headers */
+#include
+#include
+#include
+
+static PurpleConversationUiOps *uiops = NULL;
+
+static void (*default_write_conv)(PurpleConversation *conv, const char *name, const char *alias,
+ const char *message, PurpleMessageFlags flags, time_t mtime);
+static void (*default_create_conversation)(PurpleConversation *conv);
+
+static void (*default_destroy_conversation)(PurpleConversation *conv);
+
+/* Cache the contents of the HTML files */
+char *template_html = NULL; /* This is the skeleton: some basic javascript mostly */
+char *header_html = NULL; /* This is the first thing to be appended to any conversation */
+char *footer_html = NULL; /* This is the last thing appended to the conversation */
+char *incoming_content_html = NULL; /* This is a received message */
+char *outgoing_content_html = NULL; /* And a sent one */
+char *incoming_next_content_html = NULL; /* The same things, but used when someone sends multiple subsequent */
+char *outgoing_next_content_html = NULL; /* messages in a row */
+char *status_html = NULL; /* Non-IM status messages */
+char *basestyle_css = NULL; /* Shared CSS attributes */
+
+/* Cache their lenghts too, to pass into g_string_new_len, avoiding crazy allocation */
+gsize template_html_len = 0;
+gsize header_html_len = 0;
+gsize footer_html_len = 0;
+gsize incoming_content_html_len = 0;
+gsize outgoing_content_html_len = 0;
+gsize incoming_next_content_html_len = 0;
+gsize outgoing_next_content_html_len = 0;
+gsize status_html_len = 0;
+gsize basestyle_css_len = 0;
+
+/* And their paths */
+char *style_dir = NULL;
+char *template_path = NULL;
+char *css_path = NULL;
+
+static char *
+replace_message_tokens(char *text, gsize len, PurpleConversation *conv, const char *name, const char *alias,
+ const char *message, PurpleMessageFlags flags, time_t mtime)
+{
+ GString *str = g_string_new_len(NULL, len);
+ char *cur = text;
+ char *prev = cur;
+
+ while ((cur = strchr(cur, '%'))) {
+ const char *replace = NULL;
+ char *fin = NULL;
+
+ if (!strncmp(cur, "%message%", strlen("%message%"))) {
+ replace = message;
+ } else if (!strncmp(cur, "%messageClasses%", strlen("%messageClasses%"))) {
+ replace = flags & PURPLE_MESSAGE_SEND ? "outgoing" :
+ flags & PURPLE_MESSAGE_RECV ? "incoming" : "event";
+ } else if (!strncmp(cur, "%time", strlen("%time"))) {
+ char *format = NULL;
+ if (*(cur + strlen("%time")) == '{') {
+ char *start = cur + strlen("%time") + 1;
+ char *end = strstr(start, "}%");
+ if (!end) /* Invalid string */
+ continue;
+ format = g_strndup(start, end - start);
+ fin = end + 1;
+ }
+ replace = purple_utf8_strftime(format ? format : "%X", NULL);
+ g_free(format);
+ } else if (!strncmp(cur, "%userIconPath%", strlen("%userIconPath%"))) {
+ if (flags & PURPLE_MESSAGE_SEND) {
+ if (purple_account_get_bool(conv->account, "use-global-buddyicon", TRUE)) {
+ replace = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon");
+ } else {
+ PurpleStoredImage *img = purple_buddy_icons_find_account_icon(conv->account);
+ replace = purple_imgstore_get_filename(img);
+ }
+ if (replace == NULL || !g_file_test(replace, G_FILE_TEST_EXISTS)) {
+ replace = g_build_filename("Outgoing", "buddy_icon.png", NULL);
+ }
+ } else if (flags & PURPLE_MESSAGE_RECV) {
+ PurpleBuddyIcon *icon = purple_conv_im_get_icon(PURPLE_CONV_IM(conv));
+ replace = purple_buddy_icon_get_full_path(icon);
+ if (replace == NULL || !g_file_test(replace, G_FILE_TEST_EXISTS)) {
+ replace = g_build_filename("Incoming", "buddy_icon.png", NULL);
+ }
+ }
+
+ } else if (!strncmp(cur, "%senderScreenName%", strlen("%senderScreenName%"))) {
+ replace = name;
+ } else if (!strncmp(cur, "%sender%", strlen("%sender%"))) {
+ replace = alias;
+ } else if (!strncmp(cur, "%service%", strlen("%service%"))) {
+ replace = purple_account_get_protocol_name(conv->account);
+ } else {
+ cur++;
+ continue;
+ }
+
+ /* Here we have a replacement to make */
+ g_string_append_len(str, prev, cur - prev);
+ g_string_append(str, replace);
+
+ /* And update the pointers */
+ if (fin) {
+ prev = cur = fin + 1;
+ } else {
+ prev = cur = strchr(cur + 1, '%') + 1;
+ }
+
+ }
+
+ /* And wrap it up */
+ g_string_append(str, prev);
+ return g_string_free(str, FALSE);
+}
+
+static char *
+replace_header_tokens(char *text, gsize len, PurpleConversation *conv)
+{
+ GString *str = g_string_new_len(NULL, len);
+ char *cur = text;
+ char *prev = cur;
+
+ if (text == NULL)
+ return NULL;
+
+ while ((cur = strchr(cur, '%'))) {
+ const char *replace = NULL;
+ char *fin = NULL;
+
+ if (!strncmp(cur, "%chatName%", strlen("%chatName%"))) {
+ replace = conv->name;
+ } else if (!strncmp(cur, "%sourceName%", strlen("%sourceName%"))) {
+ replace = purple_account_get_alias(conv->account);
+ if (replace == NULL)
+ replace = purple_account_get_username(conv->account);
+ } else if (!strncmp(cur, "%destinationName%", strlen("%destinationName%"))) {
+ PurpleBuddy *buddy = purple_find_buddy(conv->account, conv->name);
+ if (buddy) {
+ replace = purple_buddy_get_alias(buddy);
+ } else {
+ replace = conv->name;
+ }
+ } else if (!strncmp(cur, "%incomingIconPath%", strlen("%incomingIconPath%"))) {
+ PurpleBuddyIcon *icon = purple_conv_im_get_icon(PURPLE_CONV_IM(conv));
+ replace = purple_buddy_icon_get_full_path(icon);
+ } else if (!strncmp(cur, "%outgoingIconPath%", strlen("%outgoingIconPath%"))) {
+ } else if (!strncmp(cur, "%timeOpened", strlen("%timeOpened"))) {
+ char *format = NULL;
+ if (*(cur + strlen("%timeOpened")) == '{') {
+ char *start = cur + strlen("%timeOpened") + 1;
+ char *end = strstr(start, "}%");
+ if (!end) /* Invalid string */
+ continue;
+ format = g_strndup(start, end - start);
+ fin = end + 1;
+ }
+ replace = purple_utf8_strftime(format ? format : "%X", NULL);
+ g_free(format);
+ } else {
+ // cur++;
+ continue;
+ }
+
+ /* Here we have a replacement to make */
+ g_string_append_len(str, prev, cur - prev);
+ g_string_append(str, replace);
+
+ /* And update the pointers */
+ if (fin) {
+ prev = cur = fin + 1;
+ } else {
+ prev = cur = strchr(cur + 1, '%') + 1;
+ }
+ }
+
+ /* And wrap it up */
+ g_string_append(str, prev);
+ return g_string_free(str, FALSE);
+}
+
+static char *
+replace_template_tokens(char *text, int len, char *header, char *footer) {
+ GString *str = g_string_new_len(NULL, len);
+
+ char **ms = g_strsplit(text, "%@", 6);
+ char *base = NULL;
+
+ if (ms[0] == NULL || ms[1] == NULL || ms[2] == NULL || ms[3] == NULL || ms[4] == NULL || ms[5] == NULL) {
+ g_strfreev(ms);
+ g_string_free(str, TRUE);
+ return NULL;
+ }
+
+ g_string_append(str, ms[0]);
+ g_string_append(str, "file://");
+ base = g_build_filename (style_dir, "Contents", "Resources", "Template.html", NULL);
+ g_string_append(str, base);
+ g_free (base);
+
+ g_string_append(str, ms[1]);
+ if (basestyle_css)
+ g_string_append(str, basestyle_css);
+ g_string_append(str, ms[2]);
+ if (css_path) {
+ g_string_append(str, "file://");
+ g_string_append(str, css_path);
+ }
+
+ g_string_append(str, ms[3]);
+ if (header)
+ g_string_append(str, header);
+ g_string_append(str, ms[4]);
+ if (footer)
+ g_string_append(str, footer);
+ g_string_append(str, ms[5]);
+
+ g_strfreev(ms);
+ return g_string_free (str, FALSE);
+}
+
+static GtkWidget *
+get_webkit(PurpleConversation *conv)
+{
+ PidginConversation *gtkconv;
+ gtkconv = PIDGIN_CONVERSATION(conv);
+ if (!gtkconv)
+ return NULL;
+ else
+ return gtkconv->webview;
+}
+static void
+init_theme_for_webkit (PurpleConversation *conv)
+{
+ GtkWidget *webkit = PIDGIN_CONVERSATION(conv)->webview;
+ char *header, *footer;
+ char *template;
+
+ char* basedir = g_build_filename (style_dir, "Contents", "Resources", "Template.html", NULL);
+ char* baseuri = g_strdup_printf ("file://%s", basedir);
+
+ header = replace_header_tokens(header_html, header_html_len, conv);
+ footer = replace_header_tokens(footer_html, footer_html_len, conv);
+ template = replace_template_tokens(template_html, template_html_len + header_html_len, header, footer);
+
+ if (!g_object_get_data (G_OBJECT(webkit), "adium-themed"))
+ webkit_web_view_load_string(WEBKIT_WEB_VIEW(webkit), template, "text/html", "UTF-8", baseuri);
+
+ g_object_set_data (G_OBJECT(webkit), "adium-themed", GINT_TO_POINTER(1));
+ g_free (basedir);
+ g_free (baseuri);
+ g_free (header);
+ g_free (footer);
+ g_free (template);
+}
+
+
+/* restore the non theme version of the conversation window */
+static void
+finalize_theme_for_webkit (PurpleConversation *conv)
+{
+ GtkWidget *webview = PIDGIN_CONVERSATION(conv)->webview;
+ webkit_web_view_load_string(WEBKIT_WEB_VIEW(webview), "", "text/html", "UTF-8", "");
+ g_object_set_data (G_OBJECT(webview), "adium-themed", NULL);
+}
+
+static char *
+escape_message(char *text)
+{
+ GString *str = g_string_new(NULL);
+ char *cur = text;
+
+ while (cur && *cur) {
+ switch (*cur) {
+ case '\\':
+ g_string_append(str, "\\\\");
+ break;
+ case '\"':
+ g_string_append(str, "\\\"");
+ break;
+ case '\r':
+ g_string_append(str, "
");
+ break;
+ case '\n':
+ break;
+ default:
+ g_string_append_c(str, *cur);
+ }
+ cur++;
+ }
+ return g_string_free(str, FALSE);
+}
+
+struct webkit_script {
+ GtkWidget *webkit;
+ char *script;
+};
+
+static gboolean purple_webkit_execute_script(gpointer _script)
+{
+ struct webkit_script *script = (struct webkit_script*) _script;
+ printf ("%s\n", script->script);
+ webkit_web_view_execute_script(WEBKIT_WEB_VIEW(script->webkit), script->script);
+ g_free(script->script);
+ g_free(script);
+ return FALSE;
+}
+
+static void purple_webkit_write_conv(PurpleConversation *conv, const char *name, const char *alias,
+ const char *message, PurpleMessageFlags flags, time_t mtime)
+{
+ PurpleConversationType type;
+ GtkWidget *webkit;
+ char *stripped;
+ char *message_html;
+ char *msg;
+ char *escape;
+ char *script;
+ char *func = "appendMessage";
+ char *smileyed;
+ struct webkit_script *wk_script;
+ PurpleMessageFlags old_flags = GPOINTER_TO_INT(purple_conversation_get_data(conv, "webkit-lastflags"));
+
+ /* Don't call the usual stuff first. */
+ //default_write_conv(conv, name, alias, message, flags, mtime);
+ type = purple_conversation_get_type(conv);
+ if (type != PURPLE_CONV_TYPE_IM)
+ {
+ /* If it's chat, we have nothing to do. */
+ return;
+ }
+ /* So it's an IM. Let's play. */
+
+ webkit = get_webkit(conv);
+ stripped = g_strdup(message); //purple_markup_strip_html(message);
+
+ if (flags & PURPLE_MESSAGE_SEND && old_flags & PURPLE_MESSAGE_SEND) {
+ message_html = outgoing_next_content_html;
+ func = "appendNextMessage";
+ } else if (flags & PURPLE_MESSAGE_SEND) {
+ message_html = outgoing_content_html;
+ } else if (flags & PURPLE_MESSAGE_RECV && old_flags & PURPLE_MESSAGE_RECV) {
+ message_html = incoming_next_content_html;
+ func = "appendNextMessage";
+ } else if (flags & PURPLE_MESSAGE_RECV) {
+ message_html = incoming_content_html;
+ } else {
+ message_html = status_html;
+ }
+ purple_conversation_set_data(conv, "webkit-lastflags", GINT_TO_POINTER(flags));
+
+ smileyed = smiley_parse_markup(stripped, conv->account->protocol_id);
+ msg = replace_message_tokens(message_html, 0, conv, name, alias, smileyed, flags, mtime);
+ escape = escape_message(msg);
+ script = g_strdup_printf("%s(\"%s\")", func, escape);
+
+ wk_script = g_new0(struct webkit_script, 1);
+ wk_script->script = script;
+ wk_script->webkit = webkit;
+
+ g_idle_add(purple_webkit_execute_script, wk_script);
+
+ g_free(smileyed);
+ g_free(msg);
+ g_free(stripped);
+ g_free(escape);
+}
+
+
+static void
+purple_webkit_create_conv(PurpleConversation *conv)
+{
+ default_create_conversation(conv);
+ init_theme_for_webkit(conv);
+}
+
+static void
+purple_webkit_destroy_conv(PurpleConversation *conv)
+{
+ default_destroy_conversation(conv);
+}
+
+static GList*
+get_theme_files()
+{
+ GList *ret = NULL;
+ GDir *variants;
+ char *globe = g_build_filename(DATADIR, "pidgin", "webkit", "styles", NULL);
+ const char *css_file;
+ char *css;
+
+ if (style_dir != NULL) {
+ char *variant_dir = g_build_filename(style_dir, "Contents", "Resources", "Variants", NULL);
+ variants = g_dir_open(variant_dir, 0, NULL);
+ while ((css_file = g_dir_read_name(variants)) != NULL) {
+ if (!strstr(css_file, ".css")) {
+ continue;
+ }
+ css = g_build_filename(variant_dir, css_file, NULL);
+ ret = g_list_append(ret,css);
+ }
+ g_dir_close(variants);
+ g_free(variant_dir);
+ }
+ g_free(globe);
+
+ ret = g_list_sort (ret, (GCompareFunc)g_strcmp0);
+ return ret;
+}
+
+static void
+variant_set_default ()
+{
+
+ GList* all;
+ GList* copy;
+ css_path = g_strdup (purple_prefs_get_string ("/plugins/gtk/adiumthemes/csspath"));
+
+ if (g_file_test (css_path, G_FILE_TEST_EXISTS))
+ return;
+ else {
+ g_free (css_path);
+ css_path = NULL;
+ }
+
+ all = get_theme_files ();
+ copy = all;
+ if (css_path) {
+ g_free (css_path);
+ css_path = NULL;
+ }
+ if (all) {
+ css_path = g_strdup (all->data);
+ purple_prefs_set_string ("/plugins/gtk/adiumthemes/csspath", css_path);
+ }
+
+ while (all) {
+ g_free (all->data);
+ all = g_list_next(all);
+ }
+ g_list_free (copy);
+}
+
+static gboolean
+plugin_load(PurplePlugin *plugin)
+{
+ char *file;
+
+ if (g_path_is_absolute (purple_user_dir()))
+ style_dir = g_build_filename(purple_user_dir(), "style", NULL);
+ else {
+ char* cur = g_get_current_dir ();
+ style_dir = g_build_filename (cur, purple_user_dir(), "style", NULL);
+ g_free (cur);
+ }
+
+ variant_set_default ();
+ if (!css_path)
+ return FALSE;
+
+
+ template_path = g_build_filename(style_dir, "Contents", "Resources", "Template.html", NULL);
+ if (!g_file_test(template_path, G_FILE_TEST_EXISTS)) {
+ g_free(template_path);
+ template_path = g_build_filename(DATADIR, "pidgin", "webkit", "Template.html", NULL);
+ }
+ if (!g_file_get_contents(template_path, &template_html, &template_html_len, NULL))
+ return FALSE;
+
+ file = g_build_filename(style_dir, "Contents", "Resources", "Header.html", NULL);
+ g_file_get_contents(file, &header_html, &header_html_len, NULL);
+
+ file = g_build_filename(style_dir, "Contents", "Resources", "Footer.html", NULL);
+ g_file_get_contents(file, &footer_html, &footer_html_len, NULL);
+
+ file = g_build_filename(style_dir, "Contents", "Resources", "Incoming", "Content.html", NULL);
+ if (!g_file_get_contents(file, &incoming_content_html, &incoming_content_html_len, NULL))
+ return FALSE;
+
+ file = g_build_filename(style_dir, "Contents", "Resources", "Incoming", "NextContent.html", NULL);
+ if (!g_file_get_contents(file, &incoming_next_content_html, &incoming_next_content_html_len, NULL)) {
+ incoming_next_content_html = incoming_content_html;
+ incoming_next_content_html_len = incoming_content_html_len;
+ }
+
+ file = g_build_filename(style_dir, "Contents", "Resources", "Outgoing", "Content.html", NULL);
+ if (!g_file_get_contents(file, &outgoing_content_html, &outgoing_content_html_len, NULL)) {
+ outgoing_content_html = incoming_content_html;
+ outgoing_content_html_len = incoming_content_html_len;
+ }
+
+ file = g_build_filename(style_dir, "Contents", "Resources", "Outgoing", "NextContent.html", NULL);
+ if (!g_file_get_contents(file, &outgoing_next_content_html, &outgoing_next_content_html_len, NULL)) {
+ outgoing_next_content_html = outgoing_content_html;
+ outgoing_next_content_html_len = outgoing_content_html_len;
+ }
+
+
+ file = g_build_filename(style_dir, "Contents", "Resources", "Status.html", NULL);
+ if (!g_file_get_contents(file, &status_html, &status_html_len, NULL))
+ return FALSE;
+
+ file = g_build_filename(style_dir, "Contents", "Resources", "main.css", NULL);
+ g_file_get_contents(file, &basestyle_css, &basestyle_css_len, NULL);
+
+ uiops = pidgin_conversations_get_conv_ui_ops();
+
+ if (uiops == NULL)
+ return FALSE;
+
+ /* Use the oh-so-useful uiops. Signals? bleh. */
+ default_write_conv = uiops->write_conv;
+ uiops->write_conv = purple_webkit_write_conv;
+
+ default_create_conversation = uiops->create_conversation;
+ uiops->create_conversation = purple_webkit_create_conv;
+
+ default_destroy_conversation = uiops->destroy_conversation;
+ uiops->destroy_conversation = purple_webkit_destroy_conv;
+
+ /* finally update each of the existing conversation windows */
+ {
+ GList* list = purple_get_conversations ();
+ for (;list; list = g_list_next(list))
+ purple_webkit_create_conv (list->data);
+
+ }
+ return TRUE;
+}
+
+static gboolean
+plugin_unload(PurplePlugin *plugin)
+{
+ GList *list;
+ /* Restore the default ui-ops */
+ uiops->write_conv = default_write_conv;
+ uiops->create_conversation = default_create_conversation;
+ uiops->destroy_conversation = default_destroy_conversation;
+
+ list = purple_get_conversations ();
+ while (list) {
+ finalize_theme_for_webkit(list->data);
+ list = g_list_next(list);
+ }
+ return TRUE;
+}
+
+
+static void
+variant_update_conversation (PurpleConversation *conv)
+{
+ PidginConversation *gtkconv = PIDGIN_CONVERSATION (conv);
+ WebKitWebView *webview = WEBKIT_WEB_VIEW (gtkconv->webview);
+ char* script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", css_path);
+ printf ("css_path: %s\n", css_path);
+ webkit_web_view_execute_script (webview, script);
+ g_free (script);
+}
+
+static void
+variant_changed (GtkWidget* combobox, gpointer null)
+{
+ char *name, *name_with_ext;
+ GList *list;
+
+ g_free (css_path);
+ name = gtk_combo_box_get_active_text (GTK_COMBO_BOX(combobox));
+ name_with_ext = g_strdup_printf ("%s.css", name);
+ g_free (name);
+
+ css_path = g_build_filename (style_dir, "Contents", "Resources", "Variants", name_with_ext, NULL);
+ purple_prefs_set_string ("/plugins/gtk/adiumthemes/csspath", css_path);
+ g_free (name_with_ext);
+
+ /* update each conversation */
+ list = purple_get_conversations ();
+ while (list) {
+ variant_update_conversation (list->data);
+ list = g_list_next(list);
+ }
+}
+
+static GtkWidget *
+get_config_frame(PurplePlugin *plugin) {
+ GList *themes = get_theme_files();
+ GList *theme = themes;
+ char *curdir = NULL;
+ GtkWidget *combobox = gtk_combo_box_new_text();
+ int def = -1, index = 0;
+
+ while (theme) {
+ char *basename = g_path_get_basename(theme->data);
+ char *dirname = g_path_get_dirname(theme->data);
+ if (!curdir || strcmp(curdir, dirname)) {
+ char *plist, *plist_xml;
+ gsize plist_len;
+ xmlnode *node;
+ g_free(curdir);
+ curdir = strdup(dirname);
+ plist = g_build_filename(curdir, "..", "..", "Info.plist", NULL);
+ if (!g_file_get_contents(plist, &plist_xml, &plist_len, NULL)) {
+ continue;
+ }
+ node = xmlnode_from_str(plist_xml, plist_len);
+ if (!node) continue;
+ node = xmlnode_get_child(node, "dict");
+ if (!node) continue;
+ node = xmlnode_get_child(node, "key");
+ while (node && strcmp(xmlnode_get_data(node), "CFBundleName")) {
+ node = xmlnode_get_next_twin(node);
+ }
+ if (!node) continue;
+ node = node->next;
+ while (node && node->type != XMLNODE_TYPE_TAG) {
+ node = node->next;
+ }
+
+ }
+
+ {
+ char *temp = g_strndup (basename, strlen(basename)-4);
+ gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), temp);
+ g_free (temp);
+ }
+ if (g_str_has_suffix (css_path, basename))
+ def = index;
+ index ++;
+ theme = theme->next;
+ }
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX(combobox), def);
+ g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(variant_changed), NULL);
+
+ return combobox;
+}
+
+PidginPluginUiInfo ui_info =
+{
+ get_config_frame,
+ 0, /* page_num (Reserved) */
+
+ /* padding */
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+
+static PurplePluginInfo info =
+{
+ PURPLE_PLUGIN_MAGIC, /* Magic */
+ PURPLE_MAJOR_VERSION, /* Purple Major Version */
+ PURPLE_MINOR_VERSION, /* Purple Minor Version */
+ PURPLE_PLUGIN_STANDARD, /* plugin type */
+PIDGIN_PLUGIN_TYPE, /* ui requirement */
+ 0, /* flags */
+ NULL, /* dependencies */
+ PURPLE_PRIORITY_DEFAULT, /* priority */
+
+ PLUGIN_ID, /* plugin id */
+ NULL, /* name */
+ "0.1", /* version */
+ NULL, /* summary */
+ NULL, /* description */
+ PLUGIN_AUTHOR, /* author */
+ "http://pidgin.im", /* website */
+
+ plugin_load, /* load */
+ plugin_unload, /* unload */
+ NULL, /* destroy */
+
+ &ui_info, /* ui_info */
+ NULL, /* extra_info */
+ NULL, /* prefs_info */
+ NULL, /* actions */
+ NULL, /* reserved 1 */
+ NULL, /* reserved 2 */
+ NULL, /* reserved 3 */
+ NULL /* reserved 4 */
+};
+
+static void
+init_plugin(PurplePlugin *plugin) {
+ info.name = "Adium IMs";
+ info.summary = "Adium-like IMs with Pidgin";
+ info.description = "You can chat in Pidgin using Adium's WebKit view.";
+
+ purple_prefs_add_none ("/plugins");
+ purple_prefs_add_none ("/plugins/gtk");
+ purple_prefs_add_none ("/plugins/gtk/adiumthemes");
+ purple_prefs_add_string ("/plugins/gtk/adiumthemes/csspath", "");
+}
+
+PURPLE_INIT_PLUGIN(webkit, init_plugin, info)
--
cgit v1.2.1
From 6b0c32d719c969f09d8d8047c2e1fbd39c971514 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Fri, 7 Aug 2009 18:38:31 +0000
Subject: cleaning up code.
---
pidgin/gtkwebview.c | 35 +++++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
index 1c3dc1057e..91b62cc5ab 100644
--- a/pidgin/gtkwebview.c
+++ b/pidgin/gtkwebview.c
@@ -1,3 +1,33 @@
+/*
+ * @file gtkwebview.c GTK+ WebKitWebView wrapper class.
+ * @ingroup pidgin
+ */
+
+/* pidgin
+ *
+ * Pidgin is the legal property of its developers, whose names are too numerous
+ * to list here. Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include
+#endif
#include
#include
@@ -7,6 +37,7 @@
#include "util.h"
#include "gtkwebview.h"
+#include "imgstore.h"
static WebKitWebViewClass *parent_class = NULL;
@@ -16,7 +47,7 @@ GtkWidget* gtk_webview_new ()
}
static char*
-get_img_filename_by_id (GtkWebView* view, int id)
+get_image_filename_from_id (GtkWebView* view, int id)
{
char *filename = NULL;
FILE *file;
@@ -101,7 +132,7 @@ replace_img_id_with_src (GtkWebView *view, const char* html)
/* let's dump this, tag and then dump the src information */
g_string_append_len (buffer, img, cur - img);
- g_string_append_printf (buffer, " src='file://%s' ", get_img_filename_by_id (view, nid));
+ g_string_append_printf (buffer, " src='file://%s' ", get_image_filename_from_id (view, nid));
}
return g_string_free (buffer, FALSE);
}
--
cgit v1.2.1
From fdd771ff9062d8ebbfc18f70da222f4efce78a84 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Fri, 7 Aug 2009 18:44:27 +0000
Subject: more cleanup.
---
pidgin/gtkwebview.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
index 91b62cc5ab..0f78523ff7 100644
--- a/pidgin/gtkwebview.c
+++ b/pidgin/gtkwebview.c
@@ -109,7 +109,7 @@ replace_img_id_with_src (GtkWebView *view, const char* html)
if (!cur)
cur = strstr (img, ">");
- if (!cur) { /*oops, invalid html */
+ if (!cur) { /* invalid html? */
g_string_printf (buffer, "%s", html);
break;
}
@@ -119,8 +119,12 @@ replace_img_id_with_src (GtkWebView *view, const char* html)
break;
}
- /* now I _kinda_ know that it has an id=, and does not have a src= */
- /* todo: take care of src= and id= appearing in strings? */
+ /*
+ * if this is valid HTML, then I can be sure that it
+ * has an id= and does not have an src=, since
+ * '=' cannot appear in parameters.
+ */
+
id = strstr (img, "id=") + 3;
/* *id can't be \0, since a ">" appears after this */
@@ -134,6 +138,7 @@ replace_img_id_with_src (GtkWebView *view, const char* html)
g_string_append_printf (buffer, " src='file://%s' ", get_image_filename_from_id (view, nid));
}
+
return g_string_free (buffer, FALSE);
}
@@ -153,9 +158,9 @@ gtk_webview_class_init (GtkWebViewClass *klass, gpointer userdata)
static gboolean
webview_link_clicked (WebKitWebView *view,
- WebKitWebFrame *frame,
- WebKitNetworkRequest *request,
- WebKitWebNavigationAction *navigation_action,
+ WebKitWebFrame *frame,
+ WebKitNetworkRequest *request,
+ WebKitWebNavigationAction *navigation_action,
WebKitWebPolicyDecision *policy_decision)
{
const gchar *uri;
@@ -209,7 +214,6 @@ gtk_webview_load_html_string_with_imgstore (GtkWebView* view, const char* html)
g_free (html_imged);
}
-/* taken from sean's webkit plugin */
char *gtk_webview_quote_js_string(const char *text)
{
GString *str = g_string_new("\"");
@@ -275,7 +279,7 @@ gboolean gtk_webview_is_empty (GtkWebView *view)
GType gtk_webview_get_type ()
{
static GType mview_type = 0;
- if (!mview_type) {
+ if (G_UNLIKELY (mview_type == 0)) {
static const GTypeInfo mview_info = {
sizeof (GtkWebViewClass),
NULL,
--
cgit v1.2.1
From ecdeff9e4a5cde09e19d0be212ac1818edb2d93f Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Sun, 9 Aug 2009 17:16:20 +0000
Subject: added smileyparser code.
---
pidgin/smileyparser.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++
pidgin/smileyparser.h | 3 ++
2 files changed, 147 insertions(+)
create mode 100644 pidgin/smileyparser.c
create mode 100644 pidgin/smileyparser.h
diff --git a/pidgin/smileyparser.c b/pidgin/smileyparser.c
new file mode 100644
index 0000000000..134de3d306
--- /dev/null
+++ b/pidgin/smileyparser.c
@@ -0,0 +1,144 @@
+
+#include
+#include "smileyparser.h"
+#include
+#include
+#include "gtkthemes.h"
+
+static char* get_fullpath (const char* filename)
+{
+ if (g_path_is_absolute (filename)) return g_strdup (filename);
+ else return g_build_path (g_get_current_dir (), filename, NULL);
+}
+
+static void
+parse_for_shortcut_plaintext (const char* text, const char* shortcut, const char* file, GString* ret)
+{
+ const char *tmp = text;
+
+ for(;*tmp;) {
+ const char *end = strstr (tmp, shortcut);
+ char *path;
+ char *escaped_path;
+
+ if (end == NULL) {
+ g_string_append (ret, tmp);
+ break;
+ }
+ path = get_fullpath (file);
+ escaped_path = g_markup_escape_text (path, -1);
+
+ g_string_append_len (ret, tmp, end-tmp);
+ g_string_append_printf (ret,"",
+ shortcut, escaped_path);
+ g_free (path);
+ g_free (escaped_path);
+ g_assert (strlen (tmp) >= strlen (shortcut));
+ tmp = end + strlen (shortcut);
+ }
+}
+
+static char*
+parse_for_shortcut (const char* markup, const char* shortcut, const char* file)
+{
+ GString* ret = g_string_new ("");
+ char *local_markup = g_strdup (markup);
+ char *escaped_shortcut = g_markup_escape_text (shortcut, -1);
+
+ char *temp = local_markup;
+
+ for (;*temp;) {
+ char *end = strchr (temp, '<');
+ char *end_of_tag;
+
+ if (!end) {
+ parse_for_shortcut_plaintext (temp, escaped_shortcut, file, ret);
+ break;
+ }
+
+ *end = 0;
+ parse_for_shortcut_plaintext (temp, escaped_shortcut, file, ret);
+ *end = '<';
+
+ /* if this is well-formed, then there should be no '>' within
+ * the tag. TODO: handle a comment tag better :( */
+ end_of_tag = strchr (end, '>');
+ if (!end_of_tag) {
+ g_string_append (ret, end);
+ break;
+ }
+
+ g_string_append_len (ret, end, end_of_tag-end+1);
+
+ temp = end_of_tag + 1;
+ }
+ g_free (local_markup);
+ g_free (escaped_shortcut);
+ return g_string_free (ret, FALSE);
+}
+
+static char*
+parse_for_purple_smiley (const char* markup, PurpleSmiley *smiley)
+{
+ char *file = purple_smiley_get_full_path (smiley);
+ char *ret = parse_for_shortcut (markup, purple_smiley_get_shortcut (smiley), file);
+ g_free (file);
+ return ret;
+}
+
+static char*
+parse_for_smiley_list (const char* markup, GHashTable* smileys)
+{
+ GHashTableIter iter;
+ char *key, *value;
+ char *ret = g_strdup (markup);
+
+ g_hash_table_iter_init (&iter, smileys);
+ while (g_hash_table_iter_next (&iter, (gpointer*)&key, (gpointer*)&value))
+ {
+ char* temp = parse_for_shortcut (ret, key, value);
+ g_free (ret);
+ ret = temp;
+ }
+ return ret;
+}
+
+char*
+smiley_parse_markup (const char* markup, const char *proto_id)
+{
+ GList *smileys = purple_smileys_get_all ();
+ char *temp = g_strdup (markup), *temp2;
+ struct smiley_list *list;
+ const char *proto_name = "default";
+
+ if (proto_id != NULL) {
+ PurplePlugin *proto;
+ proto = purple_find_prpl (proto_id);
+ proto_name = proto->info->name;
+ }
+
+ /* unnecessarily slow, but lets manage for now. */
+ for (; smileys; smileys = g_list_next (smileys)) {
+ temp2 = parse_for_purple_smiley (temp, PURPLE_SMILEY (smileys->data));
+ g_free (temp);
+ temp = temp2;
+ }
+
+ /* now for each theme smiley, observe that this does look nasty */
+
+ if (!current_smiley_theme || !(current_smiley_theme->list)) {
+ printf ("theme does not exist\n");
+ return temp;
+ }
+
+ for (list = current_smiley_theme->list; list; list = list->next) {
+ if (g_str_equal (list->sml, proto_name)) {
+ temp2 = parse_for_smiley_list (temp, list->files);
+ g_free (temp);
+ temp = temp2;
+ }
+ }
+
+ return temp;
+}
+
diff --git a/pidgin/smileyparser.h b/pidgin/smileyparser.h
new file mode 100644
index 0000000000..9676ab64bb
--- /dev/null
+++ b/pidgin/smileyparser.h
@@ -0,0 +1,3 @@
+
+char*
+smiley_parse_markup (const char* markup, const char* sml);
--
cgit v1.2.1
From 7f18ef168a60c9c4d79a0d429eb369ff9dcd61d6 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Sun, 9 Aug 2009 19:00:51 +0000
Subject: use displaying-im-msg instead of write_conv uiops.
---
pidgin/plugins/adiumthemes/webkit.c | 55 +++++++++++++++++++++++++------------
1 file changed, 37 insertions(+), 18 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 7a6b96b2a6..a0bca3779a 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -80,6 +80,19 @@ char *style_dir = NULL;
char *template_path = NULL;
char *css_path = NULL;
+static void *handle = NULL;
+static void* webkit_plugin_get_handle ()
+{
+ if (handle) return handle;
+ else return (handle = g_malloc (1));
+}
+
+static void webkit_plugin_free_handle ()
+{
+ purple_signals_disconnect_by_handle (handle);
+ g_free (handle);
+}
+
static char *
replace_message_tokens(char *text, gsize len, PurpleConversation *conv, const char *name, const char *alias,
const char *message, PurpleMessageFlags flags, time_t mtime)
@@ -349,11 +362,16 @@ static gboolean purple_webkit_execute_script(gpointer _script)
return FALSE;
}
-static void purple_webkit_write_conv(PurpleConversation *conv, const char *name, const char *alias,
- const char *message, PurpleMessageFlags flags, time_t mtime)
+static gboolean purple_webkit_displaying_im_msg (PurpleAccount *account,
+ const char* name,
+ char **pmessage,
+ PurpleConversation *conv,
+ PurpleMessageFlags flags,
+ gpointer data)
{
- PurpleConversationType type;
GtkWidget *webkit;
+ char *message = *pmessage;
+ const char *alias = name; /* FIXME: signal doesn't give me alias */
char *stripped;
char *message_html;
char *msg;
@@ -361,21 +379,13 @@ static void purple_webkit_write_conv(PurpleConversation *conv, const char *name,
char *script;
char *func = "appendMessage";
char *smileyed;
+ time_t mtime = time (NULL); /* FIXME: this should come from the write_conv calback, but the signal doesn't pass this to me */
+
struct webkit_script *wk_script;
PurpleMessageFlags old_flags = GPOINTER_TO_INT(purple_conversation_get_data(conv, "webkit-lastflags"));
- /* Don't call the usual stuff first. */
- //default_write_conv(conv, name, alias, message, flags, mtime);
- type = purple_conversation_get_type(conv);
- if (type != PURPLE_CONV_TYPE_IM)
- {
- /* If it's chat, we have nothing to do. */
- return;
- }
- /* So it's an IM. Let's play. */
-
webkit = get_webkit(conv);
- stripped = g_strdup(message); //purple_markup_strip_html(message);
+ stripped = g_strdup(message);
if (flags & PURPLE_MESSAGE_SEND && old_flags & PURPLE_MESSAGE_SEND) {
message_html = outgoing_next_content_html;
@@ -407,6 +417,8 @@ static void purple_webkit_write_conv(PurpleConversation *conv, const char *name,
g_free(msg);
g_free(stripped);
g_free(escape);
+
+ return TRUE; /* GtkConv should not handle this guy */
}
@@ -551,10 +563,13 @@ plugin_load(PurplePlugin *plugin)
if (uiops == NULL)
return FALSE;
- /* Use the oh-so-useful uiops. Signals? bleh. */
- default_write_conv = uiops->write_conv;
- uiops->write_conv = purple_webkit_write_conv;
-
+ purple_signal_connect (pidgin_conversations_get_handle (),
+ "displaying-im-msg",
+ webkit_plugin_get_handle (),
+ PURPLE_CALLBACK(purple_webkit_displaying_im_msg),
+ NULL);
+
+
default_create_conversation = uiops->create_conversation;
uiops->create_conversation = purple_webkit_create_conv;
@@ -575,16 +590,20 @@ static gboolean
plugin_unload(PurplePlugin *plugin)
{
GList *list;
+
/* Restore the default ui-ops */
uiops->write_conv = default_write_conv;
uiops->create_conversation = default_create_conversation;
uiops->destroy_conversation = default_destroy_conversation;
+ webkit_plugin_free_handle ();
+
list = purple_get_conversations ();
while (list) {
finalize_theme_for_webkit(list->data);
list = g_list_next(list);
}
+
return TRUE;
}
--
cgit v1.2.1
From da14fa1d3e6a0ba459c1fa29572905b5d827c648 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Sun, 9 Aug 2009 19:03:38 +0000
Subject: don't restore write-conv uiops.
---
pidgin/plugins/adiumthemes/webkit.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index a0bca3779a..1a4c31a8c3 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -47,8 +47,6 @@
static PurpleConversationUiOps *uiops = NULL;
-static void (*default_write_conv)(PurpleConversation *conv, const char *name, const char *alias,
- const char *message, PurpleMessageFlags flags, time_t mtime);
static void (*default_create_conversation)(PurpleConversation *conv);
static void (*default_destroy_conversation)(PurpleConversation *conv);
@@ -592,7 +590,6 @@ plugin_unload(PurplePlugin *plugin)
GList *list;
/* Restore the default ui-ops */
- uiops->write_conv = default_write_conv;
uiops->create_conversation = default_create_conversation;
uiops->destroy_conversation = default_destroy_conversation;
--
cgit v1.2.1
From ad10366b2b9b9a9a0cf4d11730fb05d16c0a7519 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Sun, 9 Aug 2009 19:32:54 +0000
Subject: create conversation with signals.
---
pidgin/plugins/adiumthemes/webkit.c | 40 +++++++++++++++++++++++++++----------
1 file changed, 30 insertions(+), 10 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 1a4c31a8c3..8b40ab95c7 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -47,8 +47,6 @@
static PurpleConversationUiOps *uiops = NULL;
-static void (*default_create_conversation)(PurpleConversation *conv);
-
static void (*default_destroy_conversation)(PurpleConversation *conv);
/* Cache the contents of the HTML files */
@@ -283,6 +281,15 @@ get_webkit(PurpleConversation *conv)
else
return gtkconv->webview;
}
+
+/**
+ * Called when either a new PurpleConversation is created
+ * or when a PidginConversation changes its active PurpleConversation
+ *
+ * FIXME: it's not at all clear to me as to how
+ * Adium themes handle the case when the PurpleConversation
+ * changes.
+ */
static void
init_theme_for_webkit (PurpleConversation *conv)
{
@@ -301,6 +308,7 @@ init_theme_for_webkit (PurpleConversation *conv)
webkit_web_view_load_string(WEBKIT_WEB_VIEW(webkit), template, "text/html", "UTF-8", baseuri);
g_object_set_data (G_OBJECT(webkit), "adium-themed", GINT_TO_POINTER(1));
+
g_free (basedir);
g_free (baseuri);
g_free (header);
@@ -421,10 +429,15 @@ static gboolean purple_webkit_displaying_im_msg (PurpleAccount *account,
static void
-purple_webkit_create_conv(PurpleConversation *conv)
+webkit_on_converstation_displayed (PidginConversation *gtkconv, gpointer data)
+{
+ init_theme_for_webkit (gtkconv->active_conv);
+}
+
+static void
+webkit_on_conversation_switched (PurpleConversation *conv, gpointer data)
{
- default_create_conversation(conv);
- init_theme_for_webkit(conv);
+ init_theme_for_webkit (conv);
}
static void
@@ -567,9 +580,17 @@ plugin_load(PurplePlugin *plugin)
PURPLE_CALLBACK(purple_webkit_displaying_im_msg),
NULL);
-
- default_create_conversation = uiops->create_conversation;
- uiops->create_conversation = purple_webkit_create_conv;
+ purple_signal_connect (pidgin_conversations_get_handle (),
+ "conversation-displayed",
+ webkit_plugin_get_handle (),
+ PURPLE_CALLBACK(webkit_on_converstation_displayed),
+ NULL);
+
+ purple_signal_connect (pidgin_conversations_get_handle (),
+ "conversation-switched",
+ webkit_plugin_get_handle (),
+ PURPLE_CALLBACK(webkit_on_conversation_switched),
+ NULL);
default_destroy_conversation = uiops->destroy_conversation;
uiops->destroy_conversation = purple_webkit_destroy_conv;
@@ -578,7 +599,7 @@ plugin_load(PurplePlugin *plugin)
{
GList* list = purple_get_conversations ();
for (;list; list = g_list_next(list))
- purple_webkit_create_conv (list->data);
+ init_theme_for_webkit (list->data);
}
return TRUE;
@@ -590,7 +611,6 @@ plugin_unload(PurplePlugin *plugin)
GList *list;
/* Restore the default ui-ops */
- uiops->create_conversation = default_create_conversation;
uiops->destroy_conversation = default_destroy_conversation;
webkit_plugin_free_handle ();
--
cgit v1.2.1
From b786ef54cb8688edb41c3a9c08dc1ae5b5f2428b Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Sun, 9 Aug 2009 20:13:32 +0000
Subject: * removed delete_conversation uiops and instead used signals. *
removed escape_string function and use gtk_webview_quote_js_string instead.
---
pidgin/plugins/adiumthemes/webkit.c | 51 ++++++++++---------------------------
1 file changed, 14 insertions(+), 37 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 8b40ab95c7..f73bf71259 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -43,11 +43,11 @@
/* Pidgin headers */
#include
#include
+#include
#include
static PurpleConversationUiOps *uiops = NULL;
-static void (*default_destroy_conversation)(PurpleConversation *conv);
/* Cache the contents of the HTML files */
char *template_html = NULL; /* This is the skeleton: some basic javascript mostly */
@@ -326,33 +326,6 @@ finalize_theme_for_webkit (PurpleConversation *conv)
g_object_set_data (G_OBJECT(webview), "adium-themed", NULL);
}
-static char *
-escape_message(char *text)
-{
- GString *str = g_string_new(NULL);
- char *cur = text;
-
- while (cur && *cur) {
- switch (*cur) {
- case '\\':
- g_string_append(str, "\\\\");
- break;
- case '\"':
- g_string_append(str, "\\\"");
- break;
- case '\r':
- g_string_append(str, "
");
- break;
- case '\n':
- break;
- default:
- g_string_append_c(str, *cur);
- }
- cur++;
- }
- return g_string_free(str, FALSE);
-}
-
struct webkit_script {
GtkWidget *webkit;
char *script;
@@ -390,6 +363,7 @@ static gboolean purple_webkit_displaying_im_msg (PurpleAccount *account,
struct webkit_script *wk_script;
PurpleMessageFlags old_flags = GPOINTER_TO_INT(purple_conversation_get_data(conv, "webkit-lastflags"));
+ fprintf (stderr, "hmm.. here %s %s\n", name, message);
webkit = get_webkit(conv);
stripped = g_strdup(message);
@@ -410,8 +384,8 @@ static gboolean purple_webkit_displaying_im_msg (PurpleAccount *account,
smileyed = smiley_parse_markup(stripped, conv->account->protocol_id);
msg = replace_message_tokens(message_html, 0, conv, name, alias, smileyed, flags, mtime);
- escape = escape_message(msg);
- script = g_strdup_printf("%s(\"%s\")", func, escape);
+ escape = gtk_webview_quote_js_string (msg);
+ script = g_strdup_printf("%s(%s)", func, escape);
wk_script = g_new0(struct webkit_script, 1);
wk_script->script = script;
@@ -441,9 +415,12 @@ webkit_on_conversation_switched (PurpleConversation *conv, gpointer data)
}
static void
-purple_webkit_destroy_conv(PurpleConversation *conv)
+webkit_on_conversation_hiding (PidginConversation *gtkconv, gpointer data)
{
- default_destroy_conversation(conv);
+ /*
+ * I'm not sure if I need to do anything here, but let's keep
+ * this anyway
+ */
}
static GList*
@@ -592,8 +569,11 @@ plugin_load(PurplePlugin *plugin)
PURPLE_CALLBACK(webkit_on_conversation_switched),
NULL);
- default_destroy_conversation = uiops->destroy_conversation;
- uiops->destroy_conversation = purple_webkit_destroy_conv;
+ purple_signal_connect (pidgin_conversations_get_handle (),
+ "conversation-hiding",
+ webkit_plugin_get_handle (),
+ PURPLE_CALLBACK(webkit_on_conversation_hiding),
+ NULL);
/* finally update each of the existing conversation windows */
{
@@ -610,9 +590,6 @@ plugin_unload(PurplePlugin *plugin)
{
GList *list;
- /* Restore the default ui-ops */
- uiops->destroy_conversation = default_destroy_conversation;
-
webkit_plugin_free_handle ();
list = purple_get_conversations ();
--
cgit v1.2.1
From a8e6d1b0db21ff18bdf513663d9fb0ce62803667 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 01:21:57 +0000
Subject: Well, chat is sorta kinda working.
---
pidgin/plugins/adiumthemes/webkit.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index f73bf71259..2b6e925c62 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -341,7 +341,8 @@ static gboolean purple_webkit_execute_script(gpointer _script)
return FALSE;
}
-static gboolean purple_webkit_displaying_im_msg (PurpleAccount *account,
+
+static gboolean webkit_on_displaying_im_msg (PurpleAccount *account,
const char* name,
char **pmessage,
PurpleConversation *conv,
@@ -401,6 +402,16 @@ static gboolean purple_webkit_displaying_im_msg (PurpleAccount *account,
return TRUE; /* GtkConv should not handle this guy */
}
+static gboolean webkit_on_displaying_chat_msg (PurpleAccount *account,
+ const char *who,
+ char **message,
+ PurpleConversation *conv,
+ PurpleMessageFlags flags,
+ gpointer userdata)
+{
+ /* handle exactly like an IM message */
+ return webkit_on_displaying_im_msg (account, who, message, conv, flags, NULL);
+}
static void
webkit_on_converstation_displayed (PidginConversation *gtkconv, gpointer data)
@@ -554,9 +565,15 @@ plugin_load(PurplePlugin *plugin)
purple_signal_connect (pidgin_conversations_get_handle (),
"displaying-im-msg",
webkit_plugin_get_handle (),
- PURPLE_CALLBACK(purple_webkit_displaying_im_msg),
+ PURPLE_CALLBACK(webkit_on_displaying_im_msg),
NULL);
+ purple_signal_connect (pidgin_conversations_get_handle (),
+ "displaying-chat-msg",
+ webkit_plugin_get_handle (),
+ PURPLE_CALLBACK(webkit_on_displaying_chat_msg),
+ NULL);
+
purple_signal_connect (pidgin_conversations_get_handle (),
"conversation-displayed",
webkit_plugin_get_handle (),
--
cgit v1.2.1
From af7ef23fc3a3be57fe2c4416eee425c9799feddc Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 01:34:48 +0000
Subject: Changed the Author added copyright, etc.
---
pidgin/plugins/adiumthemes/webkit.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 2b6e925c62..014a07247c 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -1,5 +1,6 @@
/*
- * Adium Webkit views
+ * Adium Message Styles
+ * Copyright (C) 2009 Arnold Noronha
* Copyright (C) 2007
*
* This program is free software; you can redistribute it and/or
@@ -18,13 +19,14 @@
* 02111-1307, USA.
*/
-/* This plugins is basically Sadrul's x-chat plugin, but with Webkit
- * instead of xtext.
- */
-
#define PLUGIN_ID "gtk-webview-adium-ims"
#define PLUGIN_NAME "webview-adium-ims"
-#define PLUGIN_AUTHOR "Sean Egan "
+
+/*
+ * A lot of this was originally written by Sean Egan, but I think I've
+ * rewrote enough to replace the author for now.
+ */
+#define PLUGIN_AUTHOR "Arnold Noronha "
#define PURPLE_PLUGINS "Hell yeah"
/* System headers */
@@ -46,8 +48,6 @@
#include
#include
-static PurpleConversationUiOps *uiops = NULL;
-
/* Cache the contents of the HTML files */
char *template_html = NULL; /* This is the skeleton: some basic javascript mostly */
--
cgit v1.2.1
From d880923511959767c7be5fdbfeaaa2f83c74c0bf Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 02:11:21 +0000
Subject: temporary commit.
---
pidgin/plugins/adiumthemes/webkit.c | 171 +++++++++++++++++++++++-------------
1 file changed, 111 insertions(+), 60 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 014a07247c..8ac9ff2d98 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -48,35 +48,80 @@
#include
#include
+/*
+ * I'm going to allow a different style for each PidginConversation.
+ * This way I can do two things: 1) change the theme on the fly and not
+ * change existing themes, and 2) Use a different theme for IMs and
+ * chats.
+ */
+typedef struct _PidginMessageStyle {
+ int ref_counter;
+
+ /* paths */
+ char *style_dir;
+ char *template_path;
+ char *css_path;
+
+ /* caches */
+ char *template_html;
+ char *style_name;
+ char *incoming_content_html;
+ char *outgoing_content_html;
+ char *incoming_next_content_html;
+ char *outgoing_next_content_html;
+ char *status_html;
+ char *basestyle_css;
+} PidginMessageStyle;
+
+static GList *style_list;
+static void *handle = NULL;
+
+static PidginMessageStyle* pidgin_message_style_new ()
+{
+ PidginMessageStyle* ret = g_new0 (PidginMessageStyle, 1);
+ ret->ref_counter ++;
+
+ style_list = g_list_append (style_list, ret);
+ return ret;
+}
+
+static void pidgin_message_style_unref (PidginMessageStyle *style)
+{
+ style->ref_counter--;
+ if (style->ref_counter) return;
+
+ g_free (style->style_dir);
+ g_free (style->template_path);
+ g_free (style->css_path);
+
+ g_free (style->template_html);
+ g_free (style->incoming_content_html);
+ g_free (style->outgoing_content_html);
+ g_free (style->outgoing_next_content_html);
+ g_free (style->status_html);
+ g_free (style->basestyle_css);
+
+ g_list_remove (style_list, style);
+ g_free (style);
+}
+
+static PidginMessageStyle*
+pidgin_message_style_load (const char* styledir)
+{
+ /* is this style already loaded? */
+ GList* cur = style_list;
+ PidginMessageStyle *ret = NULL;
+ for (; cur; cur = g_list_next (cur)) {
+ if (g_str_equal (styldir, ((PidginMessageStyle*) cur->data)->styledir))
+ return (PidginMessageStyle*) cur->data;
+ }
+
+ /* else we need to load it */
+ ret = pidgin_message_style_new ();
+
+}
-/* Cache the contents of the HTML files */
-char *template_html = NULL; /* This is the skeleton: some basic javascript mostly */
-char *header_html = NULL; /* This is the first thing to be appended to any conversation */
-char *footer_html = NULL; /* This is the last thing appended to the conversation */
-char *incoming_content_html = NULL; /* This is a received message */
-char *outgoing_content_html = NULL; /* And a sent one */
-char *incoming_next_content_html = NULL; /* The same things, but used when someone sends multiple subsequent */
-char *outgoing_next_content_html = NULL; /* messages in a row */
-char *status_html = NULL; /* Non-IM status messages */
-char *basestyle_css = NULL; /* Shared CSS attributes */
-
-/* Cache their lenghts too, to pass into g_string_new_len, avoiding crazy allocation */
-gsize template_html_len = 0;
-gsize header_html_len = 0;
-gsize footer_html_len = 0;
-gsize incoming_content_html_len = 0;
-gsize outgoing_content_html_len = 0;
-gsize incoming_next_content_html_len = 0;
-gsize outgoing_next_content_html_len = 0;
-gsize status_html_len = 0;
-gsize basestyle_css_len = 0;
-
-/* And their paths */
-char *style_dir = NULL;
-char *template_path = NULL;
-char *css_path = NULL;
-static void *handle = NULL;
static void* webkit_plugin_get_handle ()
{
if (handle) return handle;
@@ -434,65 +479,71 @@ webkit_on_conversation_hiding (PidginConversation *gtkconv, gpointer data)
*/
}
+/**
+ * Get each of the files corresponding to each variant.
+ */
static GList*
-get_theme_files()
+get_theme_files(PidginMessageStyle *style)
{
GList *ret = NULL;
GDir *variants;
- char *globe = g_build_filename(DATADIR, "pidgin", "webkit", "styles", NULL);
const char *css_file;
char *css;
+ char *variant_dir;
- if (style_dir != NULL) {
- char *variant_dir = g_build_filename(style_dir, "Contents", "Resources", "Variants", NULL);
- variants = g_dir_open(variant_dir, 0, NULL);
- while ((css_file = g_dir_read_name(variants)) != NULL) {
- if (!strstr(css_file, ".css")) {
- continue;
- }
- css = g_build_filename(variant_dir, css_file, NULL);
- ret = g_list_append(ret,css);
- }
- g_dir_close(variants);
- g_free(variant_dir);
+ g_assert (style->style_dir);
+ variant_dir = g_build_filename(style_dir, "Contents", "Resources", "Variants", NULL);
+
+ variants = g_dir_open(variant_dir, 0, NULL);
+ if (!variants) return NULL;
+
+ while ((css_file = g_dir_read_name(variants)) != NULL) {
+ if (!g_str_has_suffix (css_file, ".css"))
+ continue;
+
+ css = g_build_filename(variant_dir, css_file, NULL);
+ ret = g_list_append(ret, css);
}
- g_free(globe);
+
+ g_dir_close(variants);
+ g_free(variant_dir);
ret = g_list_sort (ret, (GCompareFunc)g_strcmp0);
return ret;
}
static void
-variant_set_default ()
+variant_set_default (PidginMessageStyle* style)
{
+ GList *all, *iter;
+ char *css_path = purple_prefs_get_string ("/plugins/gtk/adiumthemes/csspath");
- GList* all;
- GList* copy;
- css_path = g_strdup (purple_prefs_get_string ("/plugins/gtk/adiumthemes/csspath"));
-
- if (g_file_test (css_path, G_FILE_TEST_EXISTS))
+ g_free (style->css_path);
+ if (g_str_has_prefix (css_path, style->style_dir) &&
+ g_file_test (css_path, G_FILE_TEST_EXISTS)) {
+ style->css_path = g_strdup (css_path);
return;
+ }
else {
+ /* something about the theme has changed */
g_free (css_path);
css_path = NULL;
}
- all = get_theme_files ();
- copy = all;
- if (css_path) {
- g_free (css_path);
- css_path = NULL;
- }
+ all = get_theme_files (PidginMessageStyle* style);
+
if (all) {
- css_path = g_strdup (all->data);
+ style->css_path = g_strdup (all->data);
purple_prefs_set_string ("/plugins/gtk/adiumthemes/csspath", css_path);
}
- while (all) {
- g_free (all->data);
- all = g_list_next(all);
- }
- g_list_free (copy);
+ for (iter = all; iter; iter = g_list_next (iter))
+ g_free (iter->data);
+
+ g_list_free (all);
+
+ g_free (style->css_path);
+ style->css_path = css_path;
}
static gboolean
--
cgit v1.2.1
From ab0b0aec391ed8daa3a2e0a1c1d2c428498a39c2 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 02:38:12 +0000
Subject: Another temporary commit that will not compile. Separated the code to
load the message style.
---
pidgin/plugins/adiumthemes/webkit.c | 133 ++++++++++++++++++++++--------------
1 file changed, 81 insertions(+), 52 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 8ac9ff2d98..7ba7ee49b8 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -74,6 +74,7 @@ typedef struct _PidginMessageStyle {
} PidginMessageStyle;
static GList *style_list;
+static PidginMessageStyle *cur_style = NULL;
static void *handle = NULL;
static PidginMessageStyle* pidgin_message_style_new ()
@@ -105,12 +106,15 @@ static void pidgin_message_style_unref (PidginMessageStyle *style)
g_free (style);
}
+static void variant_set_default (PidginMessageStyle* style);
static PidginMessageStyle*
pidgin_message_style_load (const char* styledir)
{
/* is this style already loaded? */
- GList* cur = style_list;
+ GList *cur = style_list;
+ char *file; /* temporary variable */
PidginMessageStyle *ret = NULL;
+
for (; cur; cur = g_list_next (cur)) {
if (g_str_equal (styldir, ((PidginMessageStyle*) cur->data)->styledir))
return (PidginMessageStyle*) cur->data;
@@ -118,7 +122,80 @@ pidgin_message_style_load (const char* styledir)
/* else we need to load it */
ret = pidgin_message_style_new ();
+ ret->style_dir = g_strdup (style);
+
+ /* find some variant file (or load from user's settings) */
+ variant_set_default (style);
+
+ /* load all other files */
+
+ /* The template path can either come from the theme, or can
+ * be stock Template.html that comes with the plugin */
+ style->template_path = g_build_filename(styledir, "Contents", "Resources", "Template.html", NULL);
+
+ if (!g_file_test(style->template_path, G_FILE_TEST_EXISTS)) {
+ g_free (style->template_path);
+ style->template_path = g_build_filename(DATADIR, "pidgin", "webkit", "Template.html", NULL);
+ }
+
+ if (!g_file_get_contents(style->template_path, &style->template_html, NULL, NULL)) {
+ pidgin_message_style_free (style);
+ return NULL;
+ }
+
+ file = g_build_filename(style_dir, "Contents", "Resources", "Status.html", NULL);
+ if (!g_file_get_contents(file, &style->status_html, NULL, NULL)) {
+ pidgin_message_style_free (style);
+ g_free (file);
+ return NULL;
+ }
+ g_free (file);
+
+ file = g_build_filename(style_dir, "Contents", "Resources", "main.css", NULL);
+ if (!g_file_get_contents(file, &basestyle_css, NULL, NULL)) {
+ pidgin_message_style_free (style);
+ g_free (file);
+ return NULL;
+ }
+ g_free (file);
+ file = g_build_filename(style_dir, "Contents", "Resources", "Header.html", NULL);
+ g_file_get_contents(file, &style->header_html, NULL, NULL);
+ g_free (file);
+
+ file = g_build_filename(style_dir, "Contents", "Resources", "Footer.html", NULL);
+ g_file_get_contents(file, &style->footer_html, NULL, NULL);
+ g_free (file);
+
+
+
+ file = g_build_filename(style_dir, "Contents", "Resources", "Incoming", "Content.html", NULL);
+ if (!g_file_get_contents(file, &style->incoming_content_html, &NULL, NULL)) {
+ pidgin_message_style_free (style);
+ g_free (file);
+ return NULL;
+ }
+ g_free (file);
+
+
+ /* according to the spec, the following are not necessary files */
+ file = g_build_filename(styledir, "Contents", "Resources", "Incoming", "NextContent.html", NULL);
+ if (!g_file_get_contents(file, &style->incoming_next_content_html, NULL, NULL)) {
+ style->incoming_next_content_html = g_strdup (style->incoming_content_html);
+ }
+ g_free (file);
+
+ file = g_build_filename(styledir, "Contents", "Resources", "Outgoing", "Content.html", NULL);
+ if (!g_file_get_contents(file, &style->outgoing_content_html, NULL, NULL)) {
+ style->outgoing_content_html = g_strdup(style->incoming_content_html);
+ }
+ g_free (file);
+
+ file = g_build_filename(styledir, "Contents", "Resources", "Outgoing", "NextContent.html", NULL);
+ if (!g_file_get_contents(file, &style->outgoing_next_content_html, NULL, NULL)) {
+ outgoing_next_content_html = g_strdup (outgoing_content_html);
+ }
+
}
@@ -541,15 +618,12 @@ variant_set_default (PidginMessageStyle* style)
g_free (iter->data);
g_list_free (all);
-
- g_free (style->css_path);
- style->css_path = css_path;
}
static gboolean
plugin_load(PurplePlugin *plugin)
{
- char *file;
+ char *cur_style;
if (g_path_is_absolute (purple_user_dir()))
style_dir = g_build_filename(purple_user_dir(), "style", NULL);
@@ -559,54 +633,9 @@ plugin_load(PurplePlugin *plugin)
g_free (cur);
}
- variant_set_default ();
- if (!css_path)
- return FALSE;
-
-
- template_path = g_build_filename(style_dir, "Contents", "Resources", "Template.html", NULL);
- if (!g_file_test(template_path, G_FILE_TEST_EXISTS)) {
- g_free(template_path);
- template_path = g_build_filename(DATADIR, "pidgin", "webkit", "Template.html", NULL);
- }
- if (!g_file_get_contents(template_path, &template_html, &template_html_len, NULL))
- return FALSE;
+ cur_style = pidgin_message_style_load (style_dir);
- file = g_build_filename(style_dir, "Contents", "Resources", "Header.html", NULL);
- g_file_get_contents(file, &header_html, &header_html_len, NULL);
-
- file = g_build_filename(style_dir, "Contents", "Resources", "Footer.html", NULL);
- g_file_get_contents(file, &footer_html, &footer_html_len, NULL);
-
- file = g_build_filename(style_dir, "Contents", "Resources", "Incoming", "Content.html", NULL);
- if (!g_file_get_contents(file, &incoming_content_html, &incoming_content_html_len, NULL))
- return FALSE;
-
- file = g_build_filename(style_dir, "Contents", "Resources", "Incoming", "NextContent.html", NULL);
- if (!g_file_get_contents(file, &incoming_next_content_html, &incoming_next_content_html_len, NULL)) {
- incoming_next_content_html = incoming_content_html;
- incoming_next_content_html_len = incoming_content_html_len;
- }
-
- file = g_build_filename(style_dir, "Contents", "Resources", "Outgoing", "Content.html", NULL);
- if (!g_file_get_contents(file, &outgoing_content_html, &outgoing_content_html_len, NULL)) {
- outgoing_content_html = incoming_content_html;
- outgoing_content_html_len = incoming_content_html_len;
- }
-
- file = g_build_filename(style_dir, "Contents", "Resources", "Outgoing", "NextContent.html", NULL);
- if (!g_file_get_contents(file, &outgoing_next_content_html, &outgoing_next_content_html_len, NULL)) {
- outgoing_next_content_html = outgoing_content_html;
- outgoing_next_content_html_len = outgoing_content_html_len;
- }
-
-
- file = g_build_filename(style_dir, "Contents", "Resources", "Status.html", NULL);
- if (!g_file_get_contents(file, &status_html, &status_html_len, NULL))
- return FALSE;
-
- file = g_build_filename(style_dir, "Contents", "Resources", "main.css", NULL);
- g_file_get_contents(file, &basestyle_css, &basestyle_css_len, NULL);
+ if (!cur_style) return;
uiops = pidgin_conversations_get_conv_ui_ops();
--
cgit v1.2.1
From 98cfdd3cff9c4c12837c941314bd3463bc7c8be2 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 03:25:35 +0000
Subject: Ok, good part of this work of moving global variables to defined
styles is done. Now, I still get a crash while changing the variant.
---
pidgin/plugins/adiumthemes/webkit.c | 176 ++++++++++++++++++++++--------------
1 file changed, 108 insertions(+), 68 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 7ba7ee49b8..78c6b1228c 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -64,7 +64,8 @@ typedef struct _PidginMessageStyle {
/* caches */
char *template_html;
- char *style_name;
+ char *header_html;
+ char *footer_html;
char *incoming_content_html;
char *outgoing_content_html;
char *incoming_next_content_html;
@@ -73,9 +74,9 @@ typedef struct _PidginMessageStyle {
char *basestyle_css;
} PidginMessageStyle;
-static GList *style_list;
-static PidginMessageStyle *cur_style = NULL;
-static void *handle = NULL;
+static GList *style_list; /**< List of PidginMessageStyles */
+static char *cur_style_dir = NULL;
+static void *handle = NULL;
static PidginMessageStyle* pidgin_message_style_new ()
{
@@ -102,7 +103,7 @@ static void pidgin_message_style_unref (PidginMessageStyle *style)
g_free (style->status_html);
g_free (style->basestyle_css);
- g_list_remove (style_list, style);
+ style_list = g_list_remove (style_list, style);
g_free (style);
}
@@ -113,16 +114,18 @@ pidgin_message_style_load (const char* styledir)
/* is this style already loaded? */
GList *cur = style_list;
char *file; /* temporary variable */
- PidginMessageStyle *ret = NULL;
+ PidginMessageStyle *style = NULL;
+
+ g_assert (styledir);
for (; cur; cur = g_list_next (cur)) {
- if (g_str_equal (styldir, ((PidginMessageStyle*) cur->data)->styledir))
+ if (g_str_equal (styledir, ((PidginMessageStyle*) cur->data)->style_dir))
return (PidginMessageStyle*) cur->data;
}
/* else we need to load it */
- ret = pidgin_message_style_new ();
- ret->style_dir = g_strdup (style);
+ style = pidgin_message_style_new ();
+ style->style_dir = g_strdup (styledir);
/* find some variant file (or load from user's settings) */
variant_set_default (style);
@@ -139,39 +142,35 @@ pidgin_message_style_load (const char* styledir)
}
if (!g_file_get_contents(style->template_path, &style->template_html, NULL, NULL)) {
- pidgin_message_style_free (style);
+ pidgin_message_style_unref (style);
return NULL;
}
- file = g_build_filename(style_dir, "Contents", "Resources", "Status.html", NULL);
+ file = g_build_filename(styledir, "Contents", "Resources", "Status.html", NULL);
if (!g_file_get_contents(file, &style->status_html, NULL, NULL)) {
- pidgin_message_style_free (style);
+ pidgin_message_style_unref (style);
g_free (file);
return NULL;
}
g_free (file);
- file = g_build_filename(style_dir, "Contents", "Resources", "main.css", NULL);
- if (!g_file_get_contents(file, &basestyle_css, NULL, NULL)) {
- pidgin_message_style_free (style);
- g_free (file);
- return NULL;
- }
+ file = g_build_filename(styledir, "Contents", "Resources", "main.css", NULL);
+ g_file_get_contents(file, &style->basestyle_css, NULL, NULL);
g_free (file);
- file = g_build_filename(style_dir, "Contents", "Resources", "Header.html", NULL);
+ file = g_build_filename(styledir, "Contents", "Resources", "Header.html", NULL);
g_file_get_contents(file, &style->header_html, NULL, NULL);
g_free (file);
- file = g_build_filename(style_dir, "Contents", "Resources", "Footer.html", NULL);
+ file = g_build_filename(styledir, "Contents", "Resources", "Footer.html", NULL);
g_file_get_contents(file, &style->footer_html, NULL, NULL);
g_free (file);
- file = g_build_filename(style_dir, "Contents", "Resources", "Incoming", "Content.html", NULL);
- if (!g_file_get_contents(file, &style->incoming_content_html, &NULL, NULL)) {
- pidgin_message_style_free (style);
+ file = g_build_filename(styledir, "Contents", "Resources", "Incoming", "Content.html", NULL);
+ if (!g_file_get_contents(file, &style->incoming_content_html, NULL, NULL)) {
+ pidgin_message_style_unref (style);
g_free (file);
return NULL;
}
@@ -193,9 +192,10 @@ pidgin_message_style_load (const char* styledir)
file = g_build_filename(styledir, "Contents", "Resources", "Outgoing", "NextContent.html", NULL);
if (!g_file_get_contents(file, &style->outgoing_next_content_html, NULL, NULL)) {
- outgoing_next_content_html = g_strdup (outgoing_content_html);
+ style->outgoing_next_content_html = g_strdup (style->outgoing_content_html);
}
+ return style;
}
@@ -212,8 +212,15 @@ static void webkit_plugin_free_handle ()
}
static char *
-replace_message_tokens(char *text, gsize len, PurpleConversation *conv, const char *name, const char *alias,
- const char *message, PurpleMessageFlags flags, time_t mtime)
+replace_message_tokens(
+ char *text,
+ gsize len,
+ PurpleConversation *conv,
+ const char *name,
+ const char *alias,
+ const char *message,
+ PurpleMessageFlags flags,
+ time_t mtime)
{
GString *str = g_string_new_len(NULL, len);
char *cur = text;
@@ -332,7 +339,6 @@ replace_header_tokens(char *text, gsize len, PurpleConversation *conv)
replace = purple_utf8_strftime(format ? format : "%X", NULL);
g_free(format);
} else {
- // cur++;
continue;
}
@@ -354,7 +360,7 @@ replace_header_tokens(char *text, gsize len, PurpleConversation *conv)
}
static char *
-replace_template_tokens(char *text, int len, char *header, char *footer) {
+replace_template_tokens(PidginMessageStyle *style, char *text, int len, char *header, char *footer) {
GString *str = g_string_new_len(NULL, len);
char **ms = g_strsplit(text, "%@", 6);
@@ -368,17 +374,17 @@ replace_template_tokens(char *text, int len, char *header, char *footer) {
g_string_append(str, ms[0]);
g_string_append(str, "file://");
- base = g_build_filename (style_dir, "Contents", "Resources", "Template.html", NULL);
+ base = g_build_filename (style->style_dir, "Contents", "Resources", "Template.html", NULL);
g_string_append(str, base);
g_free (base);
g_string_append(str, ms[1]);
- if (basestyle_css)
- g_string_append(str, basestyle_css);
+ if (style->basestyle_css)
+ g_string_append(str, style->basestyle_css);
g_string_append(str, ms[2]);
- if (css_path) {
+ if (style->css_path) {
g_string_append(str, "file://");
- g_string_append(str, css_path);
+ g_string_append(str, style->css_path);
}
g_string_append(str, ms[3]);
@@ -413,23 +419,28 @@ get_webkit(PurpleConversation *conv)
* changes.
*/
static void
-init_theme_for_webkit (PurpleConversation *conv)
+init_theme_for_webkit (PurpleConversation *conv, char *style_dir)
{
GtkWidget *webkit = PIDGIN_CONVERSATION(conv)->webview;
char *header, *footer;
char *template;
- char* basedir = g_build_filename (style_dir, "Contents", "Resources", "Template.html", NULL);
- char* baseuri = g_strdup_printf ("file://%s", basedir);
+ char* basedir;
+ char* baseuri;
+ PidginMessageStyle *style;
+ style = pidgin_message_style_load (style_dir);
+ g_assert (style);
- header = replace_header_tokens(header_html, header_html_len, conv);
- footer = replace_header_tokens(footer_html, footer_html_len, conv);
- template = replace_template_tokens(template_html, template_html_len + header_html_len, header, footer);
+ basedir = g_build_filename (style->style_dir, "Contents", "Resources", "Template.html", NULL);
+ baseuri = g_strdup_printf ("file://%s", basedir);
+ header = replace_header_tokens(style->header_html, strlen(style->header_html), conv);
+ footer = replace_header_tokens(style->footer_html, strlen(style->footer_html), conv);
+ template = replace_template_tokens(style, style->template_html, strlen(style->template_html) + strlen(style->header_html), header, footer);
if (!g_object_get_data (G_OBJECT(webkit), "adium-themed"))
webkit_web_view_load_string(WEBKIT_WEB_VIEW(webkit), template, "text/html", "UTF-8", baseuri);
- g_object_set_data (G_OBJECT(webkit), "adium-themed", GINT_TO_POINTER(1));
+ g_object_set_data (G_OBJECT(webkit), "adium-themed", style);
g_free (basedir);
g_free (baseuri);
@@ -444,8 +455,11 @@ static void
finalize_theme_for_webkit (PurpleConversation *conv)
{
GtkWidget *webview = PIDGIN_CONVERSATION(conv)->webview;
+ PidginMessageStyle *style = g_object_get_data (G_OBJECT(webview), "adium-themed");
+
webkit_web_view_load_string(WEBKIT_WEB_VIEW(webview), "", "text/html", "UTF-8", "");
g_object_set_data (G_OBJECT(webview), "adium-themed", NULL);
+ pidgin_message_style_unref (style);
}
struct webkit_script {
@@ -485,23 +499,26 @@ static gboolean webkit_on_displaying_im_msg (PurpleAccount *account,
struct webkit_script *wk_script;
PurpleMessageFlags old_flags = GPOINTER_TO_INT(purple_conversation_get_data(conv, "webkit-lastflags"));
+ PidginMessageStyle *style;
fprintf (stderr, "hmm.. here %s %s\n", name, message);
webkit = get_webkit(conv);
stripped = g_strdup(message);
+ style = g_object_get_data (G_OBJECT (webkit), "adium-themed");
+
if (flags & PURPLE_MESSAGE_SEND && old_flags & PURPLE_MESSAGE_SEND) {
- message_html = outgoing_next_content_html;
+ message_html = style->outgoing_next_content_html;
func = "appendNextMessage";
} else if (flags & PURPLE_MESSAGE_SEND) {
- message_html = outgoing_content_html;
+ message_html = style->outgoing_content_html;
} else if (flags & PURPLE_MESSAGE_RECV && old_flags & PURPLE_MESSAGE_RECV) {
- message_html = incoming_next_content_html;
+ message_html = style->incoming_next_content_html;
func = "appendNextMessage";
} else if (flags & PURPLE_MESSAGE_RECV) {
- message_html = incoming_content_html;
+ message_html = style->incoming_content_html;
} else {
- message_html = status_html;
+ message_html = style->status_html;
}
purple_conversation_set_data(conv, "webkit-lastflags", GINT_TO_POINTER(flags));
@@ -538,13 +555,13 @@ static gboolean webkit_on_displaying_chat_msg (PurpleAccount *account,
static void
webkit_on_converstation_displayed (PidginConversation *gtkconv, gpointer data)
{
- init_theme_for_webkit (gtkconv->active_conv);
+ init_theme_for_webkit (gtkconv->active_conv, cur_style_dir);
}
static void
webkit_on_conversation_switched (PurpleConversation *conv, gpointer data)
{
- init_theme_for_webkit (conv);
+ init_theme_for_webkit (conv, cur_style_dir);
}
static void
@@ -569,7 +586,7 @@ get_theme_files(PidginMessageStyle *style)
char *variant_dir;
g_assert (style->style_dir);
- variant_dir = g_build_filename(style_dir, "Contents", "Resources", "Variants", NULL);
+ variant_dir = g_build_filename(style->style_dir, "Contents", "Resources", "Variants", NULL);
variants = g_dir_open(variant_dir, 0, NULL);
if (!variants) return NULL;
@@ -593,7 +610,7 @@ static void
variant_set_default (PidginMessageStyle* style)
{
GList *all, *iter;
- char *css_path = purple_prefs_get_string ("/plugins/gtk/adiumthemes/csspath");
+ const char *css_path = purple_prefs_get_string ("/plugins/gtk/adiumthemes/csspath");
g_free (style->css_path);
if (g_str_has_prefix (css_path, style->style_dir) &&
@@ -603,11 +620,10 @@ variant_set_default (PidginMessageStyle* style)
}
else {
/* something about the theme has changed */
- g_free (css_path);
css_path = NULL;
}
- all = get_theme_files (PidginMessageStyle* style);
+ all = get_theme_files (style);
if (all) {
style->css_path = g_strdup (all->data);
@@ -623,24 +639,25 @@ variant_set_default (PidginMessageStyle* style)
static gboolean
plugin_load(PurplePlugin *plugin)
{
- char *cur_style;
+ PidginMessageStyle *_style; /* temp */
if (g_path_is_absolute (purple_user_dir()))
- style_dir = g_build_filename(purple_user_dir(), "style", NULL);
+ cur_style_dir = g_build_filename(purple_user_dir(), "style", NULL);
else {
char* cur = g_get_current_dir ();
- style_dir = g_build_filename (cur, purple_user_dir(), "style", NULL);
+ cur_style_dir = g_build_filename (cur, purple_user_dir(), "style", NULL);
g_free (cur);
}
-
- cur_style = pidgin_message_style_load (style_dir);
- if (!cur_style) return;
-
- uiops = pidgin_conversations_get_conv_ui_ops();
- if (uiops == NULL)
+ _style = pidgin_message_style_load (cur_style_dir);
+ if (!_style) {
+ g_free (cur_style_dir);
+ cur_style_dir = NULL;
return FALSE;
+ }
+
+ pidgin_message_style_unref (_style);
purple_signal_connect (pidgin_conversations_get_handle (),
"displaying-im-msg",
@@ -676,7 +693,7 @@ plugin_load(PurplePlugin *plugin)
{
GList* list = purple_get_conversations ();
for (;list; list = g_list_next(list))
- init_theme_for_webkit (list->data);
+ init_theme_for_webkit (list->data, cur_style_dir);
}
return TRUE;
@@ -704,8 +721,9 @@ variant_update_conversation (PurpleConversation *conv)
{
PidginConversation *gtkconv = PIDGIN_CONVERSATION (conv);
WebKitWebView *webview = WEBKIT_WEB_VIEW (gtkconv->webview);
- char* script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", css_path);
- printf ("css_path: %s\n", css_path);
+ PidginMessageStyle *style = (PidginMessageStyle*) g_object_get_data (G_OBJECT(webview), "adium-themed");
+
+ char* script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", style->css_path);
webkit_web_view_execute_script (webview, script);
g_free (script);
}
@@ -714,16 +732,28 @@ static void
variant_changed (GtkWidget* combobox, gpointer null)
{
char *name, *name_with_ext;
+ char *css_path;
GList *list;
+ PidginMessageStyle *style = pidgin_message_style_load (cur_style_dir);
+
+ g_assert (style);
+
+ /* it is possible that the theme changed by this point, so we check
+ * that first */
- g_free (css_path);
name = gtk_combo_box_get_active_text (GTK_COMBO_BOX(combobox));
name_with_ext = g_strdup_printf ("%s.css", name);
g_free (name);
- css_path = g_build_filename (style_dir, "Contents", "Resources", "Variants", name_with_ext, NULL);
+ css_path = g_build_filename (style->style_dir, "Contents", "Resources", "Variants", name_with_ext, NULL);
+
+ if (!g_file_test (css_path, G_FILE_TEST_EXISTS)) {
+ goto cleanup;
+ }
+
+ g_free (style->css_path);
+ style->css_path = g_strdup (css_path);
purple_prefs_set_string ("/plugins/gtk/adiumthemes/csspath", css_path);
- g_free (name_with_ext);
/* update each conversation */
list = purple_get_conversations ();
@@ -731,15 +761,25 @@ variant_changed (GtkWidget* combobox, gpointer null)
variant_update_conversation (list->data);
list = g_list_next(list);
}
+
+cleanup:
+ g_free (css_path);
+ g_free (name_with_ext);
+ pidgin_message_style_unref (style);
}
static GtkWidget *
-get_config_frame(PurplePlugin *plugin) {
- GList *themes = get_theme_files();
+get_config_frame(PurplePlugin *plugin)
+{
+ PidginMessageStyle *style = pidgin_message_style_load (cur_style_dir);
+ GList *themes = get_theme_files(style);
GList *theme = themes;
char *curdir = NULL;
GtkWidget *combobox = gtk_combo_box_new_text();
int def = -1, index = 0;
+ char* css_path = style->css_path;
+
+ pidgin_message_style_unref (style);
while (theme) {
char *basename = g_path_get_basename(theme->data);
--
cgit v1.2.1
From 4f4d882005045636919e6076674346d6fbcb08da Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 05:03:49 +0000
Subject: more changes, but I still can't find the stupid bug. Valgrind gives
me some information about the uninialized bytes, but it doesn't make sense.
:(x
---
pidgin/plugins/adiumthemes/webkit.c | 66 ++++++++++++++++++++++++-------------
1 file changed, 43 insertions(+), 23 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 78c6b1228c..8f308aa15f 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -48,6 +48,10 @@
#include
#include
+
+/* GObject data keys */
+#define MESSAGE_STYLE_KEY "message-style"
+
/*
* I'm going to allow a different style for each PidginConversation.
* This way I can do two things: 1) change the theme on the fly and not
@@ -78,10 +82,17 @@ static GList *style_list; /**< List of PidginMessageStyles */
static char *cur_style_dir = NULL;
static void *handle = NULL;
-static PidginMessageStyle* pidgin_message_style_new ()
+static PidginMessageStyle* pidgin_message_style_new (const char* styledir)
{
PidginMessageStyle* ret = g_new0 (PidginMessageStyle, 1);
+ GList *iter;
+
+ /* sanity check */
+ for (iter = style_list; iter; iter = g_list_next (iter))
+ g_assert (!g_str_equal (((PidginMessageStyle*)iter->data)->style_dir, styledir));
+
ret->ref_counter ++;
+ ret->style_dir = g_strdup (styledir);
style_list = g_list_append (style_list, ret);
return ret;
@@ -89,6 +100,8 @@ static PidginMessageStyle* pidgin_message_style_new ()
static void pidgin_message_style_unref (PidginMessageStyle *style)
{
+ if (!style) return;
+
style->ref_counter--;
if (style->ref_counter) return;
@@ -124,8 +137,7 @@ pidgin_message_style_load (const char* styledir)
}
/* else we need to load it */
- style = pidgin_message_style_new ();
- style->style_dir = g_strdup (styledir);
+ style = pidgin_message_style_new (styledir);
/* find some variant file (or load from user's settings) */
variant_set_default (style);
@@ -166,8 +178,6 @@ pidgin_message_style_load (const char* styledir)
g_file_get_contents(file, &style->footer_html, NULL, NULL);
g_free (file);
-
-
file = g_build_filename(styledir, "Contents", "Resources", "Incoming", "Content.html", NULL);
if (!g_file_get_contents(file, &style->incoming_content_html, NULL, NULL)) {
pidgin_message_style_unref (style);
@@ -427,7 +437,10 @@ init_theme_for_webkit (PurpleConversation *conv, char *style_dir)
char* basedir;
char* baseuri;
- PidginMessageStyle *style;
+ PidginMessageStyle *style, *oldStyle;
+ oldStyle = g_object_get_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY);
+ if (oldStyle) return;
+
style = pidgin_message_style_load (style_dir);
g_assert (style);
@@ -437,10 +450,10 @@ init_theme_for_webkit (PurpleConversation *conv, char *style_dir)
footer = replace_header_tokens(style->footer_html, strlen(style->footer_html), conv);
template = replace_template_tokens(style, style->template_html, strlen(style->template_html) + strlen(style->header_html), header, footer);
- if (!g_object_get_data (G_OBJECT(webkit), "adium-themed"))
- webkit_web_view_load_string(WEBKIT_WEB_VIEW(webkit), template, "text/html", "UTF-8", baseuri);
-
- g_object_set_data (G_OBJECT(webkit), "adium-themed", style);
+ webkit_web_view_load_string(WEBKIT_WEB_VIEW(webkit), template, "text/html", "UTF-8", baseuri);
+ pidgin_message_style_unref (oldStyle);
+ g_object_set_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY, style);
+
g_free (basedir);
g_free (baseuri);
@@ -455,10 +468,11 @@ static void
finalize_theme_for_webkit (PurpleConversation *conv)
{
GtkWidget *webview = PIDGIN_CONVERSATION(conv)->webview;
- PidginMessageStyle *style = g_object_get_data (G_OBJECT(webview), "adium-themed");
+ PidginMessageStyle *style = g_object_get_data (G_OBJECT(webview), MESSAGE_STYLE_KEY);
webkit_web_view_load_string(WEBKIT_WEB_VIEW(webview), "", "text/html", "UTF-8", "");
- g_object_set_data (G_OBJECT(webview), "adium-themed", NULL);
+
+ g_object_set_data (G_OBJECT(webview), MESSAGE_STYLE_KEY, NULL);
pidgin_message_style_unref (style);
}
@@ -505,7 +519,7 @@ static gboolean webkit_on_displaying_im_msg (PurpleAccount *account,
webkit = get_webkit(conv);
stripped = g_strdup(message);
- style = g_object_get_data (G_OBJECT (webkit), "adium-themed");
+ style = g_object_get_data (G_OBJECT (webkit), MESSAGE_STYLE_KEY);
if (flags & PURPLE_MESSAGE_SEND && old_flags & PURPLE_MESSAGE_SEND) {
message_html = style->outgoing_next_content_html;
@@ -721,9 +735,12 @@ variant_update_conversation (PurpleConversation *conv)
{
PidginConversation *gtkconv = PIDGIN_CONVERSATION (conv);
WebKitWebView *webview = WEBKIT_WEB_VIEW (gtkconv->webview);
- PidginMessageStyle *style = (PidginMessageStyle*) g_object_get_data (G_OBJECT(webview), "adium-themed");
+ PidginMessageStyle *style = (PidginMessageStyle*) g_object_get_data (G_OBJECT(webview), MESSAGE_STYLE_KEY);
+ char *script;
+
+ g_assert (style && style->css_path);
- char* script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", style->css_path);
+ script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", style->css_path);
webkit_web_view_execute_script (webview, script);
g_free (script);
}
@@ -772,19 +789,19 @@ static GtkWidget *
get_config_frame(PurplePlugin *plugin)
{
PidginMessageStyle *style = pidgin_message_style_load (cur_style_dir);
- GList *themes = get_theme_files(style);
- GList *theme = themes;
+ GList *variants = get_theme_files(style);
+ GList *iter = variants;
char *curdir = NULL;
GtkWidget *combobox = gtk_combo_box_new_text();
int def = -1, index = 0;
- char* css_path = style->css_path;
+ char* css_path = g_strdup (style->css_path);
pidgin_message_style_unref (style);
- while (theme) {
- char *basename = g_path_get_basename(theme->data);
- char *dirname = g_path_get_dirname(theme->data);
- if (!curdir || strcmp(curdir, dirname)) {
+ for (; iter; iter = g_list_next (iter)) {
+ char *basename = g_path_get_basename(iter->data);
+ char *dirname = g_path_get_dirname(iter->data);
+ if (!curdir || !g_str_equal (curdir, dirname)) {
char *plist, *plist_xml;
gsize plist_len;
xmlnode *node;
@@ -818,12 +835,15 @@ get_config_frame(PurplePlugin *plugin)
if (g_str_has_suffix (css_path, basename))
def = index;
index ++;
- theme = theme->next;
+
+ g_free (basename);
+ g_free (dirname);
}
gtk_combo_box_set_active (GTK_COMBO_BOX(combobox), def);
g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(variant_changed), NULL);
+ g_free (css_path);
return combobox;
}
--
cgit v1.2.1
From a46e00074ed8eee7c7d027d370cd7089996547c5 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 05:36:10 +0000
Subject: woo, fixed the bug. Now things are looking wonderfully stable.
---
pidgin/plugins/adiumthemes/webkit.c | 44 +++++++++++++++++++++++--------------
1 file changed, 27 insertions(+), 17 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 8f308aa15f..c26c59ac61 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -89,9 +89,9 @@ static PidginMessageStyle* pidgin_message_style_new (const char* styledir)
/* sanity check */
for (iter = style_list; iter; iter = g_list_next (iter))
- g_assert (!g_str_equal (((PidginMessageStyle*)iter->data)->style_dir, styledir));
+ g_assert (!g_str_equal (((PidginMessageStyle*)iter->data)->style_dir, styledir));
- ret->ref_counter ++;
+ ret->ref_counter = 1;
ret->style_dir = g_strdup (styledir);
style_list = g_list_append (style_list, ret);
@@ -101,6 +101,7 @@ static PidginMessageStyle* pidgin_message_style_new (const char* styledir)
static void pidgin_message_style_unref (PidginMessageStyle *style)
{
if (!style) return;
+ g_assert (style->ref_counter > 0);
style->ref_counter--;
if (style->ref_counter) return;
@@ -121,6 +122,7 @@ static void pidgin_message_style_unref (PidginMessageStyle *style)
}
static void variant_set_default (PidginMessageStyle* style);
+
static PidginMessageStyle*
pidgin_message_style_load (const char* styledir)
{
@@ -130,18 +132,17 @@ pidgin_message_style_load (const char* styledir)
PidginMessageStyle *style = NULL;
g_assert (styledir);
-
- for (; cur; cur = g_list_next (cur)) {
- if (g_str_equal (styledir, ((PidginMessageStyle*) cur->data)->style_dir))
- return (PidginMessageStyle*) cur->data;
+ for (cur = style_list; cur; cur = g_list_next (cur)) {
+ style = (PidginMessageStyle*) cur->data;
+ if (g_str_equal (styledir, style->style_dir)) {
+ style->ref_counter++;
+ return style;
+ }
}
/* else we need to load it */
style = pidgin_message_style_new (styledir);
- /* find some variant file (or load from user's settings) */
- variant_set_default (style);
-
/* load all other files */
/* The template path can either come from the theme, or can
@@ -187,7 +188,7 @@ pidgin_message_style_load (const char* styledir)
g_free (file);
- /* according to the spec, the following are not necessary files */
+ /* according to the spec, the following are optional files */
file = g_build_filename(styledir, "Contents", "Resources", "Incoming", "NextContent.html", NULL);
if (!g_file_get_contents(file, &style->incoming_next_content_html, NULL, NULL)) {
style->incoming_next_content_html = g_strdup (style->incoming_content_html);
@@ -205,6 +206,9 @@ pidgin_message_style_load (const char* styledir)
style->outgoing_next_content_html = g_strdup (style->outgoing_content_html);
}
+ /* find some variant file (or load from user's settings) */
+ variant_set_default (style);
+
return style;
}
@@ -423,6 +427,9 @@ get_webkit(PurpleConversation *conv)
/**
* Called when either a new PurpleConversation is created
* or when a PidginConversation changes its active PurpleConversation
+ * This will not change the theme if the theme is already set.
+ * (This is to prevent accidental theme changes if a new
+ * PurpleConversation gets added.
*
* FIXME: it's not at all clear to me as to how
* Adium themes handle the case when the PurpleConversation
@@ -439,6 +446,7 @@ init_theme_for_webkit (PurpleConversation *conv, char *style_dir)
char* baseuri;
PidginMessageStyle *style, *oldStyle;
oldStyle = g_object_get_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY);
+
if (oldStyle) return;
style = pidgin_message_style_load (style_dir);
@@ -451,7 +459,7 @@ init_theme_for_webkit (PurpleConversation *conv, char *style_dir)
template = replace_template_tokens(style, style->template_html, strlen(style->template_html) + strlen(style->header_html), header, footer);
webkit_web_view_load_string(WEBKIT_WEB_VIEW(webkit), template, "text/html", "UTF-8", baseuri);
- pidgin_message_style_unref (oldStyle);
+
g_object_set_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY, style);
@@ -520,6 +528,7 @@ static gboolean webkit_on_displaying_im_msg (PurpleAccount *account,
stripped = g_strdup(message);
style = g_object_get_data (G_OBJECT (webkit), MESSAGE_STYLE_KEY);
+ g_assert (style);
if (flags & PURPLE_MESSAGE_SEND && old_flags & PURPLE_MESSAGE_SEND) {
message_html = style->outgoing_next_content_html;
@@ -545,14 +554,14 @@ static gboolean webkit_on_displaying_im_msg (PurpleAccount *account,
wk_script->script = script;
wk_script->webkit = webkit;
- g_idle_add(purple_webkit_execute_script, wk_script);
+ purple_webkit_execute_script (wk_script);
g_free(smileyed);
g_free(msg);
g_free(stripped);
g_free(escape);
- return TRUE; /* GtkConv should not handle this guy */
+ return TRUE; /* GtkConv should not handle this IM */
}
static gboolean webkit_on_displaying_chat_msg (PurpleAccount *account,
@@ -562,12 +571,12 @@ static gboolean webkit_on_displaying_chat_msg (PurpleAccount *account,
PurpleMessageFlags flags,
gpointer userdata)
{
- /* handle exactly like an IM message */
+ /* handle exactly like an IM message for now */
return webkit_on_displaying_im_msg (account, who, message, conv, flags, NULL);
}
static void
-webkit_on_converstation_displayed (PidginConversation *gtkconv, gpointer data)
+webkit_on_conversation_displayed (PidginConversation *gtkconv, gpointer data)
{
init_theme_for_webkit (gtkconv->active_conv, cur_style_dir);
}
@@ -583,7 +592,8 @@ webkit_on_conversation_hiding (PidginConversation *gtkconv, gpointer data)
{
/*
* I'm not sure if I need to do anything here, but let's keep
- * this anyway
+ * this anyway. (FIXME: have to catch a signal on the WebView
+ * when the WebView closes.)
*/
}
@@ -688,7 +698,7 @@ plugin_load(PurplePlugin *plugin)
purple_signal_connect (pidgin_conversations_get_handle (),
"conversation-displayed",
webkit_plugin_get_handle (),
- PURPLE_CALLBACK(webkit_on_converstation_displayed),
+ PURPLE_CALLBACK(webkit_on_conversation_displayed),
NULL);
purple_signal_connect (pidgin_conversations_get_handle (),
--
cgit v1.2.1
From d38cbbc17fa4d1d973420cc91c70f85ec42ed8f4 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 05:56:08 +0000
Subject: Cleanly handle webkit destroy events.
---
pidgin/plugins/adiumthemes/webkit.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index c26c59ac61..e093a37160 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -122,6 +122,7 @@ static void pidgin_message_style_unref (PidginMessageStyle *style)
}
static void variant_set_default (PidginMessageStyle* style);
+static void webkit_on_webview_destroy (GtkObject* obj, gpointer data);
static PidginMessageStyle*
pidgin_message_style_load (const char* styledir)
@@ -462,6 +463,8 @@ init_theme_for_webkit (PurpleConversation *conv, char *style_dir)
g_object_set_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY, style);
+ /* I need to unref this style when the webkit object destroys */
+ g_signal_connect (G_OBJECT(webkit), "destroy", G_CALLBACK(webkit_on_webview_destroy), style);
g_free (basedir);
g_free (baseuri);
@@ -484,6 +487,13 @@ finalize_theme_for_webkit (PurpleConversation *conv)
pidgin_message_style_unref (style);
}
+static void
+webkit_on_webview_destroy (GtkObject *object, gpointer data)
+{
+ pidgin_message_style_unref ((PidginMessageStyle*) data);
+ g_object_set_data (G_OBJECT(object), MESSAGE_STYLE_KEY, NULL);
+}
+
struct webkit_script {
GtkWidget *webkit;
char *script;
--
cgit v1.2.1
From c3737c4263ec0f9aef9e38066f63e274efaf24f5 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 07:33:21 +0000
Subject: safely execute JS scripts only after loading is done. Untested code
as of now, will test it in next commit.
---
pidgin/gtkwebview.c | 83 ++++++++++++++++++++++++++++++++-----
pidgin/gtkwebview.h | 23 +++++++---
pidgin/plugins/adiumthemes/webkit.c | 2 +-
3 files changed, 91 insertions(+), 17 deletions(-)
diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
index 0f78523ff7..b791312278 100644
--- a/pidgin/gtkwebview.c
+++ b/pidgin/gtkwebview.c
@@ -41,9 +41,19 @@
static WebKitWebViewClass *parent_class = NULL;
+struct GtkWebViewPriv {
+ GHashTable *images; /**< a map from id to temporary file for the image */
+ gboolean empty; /**< whether anything has been appended **/
+
+ /* JS execute queue */
+ GQueue *js_queue;
+ gboolean is_loading;
+};
+
GtkWidget* gtk_webview_new ()
{
- return GTK_WIDGET(g_object_new(gtk_webview_get_type(), NULL));
+ GtkWebView* ret = GTK_WEBVIEW (g_object_new(gtk_webview_get_type(), NULL));
+ return GTK_WIDGET (ret);
}
static char*
@@ -53,10 +63,10 @@ get_image_filename_from_id (GtkWebView* view, int id)
FILE *file;
PurpleStoredImage* img;
- if (!view->images)
- view->images = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
+ if (!view->priv->images)
+ view->priv->images = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
- filename = (char*) g_hash_table_lookup (view->images, GINT_TO_POINTER (id));
+ filename = (char*) g_hash_table_lookup (view->priv->images, GINT_TO_POINTER (id));
if (filename) return filename;
/* else get from img store */
@@ -65,7 +75,7 @@ get_image_filename_from_id (GtkWebView* view, int id)
img = purple_imgstore_find_by_id (id);
fwrite (purple_imgstore_get_data (img), purple_imgstore_get_size (img), 1, file);
- g_hash_table_insert (view->images, GINT_TO_POINTER (id), filename);
+ g_hash_table_insert (view->priv->images, GINT_TO_POINTER (id), filename);
fclose (file);
return filename;
}
@@ -79,9 +89,9 @@ clear_single_image (gpointer key, gpointer value, gpointer userdata)
static void
clear_images (GtkWebView* view)
{
- if (!view->images) return;
- g_hash_table_foreach (view->images, clear_single_image, NULL);
- g_hash_table_unref (view->images);
+ if (!view->priv->images) return;
+ g_hash_table_foreach (view->priv->images, clear_single_image, NULL);
+ g_hash_table_unref (view->priv->images);
}
/*
@@ -146,6 +156,7 @@ static void
gtk_webview_finalize (GObject *view)
{
clear_images (GTK_WEBVIEW (view));
+ g_free (GTK_WEBVIEW(view)->priv);
G_OBJECT_CLASS (parent_class)->finalize (G_OBJECT(view));
}
@@ -173,6 +184,39 @@ webview_link_clicked (WebKitWebView *view,
return TRUE;
}
+static gboolean
+process_js_script_queue (GtkWebView *view)
+{
+ char *script;
+ if (view->priv->is_loading) return FALSE; /* we will be called when loaded */
+ if (!view->priv->js_queue || g_queue_is_empty (view->priv->js_queue))
+ return FALSE; /* nothing to do! */
+
+ script = g_queue_pop_head (view->priv->js_queue);
+ webkit_web_view_execute_script (WEBKIT_WEB_VIEW(view), script);
+ g_free (script);
+
+ return TRUE; /* there may be more for now */
+}
+
+static void
+webview_load_started (WebKitWebView *view,
+ WebKitWebFrame *frame,
+ gpointer userdata)
+{
+ /* is there a better way to test for is_loading? */
+ GTK_WEBVIEW(view)->priv->is_loading = true;
+}
+
+static void
+webview_load_finished (WebKitWebView *view,
+ WebKitWebFrame *frame,
+ gpointer userdata)
+{
+ GTK_WEBVIEW(view)->priv->is_loading = false;
+ g_idle_add ((GSourceFunc) process_js_script_queue, view);
+}
+
char*
gtk_webview_execute_script (GtkWebView *view, const char *script)
{
@@ -192,13 +236,30 @@ gtk_webview_execute_script (GtkWebView *view, const char *script)
return cstr;
}
+void
+gtk_webview_safe_execute_script (GtkWebView *view, const char* script)
+{
+ g_queue_push_tail (view->priv->js_queue, g_strdup (script));
+ g_idle_add ((GSourceFunc)process_js_script_queue, view);
+}
+
static void
gtk_webview_init (GtkWebView *view, gpointer userdata)
{
+ view->priv = g_new0 (struct GtkWebViewPriv, 1);
g_signal_connect (view, "navigation-policy-decision-requested",
G_CALLBACK (webview_link_clicked),
view);
- view->empty = TRUE;
+
+ g_signal_connect (view, "load-started",
+ G_CALLBACK (webview_load_started),
+ view);
+
+ g_signal_connect (view, "load-finished",
+ G_CALLBACK (webview_load_finished),
+ view);
+
+ view->priv->empty = TRUE;
}
@@ -254,7 +315,7 @@ gtk_webview_append_html (GtkWebView* view, const char* html)
char* script = g_strdup_printf ("document.write(%s)", escaped);
printf ("script: %s\n", script);
webkit_web_view_execute_script (WEBKIT_WEB_VIEW (view), script);
- view->empty = FALSE;
+ view->priv->empty = FALSE;
g_free (script);
g_free (escaped);
}
@@ -273,7 +334,7 @@ gtk_webview_get_text (GtkWebView *view)
gboolean gtk_webview_is_empty (GtkWebView *view)
{
- return view->empty;
+ return view->priv->empty;
}
GType gtk_webview_get_type ()
diff --git a/pidgin/gtkwebview.h b/pidgin/gtkwebview.h
index bd0df4c770..df83b8ad6b 100644
--- a/pidgin/gtkwebview.h
+++ b/pidgin/gtkwebview.h
@@ -35,17 +35,17 @@
#define GTK_WEBVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_WEBVIEW, GtkWebView))
#define GTK_WEBVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_WEBVIEW, GtkWebViewClass))
#define GTK_IS_WEBVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_WEBVIEW))
-#define GTK_IS_IMHTML_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_WEBVIEW))
+#define GTK_IS_WEBVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_WEBVIEW))
+struct GtkWebViewPriv;
+
struct _GtkWebView
{
WebKitWebView webkit_web_view;
/*< private >*/
- GHashTable *images; /**< a map from id to temporary file for the image */
- gboolean empty; /**< whether anything has been appended **/
- char *script_return; /**< the last value returned from a script **/
+ struct GtkWebViewPriv* priv;
};
typedef struct _GtkWebView GtkWebView;
@@ -106,7 +106,8 @@ gboolean gtk_webview_is_empty (GtkWebView *webview);
* Executes javascript and returns the answer of the script
* formatted as string. The return value needs to be freed using
* g_free. If the return values is not required you may instead
- * use webkit_web_view_execute_script.
+ * use webkit_web_view_execute_script, or even better
+ * gtk_webview_safe_execute_script.
*
* @param webview The GtkWebView object
* @param script The JavaScript to execute
@@ -115,6 +116,18 @@ gboolean gtk_webview_is_empty (GtkWebView *webview);
*/
char* gtk_webview_execute_script (GtkWebView *webview, const char *script);
+/**
+ * Execute the JavaScript only after the webkit_webview_load_string
+ * loads completely. We also guarantee that the scripts are executed
+ * in the order they are called here.This is useful to avoid race
+ * conditions when calls JS functions immediately after opening the
+ * page.
+ *
+ * @param webview the GtkWebView object
+ * @param script the script to execute
+ */
+void gtk_webview_safe_execute_script (GtkWebView *webview, const char* script);
+
/**
* Get the current contents of the GtkWebView object.
*
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index e093a37160..d276a9a49c 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -564,7 +564,7 @@ static gboolean webkit_on_displaying_im_msg (PurpleAccount *account,
wk_script->script = script;
wk_script->webkit = webkit;
- purple_webkit_execute_script (wk_script);
+ g_idle_add (purple_webkit_execute_script, wk_script);
g_free(smileyed);
g_free(msg);
--
cgit v1.2.1
From f335e30bc23d9dea4f917f6c9760473d22111804 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 07:42:54 +0000
Subject: Yep, tested, and changed some code from previous commit. This is a
hard to test code, so I just hope it works flawlessly. :)
---
pidgin/gtkwebview.c | 7 +++++++
pidgin/plugins/adiumthemes/webkit.c | 26 +++-----------------------
2 files changed, 10 insertions(+), 23 deletions(-)
diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
index b791312278..b372072e06 100644
--- a/pidgin/gtkwebview.c
+++ b/pidgin/gtkwebview.c
@@ -155,6 +155,12 @@ replace_img_id_with_src (GtkWebView *view, const char* html)
static void
gtk_webview_finalize (GObject *view)
{
+ gpointer temp;
+
+ while ((temp = g_queue_pop_head (GTK_WEBVIEW(view)->priv->js_queue)))
+ g_free (temp);
+ g_queue_free (GTK_WEBVIEW(view)->priv->js_queue);
+
clear_images (GTK_WEBVIEW (view));
g_free (GTK_WEBVIEW(view)->priv);
G_OBJECT_CLASS (parent_class)->finalize (G_OBJECT(view));
@@ -260,6 +266,7 @@ gtk_webview_init (GtkWebView *view, gpointer userdata)
view);
view->priv->empty = TRUE;
+ view->priv->js_queue = g_queue_new ();
}
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index d276a9a49c..fb1868d8d5 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -494,22 +494,6 @@ webkit_on_webview_destroy (GtkObject *object, gpointer data)
g_object_set_data (G_OBJECT(object), MESSAGE_STYLE_KEY, NULL);
}
-struct webkit_script {
- GtkWidget *webkit;
- char *script;
-};
-
-static gboolean purple_webkit_execute_script(gpointer _script)
-{
- struct webkit_script *script = (struct webkit_script*) _script;
- printf ("%s\n", script->script);
- webkit_web_view_execute_script(WEBKIT_WEB_VIEW(script->webkit), script->script);
- g_free(script->script);
- g_free(script);
- return FALSE;
-}
-
-
static gboolean webkit_on_displaying_im_msg (PurpleAccount *account,
const char* name,
char **pmessage,
@@ -529,7 +513,6 @@ static gboolean webkit_on_displaying_im_msg (PurpleAccount *account,
char *smileyed;
time_t mtime = time (NULL); /* FIXME: this should come from the write_conv calback, but the signal doesn't pass this to me */
- struct webkit_script *wk_script;
PurpleMessageFlags old_flags = GPOINTER_TO_INT(purple_conversation_get_data(conv, "webkit-lastflags"));
PidginMessageStyle *style;
@@ -560,12 +543,9 @@ static gboolean webkit_on_displaying_im_msg (PurpleAccount *account,
escape = gtk_webview_quote_js_string (msg);
script = g_strdup_printf("%s(%s)", func, escape);
- wk_script = g_new0(struct webkit_script, 1);
- wk_script->script = script;
- wk_script->webkit = webkit;
-
- g_idle_add (purple_webkit_execute_script, wk_script);
+ gtk_webview_safe_execute_script (GTK_WEBVIEW (webkit), script);
+ g_free(script);
g_free(smileyed);
g_free(msg);
g_free(stripped);
@@ -761,7 +741,7 @@ variant_update_conversation (PurpleConversation *conv)
g_assert (style && style->css_path);
script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", style->css_path);
- webkit_web_view_execute_script (webview, script);
+ gtk_webview_safe_execute_script (GTK_WEBVIEW(webview), script);
g_free (script);
}
--
cgit v1.2.1
From 4df8e5ca79c85a721f3fcf2c4e30618abace2bc2 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 07:47:37 +0000
Subject: removed some ugly pointless pieces of code.
---
pidgin/gtkwebview.c | 31 -------------------------------
pidgin/gtkwebview.h | 32 --------------------------------
2 files changed, 63 deletions(-)
diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
index b372072e06..dbdea56428 100644
--- a/pidgin/gtkwebview.c
+++ b/pidgin/gtkwebview.c
@@ -223,25 +223,6 @@ webview_load_finished (WebKitWebView *view,
g_idle_add ((GSourceFunc) process_js_script_queue, view);
}
-char*
-gtk_webview_execute_script (GtkWebView *view, const char *script)
-{
- JSStringRef js_script = JSStringCreateWithUTF8CString (script);
- JSContextRef ctxt = webkit_web_frame_get_global_context (
- webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view))
- );
- JSValueRef ret = JSEvaluateScript (ctxt, js_script, NULL, NULL, 0, NULL);
- JSStringRef ret_as_str = JSValueToStringCopy (ctxt, ret, NULL);
-
- size_t cstr_len = JSStringGetMaximumUTF8CStringSize (ret_as_str);
- char *cstr = g_new0(char, cstr_len + 1);
-
- JSStringGetUTF8CString (ret_as_str, cstr, cstr_len);
-
- /* TODO: I'm not sure what, if at all, I need to free here! */
- return cstr;
-}
-
void
gtk_webview_safe_execute_script (GtkWebView *view, const char* script)
{
@@ -327,18 +308,6 @@ gtk_webview_append_html (GtkWebView* view, const char* html)
g_free (escaped);
}
-char*
-gtk_webview_get_markup (GtkWebView *view)
-{
- return gtk_webview_execute_script (view, "document.body.innerHTML");
-}
-
-char*
-gtk_webview_get_text (GtkWebView *view)
-{
- return gtk_webview_execute_script (view, "document.body.textContent");
-}
-
gboolean gtk_webview_is_empty (GtkWebView *view)
{
return view->priv->empty;
diff --git a/pidgin/gtkwebview.h b/pidgin/gtkwebview.h
index df83b8ad6b..25fee3b9a4 100644
--- a/pidgin/gtkwebview.h
+++ b/pidgin/gtkwebview.h
@@ -102,20 +102,6 @@ void gtk_webview_load_html_string_with_imgstore (GtkWebView* webview, const char
*/
gboolean gtk_webview_is_empty (GtkWebView *webview);
-/**
- * Executes javascript and returns the answer of the script
- * formatted as string. The return value needs to be freed using
- * g_free. If the return values is not required you may instead
- * use webkit_web_view_execute_script, or even better
- * gtk_webview_safe_execute_script.
- *
- * @param webview The GtkWebView object
- * @param script The JavaScript to execute
- *
- * @return the return value of the script.
- */
-char* gtk_webview_execute_script (GtkWebView *webview, const char *script);
-
/**
* Execute the JavaScript only after the webkit_webview_load_string
* loads completely. We also guarantee that the scripts are executed
@@ -128,24 +114,6 @@ char* gtk_webview_execute_script (GtkWebView *webview, const char *script);
*/
void gtk_webview_safe_execute_script (GtkWebView *webview, const char* script);
-/**
- * Get the current contents of the GtkWebView object.
- *
- * @param webview The GtkWebView object
- *
- * @return a string with the contents. Needs to be g_free'd after use.
- */
-char* gtk_webview_get_markup (GtkWebView *webview);
-
-/**
- * Returns the contents of the GtkWebView object, stripped of markups
- *
- * @param webview The GtkWebView object
- *
- * @return a string with the contents. Needs to be g_free'd after use.
- */
-char* gtk_webview_get_text (GtkWebView *view);
-
/**
* A convenience routine to quote a string for use as a JavaScript
* string. For instance, "hello 'world'" becomes "'hello \\'world\\''"
--
cgit v1.2.1
From 5199370ec56b3132986e1ba521b32aabe2a6d9c9 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 07:49:37 +0000
Subject: get_theme_files --> get_variant_files.
---
pidgin/plugins/adiumthemes/webkit.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index fb1868d8d5..86f8e978f2 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -591,7 +591,7 @@ webkit_on_conversation_hiding (PidginConversation *gtkconv, gpointer data)
* Get each of the files corresponding to each variant.
*/
static GList*
-get_theme_files(PidginMessageStyle *style)
+get_variant_files(PidginMessageStyle *style)
{
GList *ret = NULL;
GDir *variants;
@@ -637,7 +637,7 @@ variant_set_default (PidginMessageStyle* style)
css_path = NULL;
}
- all = get_theme_files (style);
+ all = get_variant_files (style);
if (all) {
style->css_path = g_strdup (all->data);
@@ -789,7 +789,7 @@ static GtkWidget *
get_config_frame(PurplePlugin *plugin)
{
PidginMessageStyle *style = pidgin_message_style_load (cur_style_dir);
- GList *variants = get_theme_files(style);
+ GList *variants = get_variant_files(style);
GList *iter = variants;
char *curdir = NULL;
GtkWidget *combobox = gtk_combo_box_new_text();
--
cgit v1.2.1
From 232be787e07b46b84d79e7e5e16eb43a3b73e2dc Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 08:17:12 +0000
Subject: partial work towards theme selection.
---
pidgin/plugins/adiumthemes/webkit.c | 63 ++++++++++++++++++++++++++++++++++++-
1 file changed, 62 insertions(+), 1 deletion(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 86f8e978f2..84833f58d1 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -587,6 +587,55 @@ webkit_on_conversation_hiding (PidginConversation *gtkconv, gpointer data)
*/
}
+static GList*
+get_dir_dir_list (const char* dirname)
+{
+ GList *ret = NULL;
+ GDir *dir = g_dir_open (dirname, 0, NULL);
+ const char* subdir;
+
+ if (!dir) return NULL;
+ while ((subdir = g_dir_read_name (dir))) {
+ ret = g_list_append (ret, g_build_filename (dirname, subdir, NULL));
+ }
+
+ g_dir_close (dir);
+ return ret;
+}
+
+/**
+ * Get me a list of all the available themes specified by their
+ * directories. I don't guarrantee that these are valid themes, just
+ * that they are in the directories for themes.
+ */
+static GList*
+get_theme_directory_list ()
+{
+ char *user_dir, *user_style_dir, *global_style_dir;
+ GList *list1, *list2;
+
+ user_dir = g_strdup (purple_user_dir ());
+ if (!g_path_is_absolute (user_dir)) {
+ char* cur = g_get_current_dir ();
+ g_free (user_dir);
+ user_dir = g_build_filename (cur, purple_user_dir(), NULL);
+ g_free (cur);
+ }
+
+ user_style_dir = g_build_filename (user_dir, "styles", NULL);
+ global_style_dir = g_build_filename (DATADIR, "pidgin", "styles", NULL);
+
+ list1 = get_dir_dir_list (user_style_dir);
+ list2 = get_dir_dir_list (global_style_dir);
+
+ g_free (global_style_dir);
+ g_free (user_style_dir);
+ g_free (user_dir);
+
+ return g_list_concat (list1, list2);
+}
+
+
/**
* Get each of the files corresponding to each variant.
*/
@@ -658,6 +707,9 @@ plugin_load(PurplePlugin *plugin)
if (g_path_is_absolute (purple_user_dir()))
cur_style_dir = g_build_filename(purple_user_dir(), "style", NULL);
else {
+
+
+
char* cur = g_get_current_dir ();
cur_style_dir = g_build_filename (cur, purple_user_dir(), "style", NULL);
g_free (cur);
@@ -786,7 +838,7 @@ cleanup:
}
static GtkWidget *
-get_config_frame(PurplePlugin *plugin)
+get_variant_config_frame()
{
PidginMessageStyle *style = pidgin_message_style_load (cur_style_dir);
GList *variants = get_variant_files(style);
@@ -847,6 +899,15 @@ get_config_frame(PurplePlugin *plugin)
return combobox;
}
+static GtkWidget*
+get_config_frame(PurplePlugin* plugin)
+{
+ GtkWidget *vbox = gtk_vbox_new (TRUE, 0);
+
+ gtk_box_pack_end (GTK_BOX(vbox), get_variant_config_frame (), TRUE, TRUE, 0);
+ return vbox;
+}
+
PidginPluginUiInfo ui_info =
{
get_config_frame,
--
cgit v1.2.1
From db7d354927afd5b0b28e32e75564caa790b1cbf4 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 08:20:05 +0000
Subject: removed the fixme.
---
pidgin/plugins/adiumthemes/webkit.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 84833f58d1..6b1728bbf1 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -582,8 +582,7 @@ webkit_on_conversation_hiding (PidginConversation *gtkconv, gpointer data)
{
/*
* I'm not sure if I need to do anything here, but let's keep
- * this anyway. (FIXME: have to catch a signal on the WebView
- * when the WebView closes.)
+ * this anyway.
*/
}
--
cgit v1.2.1
From b26b45ae455937f13ec278d8557f43f8f77018fa Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 08:40:12 +0000
Subject: theme detection.
---
pidgin/plugins/adiumthemes/webkit.c | 57 ++++++++++++++++++++++---------------
1 file changed, 34 insertions(+), 23 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 6b1728bbf1..c3f5a35ac9 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -38,6 +38,7 @@
/* Purple headers */
#include
+#include
#include
#include
#include
@@ -608,7 +609,7 @@ get_dir_dir_list (const char* dirname)
* that they are in the directories for themes.
*/
static GList*
-get_theme_directory_list ()
+get_style_directory_list ()
{
char *user_dir, *user_style_dir, *global_style_dir;
GList *list1, *list2;
@@ -634,6 +635,36 @@ get_theme_directory_list ()
return g_list_concat (list1, list2);
}
+/**
+ * use heuristics or previous user options to figure out what
+ * theme to use as default in this Pidgin instance.
+ */
+static void
+style_set_default ()
+{
+ GList* styles = get_style_directory_list (), *iter;
+ const char *stylepath = purple_prefs_get_string ("/plugins/gtk/adiumthemes/stylepath");
+ g_assert (cur_style_dir == NULL);
+
+ if (stylepath)
+ styles = g_list_prepend (styles, g_strdup (stylepath));
+
+ /* pick any one that works. Note that we have first preference
+ * for the one in the userdir */
+ for (iter = styles; iter; iter = g_list_next (iter)) {
+ PidginMessageStyle *style = pidgin_message_style_load (iter->data);
+ if (style) {
+ cur_style_dir = (char*) g_strdup (iter->data);
+ pidgin_message_style_unref (style);
+ break;
+ }
+ purple_debug_info ("webkit", "Style %s is invalid\n", (char*) iter->data);
+ }
+
+ for (iter = styles; iter; iter = g_list_next (iter))
+ g_free (iter->data);
+ g_list_free (styles);
+}
/**
* Get each of the files corresponding to each variant.
@@ -701,28 +732,8 @@ variant_set_default (PidginMessageStyle* style)
static gboolean
plugin_load(PurplePlugin *plugin)
{
- PidginMessageStyle *_style; /* temp */
-
- if (g_path_is_absolute (purple_user_dir()))
- cur_style_dir = g_build_filename(purple_user_dir(), "style", NULL);
- else {
-
-
-
- char* cur = g_get_current_dir ();
- cur_style_dir = g_build_filename (cur, purple_user_dir(), "style", NULL);
- g_free (cur);
- }
-
-
- _style = pidgin_message_style_load (cur_style_dir);
- if (!_style) {
- g_free (cur_style_dir);
- cur_style_dir = NULL;
- return FALSE;
- }
-
- pidgin_message_style_unref (_style);
+ style_set_default ();
+ if (!cur_style_dir) return FALSE; /* couldn't find a style */
purple_signal_connect (pidgin_conversations_get_handle (),
"displaying-im-msg",
--
cgit v1.2.1
From 27ee6e1f7c15602243a42cbb70b296552e56a19b Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 08:59:09 +0000
Subject: some code to get a list of styles and blah blah.
---
pidgin/plugins/adiumthemes/webkit.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index c3f5a35ac9..81cffde7f1 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -792,6 +792,27 @@ plugin_unload(PurplePlugin *plugin)
}
+static GtkWidget*
+get_style_config_frame ()
+{
+ GtkWidget *combobox = gtk_combo_box_new_text ();
+ GList *styles = get_style_directory_list (), *iter;
+ int index = 0, selected = 0;
+
+ for (iter = styles; iter; iter = g_list_next (iter), index++) {
+ PidginMessageStyle *style = pidgin_message_style_load (iter->data);
+
+ if (style) {
+ gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), iter->data);
+ if (g_str_equal (iter->data, cur_style_dir))
+ selected = index;
+ pidgin_message_style_unref (style);
+ }
+ }
+ gtk_combo_box_set_active (GTK_COMBO_BOX(combobox), selected);
+ return combobox;
+}
+
static void
variant_update_conversation (PurpleConversation *conv)
{
@@ -914,6 +935,7 @@ get_config_frame(PurplePlugin* plugin)
{
GtkWidget *vbox = gtk_vbox_new (TRUE, 0);
+ gtk_box_pack_start (GTK_BOX(vbox), get_style_config_frame (), TRUE, TRUE, 0);
gtk_box_pack_end (GTK_BOX(vbox), get_variant_config_frame (), TRUE, TRUE, 0);
return vbox;
}
--
cgit v1.2.1
From aa8f5672d7ad36734f22c2dda4ebad1e3dadd27d Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 10:03:47 +0000
Subject: some code for style_changed and also default any empty file to ""
rather than NULL.
---
pidgin/plugins/adiumthemes/webkit.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 81cffde7f1..95949490fb 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -170,15 +170,18 @@ pidgin_message_style_load (const char* styledir)
g_free (file);
file = g_build_filename(styledir, "Contents", "Resources", "main.css", NULL);
- g_file_get_contents(file, &style->basestyle_css, NULL, NULL);
+ if (!g_file_get_contents(file, &style->basestyle_css, NULL, NULL))
+ style->basestyle_css = g_strdup ("");
g_free (file);
file = g_build_filename(styledir, "Contents", "Resources", "Header.html", NULL);
- g_file_get_contents(file, &style->header_html, NULL, NULL);
+ if (!g_file_get_contents(file, &style->header_html, NULL, NULL))
+ style->header_html = g_strdup ("");
g_free (file);
file = g_build_filename(styledir, "Contents", "Resources", "Footer.html", NULL);
- g_file_get_contents(file, &style->footer_html, NULL, NULL);
+ if (!g_file_get_contents(file, &style->footer_html, NULL, NULL))
+ style->footer_html = g_strdup ("");
g_free (file);
file = g_build_filename(styledir, "Contents", "Resources", "Incoming", "Content.html", NULL);
@@ -451,12 +454,14 @@ init_theme_for_webkit (PurpleConversation *conv, char *style_dir)
if (oldStyle) return;
+ purple_debug_info ("webkit", "loading %s", style_dir);
style = pidgin_message_style_load (style_dir);
g_assert (style);
basedir = g_build_filename (style->style_dir, "Contents", "Resources", "Template.html", NULL);
baseuri = g_strdup_printf ("file://%s", basedir);
header = replace_header_tokens(style->header_html, strlen(style->header_html), conv);
+ g_assert (style);
footer = replace_header_tokens(style->footer_html, strlen(style->footer_html), conv);
template = replace_template_tokens(style, style->template_html, strlen(style->template_html) + strlen(style->header_html), header, footer);
@@ -706,7 +711,7 @@ variant_set_default (PidginMessageStyle* style)
const char *css_path = purple_prefs_get_string ("/plugins/gtk/adiumthemes/csspath");
g_free (style->css_path);
- if (g_str_has_prefix (css_path, style->style_dir) &&
+ if (css_path && g_str_has_prefix (css_path, style->style_dir) &&
g_file_test (css_path, G_FILE_TEST_EXISTS)) {
style->css_path = g_strdup (css_path);
return;
@@ -791,6 +796,14 @@ plugin_unload(PurplePlugin *plugin)
return TRUE;
}
+static void
+style_changed (GtkWidget* combobox, gpointer null)
+{
+ char *name = gtk_combo_box_get_active_text (GTK_COMBO_BOX(combobox));
+
+ g_free (cur_style_dir);
+ cur_style_dir = name;
+}
static GtkWidget*
get_style_config_frame ()
@@ -810,6 +823,7 @@ get_style_config_frame ()
}
}
gtk_combo_box_set_active (GTK_COMBO_BOX(combobox), selected);
+ g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(style_changed), NULL);
return combobox;
}
--
cgit v1.2.1
From c9f82b5e459db7b88c482c2575305cf37ca8701a Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 10:08:02 +0000
Subject: unset cur_style_dir when unloading.
---
pidgin/plugins/adiumthemes/webkit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 95949490fb..024f45da4b 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -786,7 +786,7 @@ plugin_unload(PurplePlugin *plugin)
GList *list;
webkit_plugin_free_handle ();
-
+ cur_style_dir = NULL;
list = purple_get_conversations ();
while (list) {
finalize_theme_for_webkit(list->data);
--
cgit v1.2.1
From 13ff090a651bf936f770280896a8ecf19c01b98d Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 10:26:02 +0000
Subject: Debugging info to find bad themes.
---
pidgin/plugins/adiumthemes/webkit.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 024f45da4b..54507599f7 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -132,7 +132,7 @@ pidgin_message_style_load (const char* styledir)
GList *cur = style_list;
char *file; /* temporary variable */
PidginMessageStyle *style = NULL;
-
+
g_assert (styledir);
for (cur = style_list; cur; cur = g_list_next (cur)) {
style = (PidginMessageStyle*) cur->data;
@@ -158,11 +158,13 @@ pidgin_message_style_load (const char* styledir)
if (!g_file_get_contents(style->template_path, &style->template_html, NULL, NULL)) {
pidgin_message_style_unref (style);
+ purple_debug_error ("webkit", "Could not locate a Template.html\n");
return NULL;
}
file = g_build_filename(styledir, "Contents", "Resources", "Status.html", NULL);
if (!g_file_get_contents(file, &style->status_html, NULL, NULL)) {
+ purple_debug_info ("webkit", "%s could not find Resources/Status.html", styledir);
pidgin_message_style_unref (style);
g_free (file);
return NULL;
@@ -186,6 +188,7 @@ pidgin_message_style_load (const char* styledir)
file = g_build_filename(styledir, "Contents", "Resources", "Incoming", "Content.html", NULL);
if (!g_file_get_contents(file, &style->incoming_content_html, NULL, NULL)) {
+ purple_debug_info ("webkit", "%s did not have a Incoming/Content.html\n", styledir);
pidgin_message_style_unref (style);
g_free (file);
return NULL;
@@ -454,7 +457,7 @@ init_theme_for_webkit (PurpleConversation *conv, char *style_dir)
if (oldStyle) return;
- purple_debug_info ("webkit", "loading %s", style_dir);
+ purple_debug_info ("webkit", "loading %s\n", style_dir);
style = pidgin_message_style_load (style_dir);
g_assert (style);
--
cgit v1.2.1
From 1cf31b9a078574dbb8d402cd6074f5a2a5ee4682 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 10:30:31 +0000
Subject: small assertion code.
---
pidgin/plugins/adiumthemes/webkit.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 54507599f7..b390c042e2 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -468,6 +468,7 @@ init_theme_for_webkit (PurpleConversation *conv, char *style_dir)
footer = replace_header_tokens(style->footer_html, strlen(style->footer_html), conv);
template = replace_template_tokens(style, style->template_html, strlen(style->template_html) + strlen(style->header_html), header, footer);
+ g_assert(template);
webkit_web_view_load_string(WEBKIT_WEB_VIEW(webkit), template, "text/html", "UTF-8", baseuri);
g_object_set_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY, style);
--
cgit v1.2.1
From daebe05a8c9bacc5060d0eed8b2e93740e8479dc Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 10:34:52 +0000
Subject: make a get_absolute_path function.
---
pidgin/plugins/adiumthemes/webkit.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index b390c042e2..477060b76c 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -83,6 +83,17 @@ static GList *style_list; /**< List of PidginMessageStyles */
static char *cur_style_dir = NULL;
static void *handle = NULL;
+static inline char* get_absolute_path (const char *path)
+{
+ if (g_path_is_absolute (path)) return g_strdup (path);
+ else {
+ char* cwd = g_get_current_dir (), *ret;
+ ret = g_build_filename (cwd, path, NULL);
+ g_free (cwd);
+ return ret;
+ }
+}
+
static PidginMessageStyle* pidgin_message_style_new (const char* styledir)
{
PidginMessageStyle* ret = g_new0 (PidginMessageStyle, 1);
@@ -623,13 +634,7 @@ get_style_directory_list ()
char *user_dir, *user_style_dir, *global_style_dir;
GList *list1, *list2;
- user_dir = g_strdup (purple_user_dir ());
- if (!g_path_is_absolute (user_dir)) {
- char* cur = g_get_current_dir ();
- g_free (user_dir);
- user_dir = g_build_filename (cur, purple_user_dir(), NULL);
- g_free (cur);
- }
+ user_dir = get_absolute_path (purple_user_dir ());
user_style_dir = g_build_filename (user_dir, "styles", NULL);
global_style_dir = g_build_filename (DATADIR, "pidgin", "styles", NULL);
--
cgit v1.2.1
From 0252526b61a5bdee75c314d891e1833ee3196e93 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 17:45:16 +0000
Subject: Inform the user about how the theme change takes effect.
---
pidgin/plugins/adiumthemes/webkit.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 477060b76c..2860846a1f 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -809,9 +809,16 @@ static void
style_changed (GtkWidget* combobox, gpointer null)
{
char *name = gtk_combo_box_get_active_text (GTK_COMBO_BOX(combobox));
+ GtkWidget *dialog;
g_free (cur_style_dir);
cur_style_dir = name;
+
+ /* inform the user that existing conversations haven't changed */
+ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, "The style for existing conversations have not been changed. Please close and re-open the conversation for the changes to take effect.");
+ g_assert (dialog);
+ gtk_widget_show (dialog);
+ g_signal_connect_swapped (dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog);
}
static GtkWidget*
@@ -821,13 +828,14 @@ get_style_config_frame ()
GList *styles = get_style_directory_list (), *iter;
int index = 0, selected = 0;
- for (iter = styles; iter; iter = g_list_next (iter), index++) {
+ for (iter = styles; iter; iter = g_list_next (iter)) {
PidginMessageStyle *style = pidgin_message_style_load (iter->data);
if (style) {
gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), iter->data);
if (g_str_equal (iter->data, cur_style_dir))
selected = index;
+ index++;
pidgin_message_style_unref (style);
}
}
--
cgit v1.2.1
From b78444a494ef208099bb4e4d71d64c45de66800a Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 20:16:39 +0000
Subject: use a table to display the options neatly.
---
pidgin/plugins/adiumthemes/webkit.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 2860846a1f..7603937789 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -964,11 +964,13 @@ get_variant_config_frame()
static GtkWidget*
get_config_frame(PurplePlugin* plugin)
{
- GtkWidget *vbox = gtk_vbox_new (TRUE, 0);
-
- gtk_box_pack_start (GTK_BOX(vbox), get_style_config_frame (), TRUE, TRUE, 0);
- gtk_box_pack_end (GTK_BOX(vbox), get_variant_config_frame (), TRUE, TRUE, 0);
- return vbox;
+ GtkWidget *table = gtk_table_new (2, 2, FALSE);
+
+ gtk_table_attach_defaults (GTK_TABLE(table), gtk_label_new ("Message Style"), 0, 1, 0, 1);
+ gtk_table_attach_defaults (GTK_TABLE(table), get_style_config_frame (), 1, 2, 0, 1);
+ gtk_table_attach_defaults (GTK_TABLE(table), gtk_label_new ("Style Variant"), 0, 1, 1, 2);
+ gtk_table_attach_defaults (GTK_TABLE(table), get_variant_config_frame (), 1, 2, 1, 2);
+ return table;
}
PidginPluginUiInfo ui_info =
--
cgit v1.2.1
From 606e97c61cbd62bddae7a9ae8f3f86f3f3728814 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 23:44:22 +0000
Subject: Reset the list of variants when the MessageStyle is changed.
---
pidgin/plugins/adiumthemes/webkit.c | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 7603937789..b499c9db8c 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -840,7 +840,7 @@ get_style_config_frame ()
}
}
gtk_combo_box_set_active (GTK_COMBO_BOX(combobox), selected);
- g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(style_changed), NULL);
+ g_signal_connect_after (G_OBJECT(combobox), "changed", G_CALLBACK(style_changed), NULL);
return combobox;
}
@@ -961,15 +961,36 @@ get_variant_config_frame()
return combobox;
}
+static void
+style_changed_reset_variants (GtkWidget* combobox, gpointer table)
+{
+ /* I hate to do this, I swear. But I don't know how to cleanly clean an existing combobox */
+ GtkWidget* variants = g_object_get_data (G_OBJECT(table), "variants-cbox");
+ gtk_widget_destroy (variants);
+ variants = get_variant_config_frame ();
+ gtk_table_attach_defaults (GTK_TABLE (table), variants, 1, 2, 1, 2);
+ gtk_widget_show_all (GTK_WIDGET(table));
+
+ g_object_set_data (G_OBJECT(table), "variants-cbox", variants);
+}
+
static GtkWidget*
get_config_frame(PurplePlugin* plugin)
{
GtkWidget *table = gtk_table_new (2, 2, FALSE);
-
+ GtkWidget *style_config = get_style_config_frame ();
+ GtkWidget *variant_config = get_variant_config_frame ();
+
gtk_table_attach_defaults (GTK_TABLE(table), gtk_label_new ("Message Style"), 0, 1, 0, 1);
- gtk_table_attach_defaults (GTK_TABLE(table), get_style_config_frame (), 1, 2, 0, 1);
+ gtk_table_attach_defaults (GTK_TABLE(table), style_config, 1, 2, 0, 1);
gtk_table_attach_defaults (GTK_TABLE(table), gtk_label_new ("Style Variant"), 0, 1, 1, 2);
- gtk_table_attach_defaults (GTK_TABLE(table), get_variant_config_frame (), 1, 2, 1, 2);
+ gtk_table_attach_defaults (GTK_TABLE(table), variant_config, 1, 2, 1, 2);
+
+
+ g_object_set_data (G_OBJECT(table), "variants-cbox", variant_config);
+ /* to clarify, this is a second signal connected on style config */
+ g_signal_connect_after (G_OBJECT(style_config), "changed", G_CALLBACK(style_changed_reset_variants), table);
+
return table;
}
--
cgit v1.2.1
From 3f79c0cacea569a7247787a8bcf622b1c2914111 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Mon, 10 Aug 2009 23:51:12 +0000
Subject: Show only the MessageStyle name and not the entire path.
---
pidgin/plugins/adiumthemes/webkit.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index b499c9db8c..0058214401 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -810,9 +810,22 @@ style_changed (GtkWidget* combobox, gpointer null)
{
char *name = gtk_combo_box_get_active_text (GTK_COMBO_BOX(combobox));
GtkWidget *dialog;
+ GList *styles = get_style_directory_list (), *iter;
+
+ /* find the full path for this name, I wish I could store this info in the combobox itself. :( */
+ for (iter = styles; iter; iter = g_list_next(iter)) {
+ char* basename = g_path_get_basename (iter->data);
+ if (g_str_equal (basename, name)) {
+ g_free (basename);
+ break;
+ }
+ g_free (basename);
+ }
+ g_assert (iter);
+ g_free (name);
g_free (cur_style_dir);
- cur_style_dir = name;
+ cur_style_dir = g_strdup (iter->data);;
/* inform the user that existing conversations haven't changed */
dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, "The style for existing conversations have not been changed. Please close and re-open the conversation for the changes to take effect.");
@@ -832,7 +845,10 @@ get_style_config_frame ()
PidginMessageStyle *style = pidgin_message_style_load (iter->data);
if (style) {
- gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), iter->data);
+ char *text = g_path_get_basename (iter->data);
+ gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), text);
+ g_free (text);
+
if (g_str_equal (iter->data, cur_style_dir))
selected = index;
index++;
--
cgit v1.2.1
From 893ea74345fe4997259b806dbffb293c418db4bd Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Tue, 11 Aug 2009 00:09:01 +0000
Subject: Removed some unused code.
---
pidgin/plugins/adiumthemes/webkit.c | 39 +++++--------------------------------
1 file changed, 5 insertions(+), 34 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 0058214401..6a3f64c7b8 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -919,49 +919,20 @@ static GtkWidget *
get_variant_config_frame()
{
PidginMessageStyle *style = pidgin_message_style_load (cur_style_dir);
- GList *variants = get_variant_files(style);
- GList *iter = variants;
- char *curdir = NULL;
+ GList *variants = get_variant_files(style), *iter;
GtkWidget *combobox = gtk_combo_box_new_text();
int def = -1, index = 0;
char* css_path = g_strdup (style->css_path);
pidgin_message_style_unref (style);
- for (; iter; iter = g_list_next (iter)) {
+ for (iter = variants; iter; iter = g_list_next (iter)) {
char *basename = g_path_get_basename(iter->data);
char *dirname = g_path_get_dirname(iter->data);
- if (!curdir || !g_str_equal (curdir, dirname)) {
- char *plist, *plist_xml;
- gsize plist_len;
- xmlnode *node;
- g_free(curdir);
- curdir = strdup(dirname);
- plist = g_build_filename(curdir, "..", "..", "Info.plist", NULL);
- if (!g_file_get_contents(plist, &plist_xml, &plist_len, NULL)) {
- continue;
- }
- node = xmlnode_from_str(plist_xml, plist_len);
- if (!node) continue;
- node = xmlnode_get_child(node, "dict");
- if (!node) continue;
- node = xmlnode_get_child(node, "key");
- while (node && strcmp(xmlnode_get_data(node), "CFBundleName")) {
- node = xmlnode_get_next_twin(node);
- }
- if (!node) continue;
- node = node->next;
- while (node && node->type != XMLNODE_TYPE_TAG) {
- node = node->next;
- }
+ char *temp = g_strndup (basename, strlen(basename)-4);
+ gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), temp);
+ g_free (temp);
- }
-
- {
- char *temp = g_strndup (basename, strlen(basename)-4);
- gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), temp);
- g_free (temp);
- }
if (g_str_has_suffix (css_path, basename))
def = index;
index ++;
--
cgit v1.2.1
From 20ff66cb8f41b1dbf7042fa5853a698485a32c56 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Tue, 11 Aug 2009 23:25:16 +0000
Subject: Parses Info.plist now!
---
pidgin/plugins/adiumthemes/webkit.c | 146 +++++++++++++++++++++++++++++++++++-
1 file changed, 145 insertions(+), 1 deletion(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 6a3f64c7b8..56cd0586df 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -49,7 +49,7 @@
#include
#include
-
+#include
/* GObject data keys */
#define MESSAGE_STYLE_KEY "message-style"
@@ -62,6 +62,24 @@
typedef struct _PidginMessageStyle {
int ref_counter;
+ /* current config options */
+ char *variant;
+
+ /* Info.plist keys */
+ int message_view_version;
+ char *cf_bundle_name;
+ char *cf_bundle_identifier;
+ char *cf_bundle_get_info_string;
+ char *default_font_family;
+ int default_font_size;
+ gboolean shows_user_icons;
+ gboolean disable_combine_consecutive;
+ gboolean default_background_is_transparent;
+ gboolean disable_custom_background;
+ char *default_background_color;
+ gboolean allow_text_colors;
+ char *image_mask;
+
/* paths */
char *style_dir;
char *template_path;
@@ -110,6 +128,41 @@ static PidginMessageStyle* pidgin_message_style_new (const char* styledir)
return ret;
}
+/**
+ * deallocate any memory used for info.plist options
+ */
+static void
+pidgin_message_style_unset_info_plist (PidginMessageStyle *style)
+{
+ style->message_view_version = 0;
+ g_free (style->cf_bundle_name);
+ style->cf_bundle_name = NULL;
+
+ g_free (style->cf_bundle_identifier);
+ style->cf_bundle_identifier = NULL;
+
+ g_free (style->cf_bundle_get_info_string);
+ style->cf_bundle_get_info_string = NULL;
+
+ g_free (style->default_font_family);
+ style->default_font_family = NULL;
+
+ style->default_font_size = 0;
+ style->shows_user_icons = TRUE;
+ style->disable_combine_consecutive = FALSE;
+ style->default_background_is_transparent = FALSE;
+ style->disable_custom_background = FALSE;
+
+ g_free (style->default_background_color);
+ style->default_background_color = NULL;
+
+ style->allow_text_colors = TRUE;
+
+ g_free (style->image_mask);
+ style->image_mask = NULL;
+}
+
+
static void pidgin_message_style_unref (PidginMessageStyle *style)
{
if (!style) return;
@@ -131,11 +184,98 @@ static void pidgin_message_style_unref (PidginMessageStyle *style)
style_list = g_list_remove (style_list, style);
g_free (style);
+
+ pidgin_message_style_unset_info_plist (style);
}
static void variant_set_default (PidginMessageStyle* style);
static void webkit_on_webview_destroy (GtkObject* obj, gpointer data);
+static gboolean
+parse_info_plist_key_value (xmlnode* key, gpointer destination, const char* expected)
+{
+ xmlnode *val = key->next;
+
+ for (; val && val->type != XMLNODE_TYPE_TAG; val = val->next);
+ if (!val) return FALSE;
+
+ if (expected == NULL || g_str_equal (expected, "string")) {
+ char** dest = (char**) destination;
+ if (!g_str_equal (val->name, BAD_CAST "string")) return FALSE;
+ if (*dest) g_free (*dest);
+ *dest = xmlnode_get_data_unescaped (val);
+ } else if (g_str_equal (expected, "integer")) {
+ int* dest = (int*) destination;
+ char* value = xmlnode_get_data_unescaped (val);
+
+ if (!g_str_equal (val->name, "integer")) return FALSE;
+ *dest = atoi (value);
+ g_free (value);
+ } else if (g_str_equal (expected, "boolean")) {
+ gboolean *dest = (gboolean*) destination;
+ if (g_str_equal (val->name, BAD_CAST "true")) *dest = TRUE;
+ else if (g_str_equal (val->name, BAD_CAST "false")) *dest = FALSE;
+ else return FALSE;
+ } else return FALSE;
+
+ return TRUE;
+}
+
+static
+gboolean str_for_key (const char *key, const char *found, const char *variant){
+ if (g_str_equal (key, found)) return TRUE;
+ if (!variant) return FALSE;
+ return (g_str_has_prefix (found, key)
+ && g_str_has_suffix (found, variant)
+ && strlen (found) == strlen (key) + strlen (variant) + 1);
+}
+static void
+pidgin_message_style_read_info_plist (PidginMessageStyle *style, const char* variant)
+{
+ /* note that if a variant is used the option:VARIANTNAME takes precedence */
+ char *contents = g_build_filename (style->style_dir, "Contents", NULL);
+ xmlnode *plist = xmlnode_from_file (contents, "Info.plist", "Info.plist", "webkit"), *iter;
+ xmlnode *dict = xmlnode_get_child (plist, "dict");
+
+ g_assert (dict);
+ for (iter = xmlnode_get_child (dict, "key"); iter; iter = xmlnode_get_next_twin (iter)) {
+ char* key = xmlnode_get_data_unescaped (iter);
+ gboolean pr = TRUE;
+
+ if (g_str_equal ("MessageViewVersion", key))
+ pr = parse_info_plist_key_value (iter, &style->message_view_version, "integer");
+ else if (g_str_equal ("CFBundleName", key))
+ pr = parse_info_plist_key_value (iter, &style->cf_bundle_name, "string");
+ else if (g_str_equal ("CFBundleIdentifier", key))
+ pr = parse_info_plist_key_value (iter, &style->cf_bundle_identifier, "string");
+ else if (g_str_equal ("CFBundleGetInfoString", key))
+ pr = parse_info_plist_key_value (iter, &style->cf_bundle_get_info_string, "string");
+ else if (str_for_key ("DefaultFontFamily", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->default_font_family, "string");
+ else if (str_for_key ("DefaultFontSize", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->default_font_size, "integer");
+ else if (str_for_key ("ShowsUserIcons", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->shows_user_icons, "boolean");
+ else if (str_for_key ("DisableCombineConsecutive", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->disable_combine_consecutive, "boolean");
+ else if (str_for_key ("DefaultBackgroundIsTransparent", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->default_background_is_transparent, "boolean");
+ else if (str_for_key ("DisableCustomBackground", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->disable_custom_background, "boolean");
+ else if (str_for_key ("DefaultBackgroundColor", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->default_background_color, "string");
+ else if (str_for_key ("AllowTextColors", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->allow_text_colors, "string");
+ else if (str_for_key ("ImageMask", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->image_mask, "string");
+
+ g_free (key);
+ if (!pr) break; /* does not make sense */
+ }
+
+ xmlnode_free (plist);
+}
+
static PidginMessageStyle*
pidgin_message_style_load (const char* styledir)
{
@@ -228,6 +368,10 @@ pidgin_message_style_load (const char* styledir)
/* find some variant file (or load from user's settings) */
variant_set_default (style);
+ pidgin_message_style_read_info_plist (style, NULL);
+
+ /* let's see if we did this well */
+ printf ("bundle name: %s\n", style->cf_bundle_name);
return style;
}
--
cgit v1.2.1
From 8551ef5ec96076d6103dff1868d4a34b7299d580 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Tue, 11 Aug 2009 23:54:39 +0000
Subject: some work... temporary towards the bigger picture.
---
pidgin/plugins/adiumthemes/webkit.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 56cd0586df..b8275bb5b1 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -64,11 +64,12 @@ typedef struct _PidginMessageStyle {
/* current config options */
char *variant;
+ char *bg_color;
/* Info.plist keys */
int message_view_version;
char *cf_bundle_name;
- char *cf_bundle_identifier;
+ char *cf_bundle_identifier; /* we're not using this */
char *cf_bundle_get_info_string;
char *default_font_family;
int default_font_size;
@@ -198,7 +199,7 @@ parse_info_plist_key_value (xmlnode* key, gpointer destination, const char* expe
for (; val && val->type != XMLNODE_TYPE_TAG; val = val->next);
if (!val) return FALSE;
-
+
if (expected == NULL || g_str_equal (expected, "string")) {
char** dest = (char**) destination;
if (!g_str_equal (val->name, BAD_CAST "string")) return FALSE;
@@ -229,6 +230,11 @@ gboolean str_for_key (const char *key, const char *found, const char *variant){
&& g_str_has_suffix (found, variant)
&& strlen (found) == strlen (key) + strlen (variant) + 1);
}
+
+/**
+ * Info.plist should be re-read every time the variant changes, this is because
+ * the keys that take precedence depend on the value of the current variant.
+ */
static void
pidgin_message_style_read_info_plist (PidginMessageStyle *style, const char* variant)
{
@@ -370,11 +376,24 @@ pidgin_message_style_load (const char* styledir)
pidgin_message_style_read_info_plist (style, NULL);
- /* let's see if we did this well */
- printf ("bundle name: %s\n", style->cf_bundle_name);
+ /* non variant dependent Info.plist checks */
+ if (style->message_view_version < 3) {
+ pidgin_message_style_unref (style);
+ return NULL;
+ }
+
return style;
}
+static void
+pidgin_message_style_set_variant (PidginMessageStyle *style, const char *variant)
+{
+ /* I'm not going to test whether this variant is valid! */
+ g_free (style->variant);
+ style->variant = g_strdup (variant);
+
+ pidgin_message_style_read_info_plist (style, variant);
+}
static void* webkit_plugin_get_handle ()
{
--
cgit v1.2.1
From 1792022484738536aa3ca8723c49427c5cf71fcb Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Wed, 12 Aug 2009 01:12:15 +0000
Subject: new changes seemingly working.
---
pidgin/plugins/adiumthemes/webkit.c | 270 +++++++++++++++++++++---------------
1 file changed, 155 insertions(+), 115 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index b8275bb5b1..e2d4ef82a9 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -63,13 +63,13 @@ typedef struct _PidginMessageStyle {
int ref_counter;
/* current config options */
- char *variant;
+ char *variant; /* allowed to be NULL if there are no variants */
char *bg_color;
/* Info.plist keys */
int message_view_version;
char *cf_bundle_name;
- char *cf_bundle_identifier; /* we're not using this */
+ char *cf_bundle_identifier;
char *cf_bundle_get_info_string;
char *default_font_family;
int default_font_size;
@@ -84,7 +84,6 @@ typedef struct _PidginMessageStyle {
/* paths */
char *style_dir;
char *template_path;
- char *css_path;
/* caches */
char *template_html;
@@ -102,6 +101,23 @@ static GList *style_list; /**< List of PidginMessageStyles */
static char *cur_style_dir = NULL;
static void *handle = NULL;
+static PidginMessageStyle* pidgin_message_style_new (const char* styledir);
+static PidginMessageStyle* pidgin_message_style_load (const char* styledir);
+static void pidgin_message_style_unref (PidginMessageStyle *style);
+static void pidgin_message_style_read_info_plist (PidginMessageStyle *style, const char* variant);
+static char* pidgin_message_style_get_variant (PidginMessageStyle *style);
+static GList* pidgin_message_style_get_variants (PidginMessageStyle *style);
+static void pidgin_message_style_set_variant (PidginMessageStyle *style, const char *variant);
+
+static void
+glist_free_all_string (GList *list)
+{
+ GList *first = list;
+ for (; list; list = g_list_next (list))
+ g_free (list->data);
+ g_list_free (first);
+}
+
static inline char* get_absolute_path (const char *path)
{
if (g_path_is_absolute (path)) return g_strdup (path);
@@ -174,7 +190,6 @@ static void pidgin_message_style_unref (PidginMessageStyle *style)
g_free (style->style_dir);
g_free (style->template_path);
- g_free (style->css_path);
g_free (style->template_html);
g_free (style->incoming_content_html);
@@ -189,7 +204,38 @@ static void pidgin_message_style_unref (PidginMessageStyle *style)
pidgin_message_style_unset_info_plist (style);
}
-static void variant_set_default (PidginMessageStyle* style);
+static void
+pidgin_message_style_save_state (PidginMessageStyle *style)
+{
+ char *prefname = g_strdup_printf ("/plugins/gtk/adiumthemes/%s", style->cf_bundle_identifier);
+ char *variant = g_strdup_printf ("%s/%s", prefname, style->variant);
+
+ purple_prefs_add_none (prefname);
+ purple_prefs_add_string (variant, "");
+ purple_prefs_set_string (variant, style->variant);
+
+ g_free (prefname);
+ g_free (variant);
+}
+
+static void
+pidgin_message_style_load_state (PidginMessageStyle *style)
+{
+ char *prefname = g_strdup_printf ("/plugins/gtk/adiumthemes/%s", style->cf_bundle_identifier);
+ char *variant = g_strdup_printf ("%s/%s", prefname, style->variant);
+
+ const char* value = purple_prefs_get_string (variant);
+ gboolean changed = !style->variant || !g_str_equal (style->variant, value);
+
+ g_free (style->variant);
+ style->variant = g_strdup (value);
+
+ if (changed) pidgin_message_style_read_info_plist (style, style->variant);
+
+ g_free (prefname);
+ g_free(variant);
+}
+
static void webkit_on_webview_destroy (GtkObject* obj, gpointer data);
static gboolean
@@ -285,6 +331,19 @@ pidgin_message_style_read_info_plist (PidginMessageStyle *style, const char* var
static PidginMessageStyle*
pidgin_message_style_load (const char* styledir)
{
+ /*
+ * the loading process described:
+ *
+ * First we load all the style .html files, etc.
+ * The we load any config options that have been stored for
+ * this variant.
+ * Then we load the Info.plist, for the currently decided variant.
+ * At this point, if we find that variants exist, yet
+ * we don't have a variant selected, we choose DefaultVariant
+ * and if that does not exist, we choose the first one in the
+ * directory.
+ */
+
/* is this style already loaded? */
GList *cur = style_list;
char *file; /* temporary variable */
@@ -371,10 +430,8 @@ pidgin_message_style_load (const char* styledir)
style->outgoing_next_content_html = g_strdup (style->outgoing_content_html);
}
- /* find some variant file (or load from user's settings) */
- variant_set_default (style);
-
- pidgin_message_style_read_info_plist (style, NULL);
+ pidgin_message_style_load_state (style);
+ pidgin_message_style_read_info_plist (style, style->variant);
/* non variant dependent Info.plist checks */
if (style->message_view_version < 3) {
@@ -382,6 +439,17 @@ pidgin_message_style_load (const char* styledir)
return NULL;
}
+ if (!style->variant)
+ {
+ GList *variants = pidgin_message_style_get_variants (style);
+
+ if (variants)
+ pidgin_message_style_set_variant (style, variants->data);
+
+ glist_free_all_string (variants);
+ pidgin_message_style_save_state (style);
+ }
+
return style;
}
@@ -393,6 +461,59 @@ pidgin_message_style_set_variant (PidginMessageStyle *style, const char *variant
style->variant = g_strdup (variant);
pidgin_message_style_read_info_plist (style, variant);
+ pidgin_message_style_save_state (style);
+
+ /* todo, the style has "changed". Ideally, I would like to use signals at this point. */
+}
+
+char* pidgin_message_style_get_variant (PidginMessageStyle *style)
+{
+ return g_strdup (style->variant);
+}
+
+/**
+ * Get a list of variants supported by the style.
+ */
+static GList*
+pidgin_message_style_get_variants (PidginMessageStyle *style)
+{
+ GList *ret = NULL;
+ GDir *variants;
+ const char *css_file;
+ char *css;
+ char *variant_dir;
+
+ g_assert (style->style_dir);
+ variant_dir = g_build_filename(style->style_dir, "Contents", "Resources", "Variants", NULL);
+
+ variants = g_dir_open(variant_dir, 0, NULL);
+ if (!variants) return NULL;
+
+ while ((css_file = g_dir_read_name(variants)) != NULL) {
+ if (!g_str_has_suffix (css_file, ".css"))
+ continue;
+
+ css = g_strndup (css_file, strlen (css_file) - 4);
+ ret = g_list_append(ret, css);
+ }
+
+ g_dir_close(variants);
+ g_free(variant_dir);
+
+ ret = g_list_sort (ret, (GCompareFunc)g_strcmp0);
+ return ret;
+}
+
+static char* pidgin_message_style_get_css (PidginMessageStyle *style)
+{
+ if (!style->variant) {
+ return g_build_filename (style->style_dir, "Contents", "Resources", "main.css", NULL);
+ } else {
+ char *file = g_strdup_printf ("%s.css", style->variant);
+ char *ret = g_build_filename (style->style_dir, "Contents", "Resources", "Variants", file, NULL);
+ g_free (file);
+ return ret;
+ }
}
static void* webkit_plugin_get_handle ()
@@ -561,7 +682,7 @@ replace_template_tokens(PidginMessageStyle *style, char *text, int len, char *he
char **ms = g_strsplit(text, "%@", 6);
char *base = NULL;
-
+ char *csspath = pidgin_message_style_get_css (style);
if (ms[0] == NULL || ms[1] == NULL || ms[2] == NULL || ms[3] == NULL || ms[4] == NULL || ms[5] == NULL) {
g_strfreev(ms);
g_string_free(str, TRUE);
@@ -575,13 +696,15 @@ replace_template_tokens(PidginMessageStyle *style, char *text, int len, char *he
g_free (base);
g_string_append(str, ms[1]);
- if (style->basestyle_css)
- g_string_append(str, style->basestyle_css);
+
+ /* I'm just going to skip main.css at this point */
+
g_string_append(str, ms[2]);
- if (style->css_path) {
- g_string_append(str, "file://");
- g_string_append(str, style->css_path);
- }
+
+ g_string_append(str, "file://");
+ g_string_append(str, csspath);
+
+
g_string_append(str, ms[3]);
if (header)
@@ -592,6 +715,7 @@ replace_template_tokens(PidginMessageStyle *style, char *text, int len, char *he
g_string_append(str, ms[5]);
g_strfreev(ms);
+ g_free (csspath);
return g_string_free (str, FALSE);
}
@@ -843,69 +967,6 @@ style_set_default ()
g_list_free (styles);
}
-/**
- * Get each of the files corresponding to each variant.
- */
-static GList*
-get_variant_files(PidginMessageStyle *style)
-{
- GList *ret = NULL;
- GDir *variants;
- const char *css_file;
- char *css;
- char *variant_dir;
-
- g_assert (style->style_dir);
- variant_dir = g_build_filename(style->style_dir, "Contents", "Resources", "Variants", NULL);
-
- variants = g_dir_open(variant_dir, 0, NULL);
- if (!variants) return NULL;
-
- while ((css_file = g_dir_read_name(variants)) != NULL) {
- if (!g_str_has_suffix (css_file, ".css"))
- continue;
-
- css = g_build_filename(variant_dir, css_file, NULL);
- ret = g_list_append(ret, css);
- }
-
- g_dir_close(variants);
- g_free(variant_dir);
-
- ret = g_list_sort (ret, (GCompareFunc)g_strcmp0);
- return ret;
-}
-
-static void
-variant_set_default (PidginMessageStyle* style)
-{
- GList *all, *iter;
- const char *css_path = purple_prefs_get_string ("/plugins/gtk/adiumthemes/csspath");
-
- g_free (style->css_path);
- if (css_path && g_str_has_prefix (css_path, style->style_dir) &&
- g_file_test (css_path, G_FILE_TEST_EXISTS)) {
- style->css_path = g_strdup (css_path);
- return;
- }
- else {
- /* something about the theme has changed */
- css_path = NULL;
- }
-
- all = get_variant_files (style);
-
- if (all) {
- style->css_path = g_strdup (all->data);
- purple_prefs_set_string ("/plugins/gtk/adiumthemes/csspath", css_path);
- }
-
- for (iter = all; iter; iter = g_list_next (iter))
- g_free (iter->data);
-
- g_list_free (all);
-}
-
static gboolean
plugin_load(PurplePlugin *plugin)
{
@@ -968,6 +1029,10 @@ plugin_unload(PurplePlugin *plugin)
return TRUE;
}
+/*
+ * UI config code
+ */
+
static void
style_changed (GtkWidget* combobox, gpointer null)
{
@@ -1031,9 +1096,9 @@ variant_update_conversation (PurpleConversation *conv)
PidginMessageStyle *style = (PidginMessageStyle*) g_object_get_data (G_OBJECT(webview), MESSAGE_STYLE_KEY);
char *script;
- g_assert (style && style->css_path);
+ g_assert (style);
- script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", style->css_path);
+ script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", pidgin_message_style_get_css (style));
gtk_webview_safe_execute_script (GTK_WEBVIEW(webview), script);
g_free (script);
}
@@ -1041,40 +1106,22 @@ variant_update_conversation (PurpleConversation *conv)
static void
variant_changed (GtkWidget* combobox, gpointer null)
{
- char *name, *name_with_ext;
- char *css_path;
+ char *name;
GList *list;
PidginMessageStyle *style = pidgin_message_style_load (cur_style_dir);
g_assert (style);
+ name = gtk_combo_box_get_active_text (GTK_COMBO_BOX (combobox));
+ pidgin_message_style_set_variant (style, name);
- /* it is possible that the theme changed by this point, so we check
- * that first */
-
- name = gtk_combo_box_get_active_text (GTK_COMBO_BOX(combobox));
- name_with_ext = g_strdup_printf ("%s.css", name);
- g_free (name);
-
- css_path = g_build_filename (style->style_dir, "Contents", "Resources", "Variants", name_with_ext, NULL);
-
- if (!g_file_test (css_path, G_FILE_TEST_EXISTS)) {
- goto cleanup;
- }
-
- g_free (style->css_path);
- style->css_path = g_strdup (css_path);
- purple_prefs_set_string ("/plugins/gtk/adiumthemes/csspath", css_path);
-
- /* update each conversation */
+ /* update conversations */
list = purple_get_conversations ();
while (list) {
variant_update_conversation (list->data);
list = g_list_next(list);
}
-cleanup:
- g_free (css_path);
- g_free (name_with_ext);
+ g_free (name);
pidgin_message_style_unref (style);
}
@@ -1082,32 +1129,25 @@ static GtkWidget *
get_variant_config_frame()
{
PidginMessageStyle *style = pidgin_message_style_load (cur_style_dir);
- GList *variants = get_variant_files(style), *iter;
+ GList *variants = pidgin_message_style_get_variants (style), *iter;
+ char *cur_variant = pidgin_message_style_get_variant (style);
GtkWidget *combobox = gtk_combo_box_new_text();
int def = -1, index = 0;
- char* css_path = g_strdup (style->css_path);
pidgin_message_style_unref (style);
for (iter = variants; iter; iter = g_list_next (iter)) {
- char *basename = g_path_get_basename(iter->data);
- char *dirname = g_path_get_dirname(iter->data);
- char *temp = g_strndup (basename, strlen(basename)-4);
- gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), temp);
- g_free (temp);
+ gtk_combo_box_append_text (GTK_COMBO_BOX(combobox), iter->data);
- if (g_str_has_suffix (css_path, basename))
+ if (g_str_equal (cur_variant, iter->data))
def = index;
index ++;
- g_free (basename);
- g_free (dirname);
}
gtk_combo_box_set_active (GTK_COMBO_BOX(combobox), def);
g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(variant_changed), NULL);
- g_free (css_path);
return combobox;
}
--
cgit v1.2.1
From 378143165060a20f1794f163a992e49e8936de82 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Wed, 12 Aug 2009 02:01:35 +0000
Subject: just some debugging info.
---
pidgin/plugins/adiumthemes/webkit.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index e2d4ef82a9..b9683f002f 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -767,6 +767,8 @@ init_theme_for_webkit (PurpleConversation *conv, char *style_dir)
template = replace_template_tokens(style, style->template_html, strlen(style->template_html) + strlen(style->header_html), header, footer);
g_assert(template);
+
+ purple_debug_info ("webkit", "template: %s\n", template);
webkit_web_view_load_string(WEBKIT_WEB_VIEW(webkit), template, "text/html", "UTF-8", baseuri);
g_object_set_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY, style);
@@ -851,6 +853,7 @@ static gboolean webkit_on_displaying_im_msg (PurpleAccount *account,
escape = gtk_webview_quote_js_string (msg);
script = g_strdup_printf("%s(%s)", func, escape);
+ purple_debug_info ("webkit", "JS: %s\n", script);
gtk_webview_safe_execute_script (GTK_WEBVIEW (webkit), script);
g_free(script);
--
cgit v1.2.1
From c262ecaf0a0060b997c1592f719d53d539164673 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Wed, 12 Aug 2009 02:24:41 +0000
Subject: hmm, fonts and font sizes from Info.plist.
---
pidgin/plugins/adiumthemes/webkit.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index b9683f002f..11ec5fc7c2 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -730,6 +730,19 @@ get_webkit(PurpleConversation *conv)
return gtkconv->webview;
}
+static void set_theme_font_settings (WebKitWebView *webview, PidginMessageStyle *style)
+{
+ WebKitWebSettings *settings;
+
+ g_object_get (G_OBJECT(webview), "settings", &settings, NULL);
+ if (style->default_font_family)
+ g_object_set (G_OBJECT (settings), "default-font-family", style->default_font_family, NULL);
+
+ if (style->default_font_size)
+ g_object_set (G_OBJECT (settings), "default-font-size", GINT_TO_POINTER (style->default_font_size), NULL);
+}
+
+
/**
* Called when either a new PurpleConversation is created
* or when a PidginConversation changes its active PurpleConversation
@@ -769,6 +782,8 @@ init_theme_for_webkit (PurpleConversation *conv, char *style_dir)
g_assert(template);
purple_debug_info ("webkit", "template: %s\n", template);
+
+ set_theme_font_settings (WEBKIT_WEB_VIEW(webkit), style);
webkit_web_view_load_string(WEBKIT_WEB_VIEW(webkit), template, "text/html", "UTF-8", baseuri);
g_object_set_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY, style);
@@ -1103,6 +1118,8 @@ variant_update_conversation (PurpleConversation *conv)
script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", pidgin_message_style_get_css (style));
gtk_webview_safe_execute_script (GTK_WEBVIEW(webview), script);
+
+ set_theme_font_settings (WEBKIT_WEB_VIEW (gtkconv->webview), style);
g_free (script);
}
--
cgit v1.2.1
From ae61770ab0adab293b414b69471fb3d01ff6a509 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Thu, 13 Aug 2009 19:58:17 +0000
Subject: apparent code for webkit transparency that might not be working.
---
pidgin/plugins/adiumthemes/webkit.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 11ec5fc7c2..2ea99263cd 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -730,7 +730,7 @@ get_webkit(PurpleConversation *conv)
return gtkconv->webview;
}
-static void set_theme_font_settings (WebKitWebView *webview, PidginMessageStyle *style)
+static void set_theme_webkit_settings (WebKitWebView *webview, PidginMessageStyle *style)
{
WebKitWebSettings *settings;
@@ -740,6 +740,9 @@ static void set_theme_font_settings (WebKitWebView *webview, PidginMessageStyle
if (style->default_font_size)
g_object_set (G_OBJECT (settings), "default-font-size", GINT_TO_POINTER (style->default_font_size), NULL);
+
+ /* this does not work :( */
+ webkit_web_view_set_transparent (webview, style->default_background_is_transparent);
}
@@ -783,7 +786,7 @@ init_theme_for_webkit (PurpleConversation *conv, char *style_dir)
purple_debug_info ("webkit", "template: %s\n", template);
- set_theme_font_settings (WEBKIT_WEB_VIEW(webkit), style);
+ set_theme_webkit_settings (WEBKIT_WEB_VIEW(webkit), style);
webkit_web_view_load_string(WEBKIT_WEB_VIEW(webkit), template, "text/html", "UTF-8", baseuri);
g_object_set_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY, style);
@@ -1119,7 +1122,7 @@ variant_update_conversation (PurpleConversation *conv)
script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", pidgin_message_style_get_css (style));
gtk_webview_safe_execute_script (GTK_WEBVIEW(webview), script);
- set_theme_font_settings (WEBKIT_WEB_VIEW (gtkconv->webview), style);
+ set_theme_webkit_settings (WEBKIT_WEB_VIEW (gtkconv->webview), style);
g_free (script);
}
--
cgit v1.2.1
From 54fff0eed52c0026727efbfbd278c5e78d6d1b56 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Fri, 14 Aug 2009 02:51:41 +0000
Subject: Separated the MessageStyle loading code from the actual rendering
code.
---
pidgin/plugins/adiumthemes/Makefile.am | 4 +-
pidgin/plugins/adiumthemes/message-style.c | 429 +++++++++++++++++++++++++++
pidgin/plugins/adiumthemes/message-style.h | 56 ++++
pidgin/plugins/adiumthemes/webkit.c | 450 +----------------------------
4 files changed, 495 insertions(+), 444 deletions(-)
create mode 100644 pidgin/plugins/adiumthemes/message-style.c
create mode 100644 pidgin/plugins/adiumthemes/message-style.h
diff --git a/pidgin/plugins/adiumthemes/Makefile.am b/pidgin/plugins/adiumthemes/Makefile.am
index e9d0b8a5d6..dba8959310 100644
--- a/pidgin/plugins/adiumthemes/Makefile.am
+++ b/pidgin/plugins/adiumthemes/Makefile.am
@@ -12,7 +12,9 @@ if PLUGINS
webkit_LTLIBRARIES = webkit.la
-webkit_la_SOURCES = webkit.c
+webkit_la_SOURCES = webkit.c \
+ message-style.h \
+ message-style.c
endif
diff --git a/pidgin/plugins/adiumthemes/message-style.c b/pidgin/plugins/adiumthemes/message-style.c
new file mode 100644
index 0000000000..fa6dc67658
--- /dev/null
+++ b/pidgin/plugins/adiumthemes/message-style.c
@@ -0,0 +1,429 @@
+/*
+ * Adium Message Styles
+ * Copyright (C) 2009 Arnold Noronha
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "message-style.h"
+
+#include
+
+#include
+
+#include
+#include
+
+static GList *style_list; /**< List of PidginMessageStyles */
+
+static void
+glist_free_all_string (GList *list)
+{
+ GList *first = list;
+ for (; list; list = g_list_next (list))
+ g_free (list->data);
+ g_list_free (first);
+}
+
+static
+PidginMessageStyle* pidgin_message_style_new (const char* styledir)
+{
+ PidginMessageStyle* ret = g_new0 (PidginMessageStyle, 1);
+ GList *iter;
+
+ /* sanity check */
+ for (iter = style_list; iter; iter = g_list_next (iter))
+ g_assert (!g_str_equal (((PidginMessageStyle*)iter->data)->style_dir, styledir));
+
+ ret->ref_counter = 1;
+ ret->style_dir = g_strdup (styledir);
+
+ style_list = g_list_append (style_list, ret);
+ return ret;
+}
+
+/**
+ * deallocate any memory used for info.plist options
+ */
+static void
+pidgin_message_style_unset_info_plist (PidginMessageStyle *style)
+{
+ style->message_view_version = 0;
+ g_free (style->cf_bundle_name);
+ style->cf_bundle_name = NULL;
+
+ g_free (style->cf_bundle_identifier);
+ style->cf_bundle_identifier = NULL;
+
+ g_free (style->cf_bundle_get_info_string);
+ style->cf_bundle_get_info_string = NULL;
+
+ g_free (style->default_font_family);
+ style->default_font_family = NULL;
+
+ style->default_font_size = 0;
+ style->shows_user_icons = TRUE;
+ style->disable_combine_consecutive = FALSE;
+ style->default_background_is_transparent = FALSE;
+ style->disable_custom_background = FALSE;
+
+ g_free (style->default_background_color);
+ style->default_background_color = NULL;
+
+ style->allow_text_colors = TRUE;
+
+ g_free (style->image_mask);
+ style->image_mask = NULL;
+}
+
+
+void pidgin_message_style_unref (PidginMessageStyle *style)
+{
+ if (!style) return;
+ g_assert (style->ref_counter > 0);
+
+ style->ref_counter--;
+ if (style->ref_counter) return;
+
+ g_free (style->style_dir);
+ g_free (style->template_path);
+
+ g_free (style->template_html);
+ g_free (style->incoming_content_html);
+ g_free (style->outgoing_content_html);
+ g_free (style->outgoing_next_content_html);
+ g_free (style->status_html);
+ g_free (style->basestyle_css);
+
+ style_list = g_list_remove (style_list, style);
+ g_free (style);
+
+ pidgin_message_style_unset_info_plist (style);
+}
+
+void
+pidgin_message_style_save_state (PidginMessageStyle *style)
+{
+ char *prefname = g_strdup_printf ("/plugins/gtk/adiumthemes/%s", style->cf_bundle_identifier);
+ char *variant = g_strdup_printf ("%s/%s", prefname, style->variant);
+
+ purple_prefs_add_none (prefname);
+ purple_prefs_add_string (variant, "");
+ purple_prefs_set_string (variant, style->variant);
+
+ g_free (prefname);
+ g_free (variant);
+}
+
+void
+pidgin_message_style_load_state (PidginMessageStyle *style)
+{
+ char *prefname = g_strdup_printf ("/plugins/gtk/adiumthemes/%s", style->cf_bundle_identifier);
+ char *variant = g_strdup_printf ("%s/%s", prefname, style->variant);
+
+ const char* value = purple_prefs_get_string (variant);
+ gboolean changed = !style->variant || !g_str_equal (style->variant, value);
+
+ g_free (style->variant);
+ style->variant = g_strdup (value);
+
+ if (changed) pidgin_message_style_read_info_plist (style, style->variant);
+
+ g_free (prefname);
+ g_free(variant);
+}
+
+
+static gboolean
+parse_info_plist_key_value (xmlnode* key, gpointer destination, const char* expected)
+{
+ xmlnode *val = key->next;
+
+ for (; val && val->type != XMLNODE_TYPE_TAG; val = val->next);
+ if (!val) return FALSE;
+
+ if (expected == NULL || g_str_equal (expected, "string")) {
+ char** dest = (char**) destination;
+ if (!g_str_equal (val->name, "string")) return FALSE;
+ if (*dest) g_free (*dest);
+ *dest = xmlnode_get_data_unescaped (val);
+ } else if (g_str_equal (expected, "integer")) {
+ int* dest = (int*) destination;
+ char* value = xmlnode_get_data_unescaped (val);
+
+ if (!g_str_equal (val->name, "integer")) return FALSE;
+ *dest = atoi (value);
+ g_free (value);
+ } else if (g_str_equal (expected, "boolean")) {
+ gboolean *dest = (gboolean*) destination;
+ if (g_str_equal (val->name, "true")) *dest = TRUE;
+ else if (g_str_equal (val->name, "false")) *dest = FALSE;
+ else return FALSE;
+ } else return FALSE;
+
+ return TRUE;
+}
+
+static
+gboolean str_for_key (const char *key, const char *found, const char *variant){
+ if (g_str_equal (key, found)) return TRUE;
+ if (!variant) return FALSE;
+ return (g_str_has_prefix (found, key)
+ && g_str_has_suffix (found, variant)
+ && strlen (found) == strlen (key) + strlen (variant) + 1);
+}
+
+/**
+ * Info.plist should be re-read every time the variant changes, this is because
+ * the keys that take precedence depend on the value of the current variant.
+ */
+void
+pidgin_message_style_read_info_plist (PidginMessageStyle *style, const char* variant)
+{
+ /* note that if a variant is used the option:VARIANTNAME takes precedence */
+ char *contents = g_build_filename (style->style_dir, "Contents", NULL);
+ xmlnode *plist = xmlnode_from_file (contents, "Info.plist", "Info.plist", "webkit"), *iter;
+ xmlnode *dict = xmlnode_get_child (plist, "dict");
+
+ g_assert (dict);
+ for (iter = xmlnode_get_child (dict, "key"); iter; iter = xmlnode_get_next_twin (iter)) {
+ char* key = xmlnode_get_data_unescaped (iter);
+ gboolean pr = TRUE;
+
+ if (g_str_equal ("MessageViewVersion", key))
+ pr = parse_info_plist_key_value (iter, &style->message_view_version, "integer");
+ else if (g_str_equal ("CFBundleName", key))
+ pr = parse_info_plist_key_value (iter, &style->cf_bundle_name, "string");
+ else if (g_str_equal ("CFBundleIdentifier", key))
+ pr = parse_info_plist_key_value (iter, &style->cf_bundle_identifier, "string");
+ else if (g_str_equal ("CFBundleGetInfoString", key))
+ pr = parse_info_plist_key_value (iter, &style->cf_bundle_get_info_string, "string");
+ else if (str_for_key ("DefaultFontFamily", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->default_font_family, "string");
+ else if (str_for_key ("DefaultFontSize", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->default_font_size, "integer");
+ else if (str_for_key ("ShowsUserIcons", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->shows_user_icons, "boolean");
+ else if (str_for_key ("DisableCombineConsecutive", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->disable_combine_consecutive, "boolean");
+ else if (str_for_key ("DefaultBackgroundIsTransparent", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->default_background_is_transparent, "boolean");
+ else if (str_for_key ("DisableCustomBackground", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->disable_custom_background, "boolean");
+ else if (str_for_key ("DefaultBackgroundColor", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->default_background_color, "string");
+ else if (str_for_key ("AllowTextColors", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->allow_text_colors, "string");
+ else if (str_for_key ("ImageMask", key, variant))
+ pr = parse_info_plist_key_value (iter, &style->image_mask, "string");
+
+ g_free (key);
+ if (!pr) break; /* does not make sense */
+ }
+
+ xmlnode_free (plist);
+}
+
+PidginMessageStyle*
+pidgin_message_style_load (const char* styledir)
+{
+ /*
+ * the loading process described:
+ *
+ * First we load all the style .html files, etc.
+ * The we load any config options that have been stored for
+ * this variant.
+ * Then we load the Info.plist, for the currently decided variant.
+ * At this point, if we find that variants exist, yet
+ * we don't have a variant selected, we choose DefaultVariant
+ * and if that does not exist, we choose the first one in the
+ * directory.
+ */
+
+ /* is this style already loaded? */
+ GList *cur = style_list;
+ char *file; /* temporary variable */
+ PidginMessageStyle *style = NULL;
+
+ g_assert (styledir);
+ for (cur = style_list; cur; cur = g_list_next (cur)) {
+ style = (PidginMessageStyle*) cur->data;
+ if (g_str_equal (styledir, style->style_dir)) {
+ style->ref_counter++;
+ return style;
+ }
+ }
+
+ /* else we need to load it */
+ style = pidgin_message_style_new (styledir);
+
+ /* load all other files */
+
+ /* The template path can either come from the theme, or can
+ * be stock Template.html that comes with the plugin */
+ style->template_path = g_build_filename(styledir, "Contents", "Resources", "Template.html", NULL);
+
+ if (!g_file_test(style->template_path, G_FILE_TEST_EXISTS)) {
+ g_free (style->template_path);
+ style->template_path = g_build_filename(DATADIR, "pidgin", "webkit", "Template.html", NULL);
+ }
+
+ if (!g_file_get_contents(style->template_path, &style->template_html, NULL, NULL)) {
+ pidgin_message_style_unref (style);
+ purple_debug_error ("webkit", "Could not locate a Template.html\n");
+ return NULL;
+ }
+
+ file = g_build_filename(styledir, "Contents", "Resources", "Status.html", NULL);
+ if (!g_file_get_contents(file, &style->status_html, NULL, NULL)) {
+ purple_debug_info ("webkit", "%s could not find Resources/Status.html", styledir);
+ pidgin_message_style_unref (style);
+ g_free (file);
+ return NULL;
+ }
+ g_free (file);
+
+ file = g_build_filename(styledir, "Contents", "Resources", "main.css", NULL);
+ if (!g_file_get_contents(file, &style->basestyle_css, NULL, NULL))
+ style->basestyle_css = g_strdup ("");
+ g_free (file);
+
+ file = g_build_filename(styledir, "Contents", "Resources", "Header.html", NULL);
+ if (!g_file_get_contents(file, &style->header_html, NULL, NULL))
+ style->header_html = g_strdup ("");
+ g_free (file);
+
+ file = g_build_filename(styledir, "Contents", "Resources", "Footer.html", NULL);
+ if (!g_file_get_contents(file, &style->footer_html, NULL, NULL))
+ style->footer_html = g_strdup ("");
+ g_free (file);
+
+ file = g_build_filename(styledir, "Contents", "Resources", "Incoming", "Content.html", NULL);
+ if (!g_file_get_contents(file, &style->incoming_content_html, NULL, NULL)) {
+ purple_debug_info ("webkit", "%s did not have a Incoming/Content.html\n", styledir);
+ pidgin_message_style_unref (style);
+ g_free (file);
+ return NULL;
+ }
+ g_free (file);
+
+
+ /* according to the spec, the following are optional files */
+ file = g_build_filename(styledir, "Contents", "Resources", "Incoming", "NextContent.html", NULL);
+ if (!g_file_get_contents(file, &style->incoming_next_content_html, NULL, NULL)) {
+ style->incoming_next_content_html = g_strdup (style->incoming_content_html);
+ }
+ g_free (file);
+
+ file = g_build_filename(styledir, "Contents", "Resources", "Outgoing", "Content.html", NULL);
+ if (!g_file_get_contents(file, &style->outgoing_content_html, NULL, NULL)) {
+ style->outgoing_content_html = g_strdup(style->incoming_content_html);
+ }
+ g_free (file);
+
+ file = g_build_filename(styledir, "Contents", "Resources", "Outgoing", "NextContent.html", NULL);
+ if (!g_file_get_contents(file, &style->outgoing_next_content_html, NULL, NULL)) {
+ style->outgoing_next_content_html = g_strdup (style->outgoing_content_html);
+ }
+
+ pidgin_message_style_load_state (style);
+ pidgin_message_style_read_info_plist (style, style->variant);
+
+ /* non variant dependent Info.plist checks */
+ if (style->message_view_version < 3) {
+ pidgin_message_style_unref (style);
+ return NULL;
+ }
+
+ if (!style->variant)
+ {
+ GList *variants = pidgin_message_style_get_variants (style);
+
+ if (variants)
+ pidgin_message_style_set_variant (style, variants->data);
+
+ glist_free_all_string (variants);
+ pidgin_message_style_save_state (style);
+ }
+
+ return style;
+}
+
+void
+pidgin_message_style_set_variant (PidginMessageStyle *style, const char *variant)
+{
+ /* I'm not going to test whether this variant is valid! */
+ g_free (style->variant);
+ style->variant = g_strdup (variant);
+
+ pidgin_message_style_read_info_plist (style, variant);
+ pidgin_message_style_save_state (style);
+
+ /* todo, the style has "changed". Ideally, I would like to use signals at this point. */
+}
+
+char* pidgin_message_style_get_variant (PidginMessageStyle *style)
+{
+ return g_strdup (style->variant);
+}
+
+/**
+ * Get a list of variants supported by the style.
+ */
+GList*
+pidgin_message_style_get_variants (PidginMessageStyle *style)
+{
+ GList *ret = NULL;
+ GDir *variants;
+ const char *css_file;
+ char *css;
+ char *variant_dir;
+
+ g_assert (style->style_dir);
+ variant_dir = g_build_filename(style->style_dir, "Contents", "Resources", "Variants", NULL);
+
+ variants = g_dir_open(variant_dir, 0, NULL);
+ if (!variants) return NULL;
+
+ while ((css_file = g_dir_read_name(variants)) != NULL) {
+ if (!g_str_has_suffix (css_file, ".css"))
+ continue;
+
+ css = g_strndup (css_file, strlen (css_file) - 4);
+ ret = g_list_append(ret, css);
+ }
+
+ g_dir_close(variants);
+ g_free(variant_dir);
+
+ ret = g_list_sort (ret, (GCompareFunc)g_strcmp0);
+ return ret;
+}
+
+
+char* pidgin_message_style_get_css (PidginMessageStyle *style)
+{
+ if (!style->variant) {
+ return g_build_filename (style->style_dir, "Contents", "Resources", "main.css", NULL);
+ } else {
+ char *file = g_strdup_printf ("%s.css", style->variant);
+ char *ret = g_build_filename (style->style_dir, "Contents", "Resources", "Variants", file, NULL);
+ g_free (file);
+ return ret;
+ }
+}
+
+
diff --git a/pidgin/plugins/adiumthemes/message-style.h b/pidgin/plugins/adiumthemes/message-style.h
new file mode 100644
index 0000000000..b98f79fbc5
--- /dev/null
+++ b/pidgin/plugins/adiumthemes/message-style.h
@@ -0,0 +1,56 @@
+
+#include
+
+/*
+ * I'm going to allow a different style for each PidginConversation.
+ * This way I can do two things: 1) change the theme on the fly and not
+ * change existing themes, and 2) Use a different theme for IMs and
+ * chats.
+ */
+typedef struct _PidginMessageStyle {
+ int ref_counter;
+
+ /* current config options */
+ char *variant; /* allowed to be NULL if there are no variants */
+ gboolean show_user_icons;
+
+
+ /* Info.plist keys */
+ int message_view_version;
+ char *cf_bundle_name;
+ char *cf_bundle_identifier;
+ char *cf_bundle_get_info_string;
+ char *default_font_family;
+ int default_font_size;
+ gboolean shows_user_icons;
+ gboolean disable_combine_consecutive;
+ gboolean default_background_is_transparent;
+ gboolean disable_custom_background;
+ char *default_background_color;
+ gboolean allow_text_colors;
+ char *image_mask;
+
+ /* paths */
+ char *style_dir;
+ char *template_path;
+
+ /* caches */
+ char *template_html;
+ char *header_html;
+ char *footer_html;
+ char *incoming_content_html;
+ char *outgoing_content_html;
+ char *incoming_next_content_html;
+ char *outgoing_next_content_html;
+ char *status_html;
+ char *basestyle_css;
+} PidginMessageStyle;
+
+PidginMessageStyle* pidgin_message_style_load (const char* styledir);
+void pidgin_message_style_unref (PidginMessageStyle *style);
+void pidgin_message_style_read_info_plist (PidginMessageStyle *style, const char* variant);
+char* pidgin_message_style_get_variant (PidginMessageStyle *style);
+GList* pidgin_message_style_get_variants (PidginMessageStyle *style);
+void pidgin_message_style_set_variant (PidginMessageStyle *style, const char *variant);
+
+char* pidgin_message_style_get_css (PidginMessageStyle *style);
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 2ea99263cd..fca14334fb 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -50,74 +50,14 @@
#include
#include
+
+#include "message-style.h"
/* GObject data keys */
#define MESSAGE_STYLE_KEY "message-style"
-/*
- * I'm going to allow a different style for each PidginConversation.
- * This way I can do two things: 1) change the theme on the fly and not
- * change existing themes, and 2) Use a different theme for IMs and
- * chats.
- */
-typedef struct _PidginMessageStyle {
- int ref_counter;
-
- /* current config options */
- char *variant; /* allowed to be NULL if there are no variants */
- char *bg_color;
-
- /* Info.plist keys */
- int message_view_version;
- char *cf_bundle_name;
- char *cf_bundle_identifier;
- char *cf_bundle_get_info_string;
- char *default_font_family;
- int default_font_size;
- gboolean shows_user_icons;
- gboolean disable_combine_consecutive;
- gboolean default_background_is_transparent;
- gboolean disable_custom_background;
- char *default_background_color;
- gboolean allow_text_colors;
- char *image_mask;
-
- /* paths */
- char *style_dir;
- char *template_path;
-
- /* caches */
- char *template_html;
- char *header_html;
- char *footer_html;
- char *incoming_content_html;
- char *outgoing_content_html;
- char *incoming_next_content_html;
- char *outgoing_next_content_html;
- char *status_html;
- char *basestyle_css;
-} PidginMessageStyle;
-
-static GList *style_list; /**< List of PidginMessageStyles */
static char *cur_style_dir = NULL;
static void *handle = NULL;
-static PidginMessageStyle* pidgin_message_style_new (const char* styledir);
-static PidginMessageStyle* pidgin_message_style_load (const char* styledir);
-static void pidgin_message_style_unref (PidginMessageStyle *style);
-static void pidgin_message_style_read_info_plist (PidginMessageStyle *style, const char* variant);
-static char* pidgin_message_style_get_variant (PidginMessageStyle *style);
-static GList* pidgin_message_style_get_variants (PidginMessageStyle *style);
-static void pidgin_message_style_set_variant (PidginMessageStyle *style, const char *variant);
-
-static void
-glist_free_all_string (GList *list)
-{
- GList *first = list;
- for (; list; list = g_list_next (list))
- g_free (list->data);
- g_list_free (first);
-}
-
static inline char* get_absolute_path (const char *path)
{
if (g_path_is_absolute (path)) return g_strdup (path);
@@ -129,393 +69,17 @@ static inline char* get_absolute_path (const char *path)
}
}
-static PidginMessageStyle* pidgin_message_style_new (const char* styledir)
-{
- PidginMessageStyle* ret = g_new0 (PidginMessageStyle, 1);
- GList *iter;
-
- /* sanity check */
- for (iter = style_list; iter; iter = g_list_next (iter))
- g_assert (!g_str_equal (((PidginMessageStyle*)iter->data)->style_dir, styledir));
-
- ret->ref_counter = 1;
- ret->style_dir = g_strdup (styledir);
-
- style_list = g_list_append (style_list, ret);
- return ret;
-}
-
-/**
- * deallocate any memory used for info.plist options
- */
static void
-pidgin_message_style_unset_info_plist (PidginMessageStyle *style)
-{
- style->message_view_version = 0;
- g_free (style->cf_bundle_name);
- style->cf_bundle_name = NULL;
-
- g_free (style->cf_bundle_identifier);
- style->cf_bundle_identifier = NULL;
-
- g_free (style->cf_bundle_get_info_string);
- style->cf_bundle_get_info_string = NULL;
-
- g_free (style->default_font_family);
- style->default_font_family = NULL;
-
- style->default_font_size = 0;
- style->shows_user_icons = TRUE;
- style->disable_combine_consecutive = FALSE;
- style->default_background_is_transparent = FALSE;
- style->disable_custom_background = FALSE;
-
- g_free (style->default_background_color);
- style->default_background_color = NULL;
-
- style->allow_text_colors = TRUE;
-
- g_free (style->image_mask);
- style->image_mask = NULL;
-}
-
-
-static void pidgin_message_style_unref (PidginMessageStyle *style)
-{
- if (!style) return;
- g_assert (style->ref_counter > 0);
-
- style->ref_counter--;
- if (style->ref_counter) return;
-
- g_free (style->style_dir);
- g_free (style->template_path);
-
- g_free (style->template_html);
- g_free (style->incoming_content_html);
- g_free (style->outgoing_content_html);
- g_free (style->outgoing_next_content_html);
- g_free (style->status_html);
- g_free (style->basestyle_css);
-
- style_list = g_list_remove (style_list, style);
- g_free (style);
-
- pidgin_message_style_unset_info_plist (style);
-}
-
-static void
-pidgin_message_style_save_state (PidginMessageStyle *style)
-{
- char *prefname = g_strdup_printf ("/plugins/gtk/adiumthemes/%s", style->cf_bundle_identifier);
- char *variant = g_strdup_printf ("%s/%s", prefname, style->variant);
-
- purple_prefs_add_none (prefname);
- purple_prefs_add_string (variant, "");
- purple_prefs_set_string (variant, style->variant);
-
- g_free (prefname);
- g_free (variant);
-}
-
-static void
-pidgin_message_style_load_state (PidginMessageStyle *style)
+glist_free_all_string (GList *list)
{
- char *prefname = g_strdup_printf ("/plugins/gtk/adiumthemes/%s", style->cf_bundle_identifier);
- char *variant = g_strdup_printf ("%s/%s", prefname, style->variant);
-
- const char* value = purple_prefs_get_string (variant);
- gboolean changed = !style->variant || !g_str_equal (style->variant, value);
-
- g_free (style->variant);
- style->variant = g_strdup (value);
-
- if (changed) pidgin_message_style_read_info_plist (style, style->variant);
-
- g_free (prefname);
- g_free(variant);
+ GList *first = list;
+ for (; list; list = g_list_next (list))
+ g_free (list->data);
+ g_list_free (first);
}
static void webkit_on_webview_destroy (GtkObject* obj, gpointer data);
-static gboolean
-parse_info_plist_key_value (xmlnode* key, gpointer destination, const char* expected)
-{
- xmlnode *val = key->next;
-
- for (; val && val->type != XMLNODE_TYPE_TAG; val = val->next);
- if (!val) return FALSE;
-
- if (expected == NULL || g_str_equal (expected, "string")) {
- char** dest = (char**) destination;
- if (!g_str_equal (val->name, BAD_CAST "string")) return FALSE;
- if (*dest) g_free (*dest);
- *dest = xmlnode_get_data_unescaped (val);
- } else if (g_str_equal (expected, "integer")) {
- int* dest = (int*) destination;
- char* value = xmlnode_get_data_unescaped (val);
-
- if (!g_str_equal (val->name, "integer")) return FALSE;
- *dest = atoi (value);
- g_free (value);
- } else if (g_str_equal (expected, "boolean")) {
- gboolean *dest = (gboolean*) destination;
- if (g_str_equal (val->name, BAD_CAST "true")) *dest = TRUE;
- else if (g_str_equal (val->name, BAD_CAST "false")) *dest = FALSE;
- else return FALSE;
- } else return FALSE;
-
- return TRUE;
-}
-
-static
-gboolean str_for_key (const char *key, const char *found, const char *variant){
- if (g_str_equal (key, found)) return TRUE;
- if (!variant) return FALSE;
- return (g_str_has_prefix (found, key)
- && g_str_has_suffix (found, variant)
- && strlen (found) == strlen (key) + strlen (variant) + 1);
-}
-
-/**
- * Info.plist should be re-read every time the variant changes, this is because
- * the keys that take precedence depend on the value of the current variant.
- */
-static void
-pidgin_message_style_read_info_plist (PidginMessageStyle *style, const char* variant)
-{
- /* note that if a variant is used the option:VARIANTNAME takes precedence */
- char *contents = g_build_filename (style->style_dir, "Contents", NULL);
- xmlnode *plist = xmlnode_from_file (contents, "Info.plist", "Info.plist", "webkit"), *iter;
- xmlnode *dict = xmlnode_get_child (plist, "dict");
-
- g_assert (dict);
- for (iter = xmlnode_get_child (dict, "key"); iter; iter = xmlnode_get_next_twin (iter)) {
- char* key = xmlnode_get_data_unescaped (iter);
- gboolean pr = TRUE;
-
- if (g_str_equal ("MessageViewVersion", key))
- pr = parse_info_plist_key_value (iter, &style->message_view_version, "integer");
- else if (g_str_equal ("CFBundleName", key))
- pr = parse_info_plist_key_value (iter, &style->cf_bundle_name, "string");
- else if (g_str_equal ("CFBundleIdentifier", key))
- pr = parse_info_plist_key_value (iter, &style->cf_bundle_identifier, "string");
- else if (g_str_equal ("CFBundleGetInfoString", key))
- pr = parse_info_plist_key_value (iter, &style->cf_bundle_get_info_string, "string");
- else if (str_for_key ("DefaultFontFamily", key, variant))
- pr = parse_info_plist_key_value (iter, &style->default_font_family, "string");
- else if (str_for_key ("DefaultFontSize", key, variant))
- pr = parse_info_plist_key_value (iter, &style->default_font_size, "integer");
- else if (str_for_key ("ShowsUserIcons", key, variant))
- pr = parse_info_plist_key_value (iter, &style->shows_user_icons, "boolean");
- else if (str_for_key ("DisableCombineConsecutive", key, variant))
- pr = parse_info_plist_key_value (iter, &style->disable_combine_consecutive, "boolean");
- else if (str_for_key ("DefaultBackgroundIsTransparent", key, variant))
- pr = parse_info_plist_key_value (iter, &style->default_background_is_transparent, "boolean");
- else if (str_for_key ("DisableCustomBackground", key, variant))
- pr = parse_info_plist_key_value (iter, &style->disable_custom_background, "boolean");
- else if (str_for_key ("DefaultBackgroundColor", key, variant))
- pr = parse_info_plist_key_value (iter, &style->default_background_color, "string");
- else if (str_for_key ("AllowTextColors", key, variant))
- pr = parse_info_plist_key_value (iter, &style->allow_text_colors, "string");
- else if (str_for_key ("ImageMask", key, variant))
- pr = parse_info_plist_key_value (iter, &style->image_mask, "string");
-
- g_free (key);
- if (!pr) break; /* does not make sense */
- }
-
- xmlnode_free (plist);
-}
-
-static PidginMessageStyle*
-pidgin_message_style_load (const char* styledir)
-{
- /*
- * the loading process described:
- *
- * First we load all the style .html files, etc.
- * The we load any config options that have been stored for
- * this variant.
- * Then we load the Info.plist, for the currently decided variant.
- * At this point, if we find that variants exist, yet
- * we don't have a variant selected, we choose DefaultVariant
- * and if that does not exist, we choose the first one in the
- * directory.
- */
-
- /* is this style already loaded? */
- GList *cur = style_list;
- char *file; /* temporary variable */
- PidginMessageStyle *style = NULL;
-
- g_assert (styledir);
- for (cur = style_list; cur; cur = g_list_next (cur)) {
- style = (PidginMessageStyle*) cur->data;
- if (g_str_equal (styledir, style->style_dir)) {
- style->ref_counter++;
- return style;
- }
- }
-
- /* else we need to load it */
- style = pidgin_message_style_new (styledir);
-
- /* load all other files */
-
- /* The template path can either come from the theme, or can
- * be stock Template.html that comes with the plugin */
- style->template_path = g_build_filename(styledir, "Contents", "Resources", "Template.html", NULL);
-
- if (!g_file_test(style->template_path, G_FILE_TEST_EXISTS)) {
- g_free (style->template_path);
- style->template_path = g_build_filename(DATADIR, "pidgin", "webkit", "Template.html", NULL);
- }
-
- if (!g_file_get_contents(style->template_path, &style->template_html, NULL, NULL)) {
- pidgin_message_style_unref (style);
- purple_debug_error ("webkit", "Could not locate a Template.html\n");
- return NULL;
- }
-
- file = g_build_filename(styledir, "Contents", "Resources", "Status.html", NULL);
- if (!g_file_get_contents(file, &style->status_html, NULL, NULL)) {
- purple_debug_info ("webkit", "%s could not find Resources/Status.html", styledir);
- pidgin_message_style_unref (style);
- g_free (file);
- return NULL;
- }
- g_free (file);
-
- file = g_build_filename(styledir, "Contents", "Resources", "main.css", NULL);
- if (!g_file_get_contents(file, &style->basestyle_css, NULL, NULL))
- style->basestyle_css = g_strdup ("");
- g_free (file);
-
- file = g_build_filename(styledir, "Contents", "Resources", "Header.html", NULL);
- if (!g_file_get_contents(file, &style->header_html, NULL, NULL))
- style->header_html = g_strdup ("");
- g_free (file);
-
- file = g_build_filename(styledir, "Contents", "Resources", "Footer.html", NULL);
- if (!g_file_get_contents(file, &style->footer_html, NULL, NULL))
- style->footer_html = g_strdup ("");
- g_free (file);
-
- file = g_build_filename(styledir, "Contents", "Resources", "Incoming", "Content.html", NULL);
- if (!g_file_get_contents(file, &style->incoming_content_html, NULL, NULL)) {
- purple_debug_info ("webkit", "%s did not have a Incoming/Content.html\n", styledir);
- pidgin_message_style_unref (style);
- g_free (file);
- return NULL;
- }
- g_free (file);
-
-
- /* according to the spec, the following are optional files */
- file = g_build_filename(styledir, "Contents", "Resources", "Incoming", "NextContent.html", NULL);
- if (!g_file_get_contents(file, &style->incoming_next_content_html, NULL, NULL)) {
- style->incoming_next_content_html = g_strdup (style->incoming_content_html);
- }
- g_free (file);
-
- file = g_build_filename(styledir, "Contents", "Resources", "Outgoing", "Content.html", NULL);
- if (!g_file_get_contents(file, &style->outgoing_content_html, NULL, NULL)) {
- style->outgoing_content_html = g_strdup(style->incoming_content_html);
- }
- g_free (file);
-
- file = g_build_filename(styledir, "Contents", "Resources", "Outgoing", "NextContent.html", NULL);
- if (!g_file_get_contents(file, &style->outgoing_next_content_html, NULL, NULL)) {
- style->outgoing_next_content_html = g_strdup (style->outgoing_content_html);
- }
-
- pidgin_message_style_load_state (style);
- pidgin_message_style_read_info_plist (style, style->variant);
-
- /* non variant dependent Info.plist checks */
- if (style->message_view_version < 3) {
- pidgin_message_style_unref (style);
- return NULL;
- }
-
- if (!style->variant)
- {
- GList *variants = pidgin_message_style_get_variants (style);
-
- if (variants)
- pidgin_message_style_set_variant (style, variants->data);
-
- glist_free_all_string (variants);
- pidgin_message_style_save_state (style);
- }
-
- return style;
-}
-
-static void
-pidgin_message_style_set_variant (PidginMessageStyle *style, const char *variant)
-{
- /* I'm not going to test whether this variant is valid! */
- g_free (style->variant);
- style->variant = g_strdup (variant);
-
- pidgin_message_style_read_info_plist (style, variant);
- pidgin_message_style_save_state (style);
-
- /* todo, the style has "changed". Ideally, I would like to use signals at this point. */
-}
-
-char* pidgin_message_style_get_variant (PidginMessageStyle *style)
-{
- return g_strdup (style->variant);
-}
-
-/**
- * Get a list of variants supported by the style.
- */
-static GList*
-pidgin_message_style_get_variants (PidginMessageStyle *style)
-{
- GList *ret = NULL;
- GDir *variants;
- const char *css_file;
- char *css;
- char *variant_dir;
-
- g_assert (style->style_dir);
- variant_dir = g_build_filename(style->style_dir, "Contents", "Resources", "Variants", NULL);
-
- variants = g_dir_open(variant_dir, 0, NULL);
- if (!variants) return NULL;
-
- while ((css_file = g_dir_read_name(variants)) != NULL) {
- if (!g_str_has_suffix (css_file, ".css"))
- continue;
-
- css = g_strndup (css_file, strlen (css_file) - 4);
- ret = g_list_append(ret, css);
- }
-
- g_dir_close(variants);
- g_free(variant_dir);
-
- ret = g_list_sort (ret, (GCompareFunc)g_strcmp0);
- return ret;
-}
-
-static char* pidgin_message_style_get_css (PidginMessageStyle *style)
-{
- if (!style->variant) {
- return g_build_filename (style->style_dir, "Contents", "Resources", "main.css", NULL);
- } else {
- char *file = g_strdup_printf ("%s.css", style->variant);
- char *ret = g_build_filename (style->style_dir, "Contents", "Resources", "Variants", file, NULL);
- g_free (file);
- return ret;
- }
-}
-
static void* webkit_plugin_get_handle ()
{
if (handle) return handle;
--
cgit v1.2.1
From 5e44c77ef58b67db5cbd26bf9a76c2f6a7a3c8cc Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Fri, 14 Aug 2009 04:47:16 +0000
Subject: load the default variant. Bring back basestyle.css.
---
pidgin/plugins/adiumthemes/message-style.c | 2 ++
pidgin/plugins/adiumthemes/message-style.h | 3 ++-
pidgin/plugins/adiumthemes/webkit.c | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/message-style.c b/pidgin/plugins/adiumthemes/message-style.c
index fa6dc67658..a59598a8a7 100644
--- a/pidgin/plugins/adiumthemes/message-style.c
+++ b/pidgin/plugins/adiumthemes/message-style.c
@@ -87,6 +87,8 @@ pidgin_message_style_unset_info_plist (PidginMessageStyle *style)
g_free (style->image_mask);
style->image_mask = NULL;
+ g_free (style->default_variant);
+ style->default_variant = NULL;
}
diff --git a/pidgin/plugins/adiumthemes/message-style.h b/pidgin/plugins/adiumthemes/message-style.h
index b98f79fbc5..ac7919dd63 100644
--- a/pidgin/plugins/adiumthemes/message-style.h
+++ b/pidgin/plugins/adiumthemes/message-style.h
@@ -29,7 +29,8 @@ typedef struct _PidginMessageStyle {
char *default_background_color;
gboolean allow_text_colors;
char *image_mask;
-
+ char *default_variant;
+
/* paths */
char *style_dir;
char *template_path;
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index fca14334fb..8797629b79 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -261,7 +261,7 @@ replace_template_tokens(PidginMessageStyle *style, char *text, int len, char *he
g_string_append(str, ms[1]);
- /* I'm just going to skip main.css at this point */
+ g_string_append(str, style->basestyle_css);
g_string_append(str, ms[2]);
--
cgit v1.2.1
From 12521cd0d3da38bca361b146f17e6d6267984547 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Sun, 16 Aug 2009 07:01:11 +0000
Subject: Instead of using references, use copy's. Sigh, I know this is a
memory inefficient design, but it's the most robust.
---
pidgin/plugins/adiumthemes/message-style.c | 56 +++++++++++++++++++-----------
pidgin/plugins/adiumthemes/message-style.h | 5 +--
pidgin/plugins/adiumthemes/webkit.c | 17 +++++----
3 files changed, 49 insertions(+), 29 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/message-style.c b/pidgin/plugins/adiumthemes/message-style.c
index a59598a8a7..b0d360c2d0 100644
--- a/pidgin/plugins/adiumthemes/message-style.c
+++ b/pidgin/plugins/adiumthemes/message-style.c
@@ -27,8 +27,6 @@
#include
#include
-static GList *style_list; /**< List of PidginMessageStyles */
-
static void
glist_free_all_string (GList *list)
{
@@ -42,16 +40,10 @@ static
PidginMessageStyle* pidgin_message_style_new (const char* styledir)
{
PidginMessageStyle* ret = g_new0 (PidginMessageStyle, 1);
- GList *iter;
-
- /* sanity check */
- for (iter = style_list; iter; iter = g_list_next (iter))
- g_assert (!g_str_equal (((PidginMessageStyle*)iter->data)->style_dir, styledir));
ret->ref_counter = 1;
ret->style_dir = g_strdup (styledir);
- style_list = g_list_append (style_list, ret);
return ret;
}
@@ -110,7 +102,6 @@ void pidgin_message_style_unref (PidginMessageStyle *style)
g_free (style->status_html);
g_free (style->basestyle_css);
- style_list = g_list_remove (style_list, style);
g_free (style);
pidgin_message_style_unset_info_plist (style);
@@ -256,19 +247,9 @@ pidgin_message_style_load (const char* styledir)
*/
/* is this style already loaded? */
- GList *cur = style_list;
char *file; /* temporary variable */
PidginMessageStyle *style = NULL;
- g_assert (styledir);
- for (cur = style_list; cur; cur = g_list_next (cur)) {
- style = (PidginMessageStyle*) cur->data;
- if (g_str_equal (styledir, style->style_dir)) {
- style->ref_counter++;
- return style;
- }
- }
-
/* else we need to load it */
style = pidgin_message_style_new (styledir);
@@ -284,8 +265,8 @@ pidgin_message_style_load (const char* styledir)
}
if (!g_file_get_contents(style->template_path, &style->template_html, NULL, NULL)) {
+ purple_debug_error ("webkit", "Could not locate a Template.html (%s)\n", style->template_path);
pidgin_message_style_unref (style);
- purple_debug_error ("webkit", "Could not locate a Template.html\n");
return NULL;
}
@@ -364,6 +345,41 @@ pidgin_message_style_load (const char* styledir)
return style;
}
+PidginMessageStyle*
+pidgin_message_style_copy (const PidginMessageStyle *style)
+{
+ /* it's at times like this that I miss C++ */
+ PidginMessageStyle *ret = pidgin_message_style_new (style->style_dir);
+
+ ret->variant = g_strdup (style->variant);
+ ret->message_view_version = style->message_view_version;
+ ret->cf_bundle_name = g_strdup (style->cf_bundle_name);
+ ret->cf_bundle_identifier = g_strdup (style->cf_bundle_identifier);
+ ret->cf_bundle_get_info_string = g_strdup (style->cf_bundle_get_info_string);
+ ret->default_font_family = g_strdup (style->default_font_family);
+ ret->default_font_size = style->default_font_size;
+ ret->shows_user_icons = style->shows_user_icons;
+ ret->disable_combine_consecutive = style->disable_combine_consecutive;
+ ret->default_background_is_transparent = style->default_background_is_transparent;
+ ret->disable_custom_background = style->disable_custom_background;
+ ret->default_background_color = g_strdup (style->default_background_color);
+ ret->allow_text_colors = style->allow_text_colors;
+ ret->image_mask = g_strdup (style->image_mask);
+ ret->default_variant = g_strdup (style->default_variant);
+
+ ret->template_path = g_strdup (style->template_path);
+ ret->template_html = g_strdup (style->template_html);
+ ret->header_html = g_strdup (style->header_html);
+ ret->footer_html = g_strdup (style->footer_html);
+ ret->incoming_content_html = g_strdup (style->incoming_content_html);
+ ret->outgoing_content_html = g_strdup (style->outgoing_content_html);
+ ret->incoming_next_content_html = g_strdup (style->incoming_next_content_html);
+ ret->outgoing_next_content_html = g_strdup (style->outgoing_next_content_html);
+ ret->status_html = g_strdup (style->status_html);
+ ret->basestyle_css = g_strdup (style->basestyle_css);
+ return ret;
+}
+
void
pidgin_message_style_set_variant (PidginMessageStyle *style, const char *variant)
{
diff --git a/pidgin/plugins/adiumthemes/message-style.h b/pidgin/plugins/adiumthemes/message-style.h
index ac7919dd63..7c21805edc 100644
--- a/pidgin/plugins/adiumthemes/message-style.h
+++ b/pidgin/plugins/adiumthemes/message-style.h
@@ -12,10 +12,10 @@ typedef struct _PidginMessageStyle {
/* current config options */
char *variant; /* allowed to be NULL if there are no variants */
- gboolean show_user_icons;
+ /* Info.plist keys that change with Variant */
- /* Info.plist keys */
+ /* Static Info.plist keys */
int message_view_version;
char *cf_bundle_name;
char *cf_bundle_identifier;
@@ -48,6 +48,7 @@ typedef struct _PidginMessageStyle {
} PidginMessageStyle;
PidginMessageStyle* pidgin_message_style_load (const char* styledir);
+PidginMessageStyle* pidgin_message_style_copy (const PidginMessageStyle *style);
void pidgin_message_style_unref (PidginMessageStyle *style);
void pidgin_message_style_read_info_plist (PidginMessageStyle *style, const char* variant);
char* pidgin_message_style_get_variant (PidginMessageStyle *style);
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 8797629b79..2723a1617d 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -94,7 +94,7 @@ static void webkit_plugin_free_handle ()
static char *
replace_message_tokens(
- char *text,
+ const char *text,
gsize len,
PurpleConversation *conv,
const char *name,
@@ -104,8 +104,8 @@ replace_message_tokens(
time_t mtime)
{
GString *str = g_string_new_len(NULL, len);
- char *cur = text;
- char *prev = cur;
+ const char *cur = text;
+ const char *prev = cur;
while ((cur = strchr(cur, '%'))) {
const char *replace = NULL;
@@ -119,7 +119,7 @@ replace_message_tokens(
} else if (!strncmp(cur, "%time", strlen("%time"))) {
char *format = NULL;
if (*(cur + strlen("%time")) == '{') {
- char *start = cur + strlen("%time") + 1;
+ const char *start = cur + strlen("%time") + 1;
char *end = strstr(start, "}%");
if (!end) /* Invalid string */
continue;
@@ -333,11 +333,12 @@ init_theme_for_webkit (PurpleConversation *conv, char *style_dir)
PidginMessageStyle *style, *oldStyle;
oldStyle = g_object_get_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY);
- if (oldStyle) return;
+ g_return_if_fail (!oldStyle);
purple_debug_info ("webkit", "loading %s\n", style_dir);
style = pidgin_message_style_load (style_dir);
g_assert (style);
+ g_assert (style->template_html); /* debugging test? */
basedir = g_build_filename (style->style_dir, "Contents", "Resources", "Template.html", NULL);
baseuri = g_strdup_printf ("file://%s", basedir);
@@ -353,10 +354,12 @@ init_theme_for_webkit (PurpleConversation *conv, char *style_dir)
set_theme_webkit_settings (WEBKIT_WEB_VIEW(webkit), style);
webkit_web_view_load_string(WEBKIT_WEB_VIEW(webkit), template, "text/html", "UTF-8", baseuri);
- g_object_set_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY, style);
+ PidginMessageStyle *copy = pidgin_message_style_copy (style);
+ g_object_set_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY, copy);
+ pidgin_message_style_unref (style);
/* I need to unref this style when the webkit object destroys */
- g_signal_connect (G_OBJECT(webkit), "destroy", G_CALLBACK(webkit_on_webview_destroy), style);
+ g_signal_connect (G_OBJECT(webkit), "destroy", G_CALLBACK(webkit_on_webview_destroy), copy);
g_free (basedir);
g_free (baseuri);
--
cgit v1.2.1
From 89ee49ea75ee5c7e18e90af4707a05abce71e552 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Sun, 16 Aug 2009 19:28:23 +0000
Subject: Fixing back variants.
---
pidgin/plugins/adiumthemes/message-style.c | 11 +++++------
pidgin/plugins/adiumthemes/message-style.h | 1 +
pidgin/plugins/adiumthemes/webkit.c | 5 +++--
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/message-style.c b/pidgin/plugins/adiumthemes/message-style.c
index b0d360c2d0..6f7e4449c3 100644
--- a/pidgin/plugins/adiumthemes/message-style.c
+++ b/pidgin/plugins/adiumthemes/message-style.c
@@ -108,11 +108,12 @@ void pidgin_message_style_unref (PidginMessageStyle *style)
}
void
-pidgin_message_style_save_state (PidginMessageStyle *style)
+pidgin_message_style_save_state (const PidginMessageStyle *style)
{
char *prefname = g_strdup_printf ("/plugins/gtk/adiumthemes/%s", style->cf_bundle_identifier);
- char *variant = g_strdup_printf ("%s/%s", prefname, style->variant);
+ char *variant = g_strdup_printf ("%s/variant", prefname);
+ purple_debug_info ("webkit", "saving state with variant %s\n", style->variant);
purple_prefs_add_none (prefname);
purple_prefs_add_string (variant, "");
purple_prefs_set_string (variant, style->variant);
@@ -125,7 +126,7 @@ void
pidgin_message_style_load_state (PidginMessageStyle *style)
{
char *prefname = g_strdup_printf ("/plugins/gtk/adiumthemes/%s", style->cf_bundle_identifier);
- char *variant = g_strdup_printf ("%s/%s", prefname, style->variant);
+ char *variant = g_strdup_printf ("%s/variant", prefname);
const char* value = purple_prefs_get_string (variant);
gboolean changed = !style->variant || !g_str_equal (style->variant, value);
@@ -322,8 +323,8 @@ pidgin_message_style_load (const char* styledir)
style->outgoing_next_content_html = g_strdup (style->outgoing_content_html);
}
+ pidgin_message_style_read_info_plist (style, NULL);
pidgin_message_style_load_state (style);
- pidgin_message_style_read_info_plist (style, style->variant);
/* non variant dependent Info.plist checks */
if (style->message_view_version < 3) {
@@ -339,7 +340,6 @@ pidgin_message_style_load (const char* styledir)
pidgin_message_style_set_variant (style, variants->data);
glist_free_all_string (variants);
- pidgin_message_style_save_state (style);
}
return style;
@@ -388,7 +388,6 @@ pidgin_message_style_set_variant (PidginMessageStyle *style, const char *variant
style->variant = g_strdup (variant);
pidgin_message_style_read_info_plist (style, variant);
- pidgin_message_style_save_state (style);
/* todo, the style has "changed". Ideally, I would like to use signals at this point. */
}
diff --git a/pidgin/plugins/adiumthemes/message-style.h b/pidgin/plugins/adiumthemes/message-style.h
index 7c21805edc..c8f9cdbe9d 100644
--- a/pidgin/plugins/adiumthemes/message-style.h
+++ b/pidgin/plugins/adiumthemes/message-style.h
@@ -49,6 +49,7 @@ typedef struct _PidginMessageStyle {
PidginMessageStyle* pidgin_message_style_load (const char* styledir);
PidginMessageStyle* pidgin_message_style_copy (const PidginMessageStyle *style);
+void pidgin_message_style_save_state (const PidginMessageStyle *style);
void pidgin_message_style_unref (PidginMessageStyle *style);
void pidgin_message_style_read_info_plist (PidginMessageStyle *style, const char* variant);
char* pidgin_message_style_get_variant (PidginMessageStyle *style);
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 2723a1617d..573b187cbd 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -333,7 +333,7 @@ init_theme_for_webkit (PurpleConversation *conv, char *style_dir)
PidginMessageStyle *style, *oldStyle;
oldStyle = g_object_get_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY);
- g_return_if_fail (!oldStyle);
+ if (oldStyle) return;
purple_debug_info ("webkit", "loading %s\n", style_dir);
style = pidgin_message_style_load (style_dir);
@@ -703,7 +703,8 @@ variant_changed (GtkWidget* combobox, gpointer null)
g_assert (style);
name = gtk_combo_box_get_active_text (GTK_COMBO_BOX (combobox));
pidgin_message_style_set_variant (style, name);
-
+ pidgin_message_style_save_state (style);
+
/* update conversations */
list = purple_get_conversations ();
while (list) {
--
cgit v1.2.1
From f5e9e0891d55ea3761f75f364ab2a838f7c69ca6 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Wed, 19 Aug 2009 02:43:17 +0000
Subject: Use (void) in prototypes. (thanks Elliott)
---
pidgin/gtkwebview.c | 4 ++--
pidgin/gtkwebview.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
index dbdea56428..f88fb5a51a 100644
--- a/pidgin/gtkwebview.c
+++ b/pidgin/gtkwebview.c
@@ -50,7 +50,7 @@ struct GtkWebViewPriv {
gboolean is_loading;
};
-GtkWidget* gtk_webview_new ()
+GtkWidget* gtk_webview_new (void)
{
GtkWebView* ret = GTK_WEBVIEW (g_object_new(gtk_webview_get_type(), NULL));
return GTK_WIDGET (ret);
@@ -313,7 +313,7 @@ gboolean gtk_webview_is_empty (GtkWebView *view)
return view->priv->empty;
}
-GType gtk_webview_get_type ()
+GType gtk_webview_get_type (void)
{
static GType mview_type = 0;
if (G_UNLIKELY (mview_type == 0)) {
diff --git a/pidgin/gtkwebview.h b/pidgin/gtkwebview.h
index 25fee3b9a4..574c4ae262 100644
--- a/pidgin/gtkwebview.h
+++ b/pidgin/gtkwebview.h
@@ -63,14 +63,14 @@ typedef struct _GtkWebViewClass GtkWebViewClass;
*
* @return the GType for GtkWebView widget
*/
-GType gtk_webview_get_type ();
+GType gtk_webview_get_type (void);
/**
* Create a new GtkWebView object
*
* @return a GtkWidget corresponding to the GtkWebView object
*/
-GtkWidget* gtk_webview_new ();
+GtkWidget* gtk_webview_new (void);
/**
* A very basic routine to append html, which can be considered
--
cgit v1.2.1
From 3c6dd75fd2956edb05f9e510207e57e9413f39c5 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Wed, 19 Aug 2009 05:04:01 +0000
Subject: Adds the 'groupchat' classname to #Chat when using groupchat.
This should be the only requirement for Adium 1.3.x.
---
pidgin/plugins/adiumthemes/webkit.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 573b187cbd..5d033762a3 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -309,6 +309,20 @@ static void set_theme_webkit_settings (WebKitWebView *webview, PidginMessageStyl
webkit_web_view_set_transparent (webview, style->default_background_is_transparent);
}
+/*
+ * The style specification says that if the conversation is a group
+ * chat then the element will be given a class
+ * 'groupchat'. I can't add another '%@' in Template.html because
+ * that breaks style-specific Template.html's. I have to either use libxml
+ * or conveniently play with WebKit's javascript engine. The javascript
+ * engine should work, but it's not an identical behavior.
+ */
+static void
+webkit_set_groupchat (GtkWebView *webview)
+{
+ gtk_webview_safe_execute_script (webview, "document.getElementById('Chat').className = 'groupchat'");
+}
+
/**
* Called when either a new PurpleConversation is created
@@ -361,6 +375,8 @@ init_theme_for_webkit (PurpleConversation *conv, char *style_dir)
/* I need to unref this style when the webkit object destroys */
g_signal_connect (G_OBJECT(webkit), "destroy", G_CALLBACK(webkit_on_webview_destroy), copy);
+ if (purple_conversation_get_type (conv) == PURPLE_CONV_TYPE_CHAT)
+ webkit_set_groupchat (GTK_WEBVIEW (webkit));
g_free (basedir);
g_free (baseuri);
g_free (header);
--
cgit v1.2.1
From 624bc9c8b2d3885eb3c30a9ac29c7bd8a5173121 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Tue, 25 Aug 2009 15:40:06 +0000
Subject: Read AllowTextColors key properly.
---
pidgin/plugins/adiumthemes/message-style.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/pidgin/plugins/adiumthemes/message-style.c b/pidgin/plugins/adiumthemes/message-style.c
index 6f7e4449c3..3365d1411f 100644
--- a/pidgin/plugins/adiumthemes/message-style.c
+++ b/pidgin/plugins/adiumthemes/message-style.c
@@ -122,7 +122,7 @@ pidgin_message_style_save_state (const PidginMessageStyle *style)
g_free (variant);
}
-void
+static void
pidgin_message_style_load_state (PidginMessageStyle *style)
{
char *prefname = g_strdup_printf ("/plugins/gtk/adiumthemes/%s", style->cf_bundle_identifier);
@@ -220,12 +220,13 @@ pidgin_message_style_read_info_plist (PidginMessageStyle *style, const char* var
else if (str_for_key ("DefaultBackgroundColor", key, variant))
pr = parse_info_plist_key_value (iter, &style->default_background_color, "string");
else if (str_for_key ("AllowTextColors", key, variant))
- pr = parse_info_plist_key_value (iter, &style->allow_text_colors, "string");
+ pr = parse_info_plist_key_value (iter, &style->allow_text_colors, "integer");
else if (str_for_key ("ImageMask", key, variant))
pr = parse_info_plist_key_value (iter, &style->image_mask, "string");
+ if (!pr)
+ purple_debug_warning ("webkit", "Failed to parse key %s\n", key);
g_free (key);
- if (!pr) break; /* does not make sense */
}
xmlnode_free (plist);
@@ -328,6 +329,7 @@ pidgin_message_style_load (const char* styledir)
/* non variant dependent Info.plist checks */
if (style->message_view_version < 3) {
+ purple_debug_info ("webkit", "%s is a legacy style (version %d) and will not be loaded\n", style->cf_bundle_name, style->message_view_version);
pidgin_message_style_unref (style);
return NULL;
}
--
cgit v1.2.1
From 3fb1b8e2803c6684e6f994dfd362ed1e14fecde6 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Wed, 26 Aug 2009 03:19:30 +0000
Subject: fixed conflicts in previous merge.
---
pidgin/plugins/Makefile.am | 33 ---------------------------------
1 file changed, 33 deletions(-)
diff --git a/pidgin/plugins/Makefile.am b/pidgin/plugins/Makefile.am
index 3c732ca995..593118692a 100644
--- a/pidgin/plugins/Makefile.am
+++ b/pidgin/plugins/Makefile.am
@@ -76,10 +76,6 @@ relnot_la_SOURCES = relnot.c
sendbutton_la_SOURCES = sendbutton.c
spellchk_la_SOURCES = spellchk.c
themeedit_la_SOURCES = themeedit.c themeedit-icon.c themeedit-icon.h
-<<<<<<< variant A
-timestamp_la_SOURCES = timestamp.c
-timestamp_format_la_SOURCES = timestamp_format.c
-vvconfig_SOURCES = vvconfig.c
xmppconsole_la_SOURCES = xmppconsole.c
convcolors_la_LIBADD = $(GTK_LIBS)
@@ -87,41 +83,12 @@ contact_priority_la_LIBADD = $(GTK_LIBS)
extplacement_la_LIBADD = $(GTK_LIBS)
gtk_signals_test_la_LIBADD = $(GTK_LIBS)
gtkbuddynote_la_LIBADD = $(GTK_LIBS)
-history_la_LIBADD = $(GTK_LIBS)
iconaway_la_LIBADD = $(GTK_LIBS)
-markerline_la_LIBADD = $(GTK_LIBS)
-notify_la_LIBADD = $(GTK_LIBS)
pidginrc_la_LIBADD = $(GTK_LIBS)
relnot_la_LIBADD = $(GLIB_LIBS)
sendbutton_la_LIBADD = $(GTK_LIBS)
spellchk_la_LIBADD = $(GTK_LIBS)
themeedit_la_LIBADD = $(GTK_LIBS)
-timestamp_la_LIBADD = $(GTK_LIBS)
-timestamp_format_la_LIBADD = $(GTK_LIBS)
-vvconfig_la_LIBADD = $(GTK_LIBS) $(GSTREAMER_LIBS)
->>>>>>> variant B
-####### Ancestor
-timestamp_la_SOURCES = timestamp.c
-timestamp_format_la_SOURCES = timestamp_format.c
-xmppconsole_la_SOURCES = xmppconsole.c
-
-convcolors_la_LIBADD = $(GTK_LIBS)
-contact_priority_la_LIBADD = $(GTK_LIBS)
-extplacement_la_LIBADD = $(GTK_LIBS)
-gtk_signals_test_la_LIBADD = $(GTK_LIBS)
-gtkbuddynote_la_LIBADD = $(GTK_LIBS)
-history_la_LIBADD = $(GTK_LIBS)
-iconaway_la_LIBADD = $(GTK_LIBS)
-markerline_la_LIBADD = $(GTK_LIBS)
-notify_la_LIBADD = $(GTK_LIBS)
-pidginrc_la_LIBADD = $(GTK_LIBS)
-relnot_la_LIBADD = $(GLIB_LIBS)
-sendbutton_la_LIBADD = $(GTK_LIBS)
-spellchk_la_LIBADD = $(GTK_LIBS)
-themeedit_la_LIBADD = $(GTK_LIBS)
-timestamp_la_LIBADD = $(GTK_LIBS)
-timestamp_format_la_LIBADD = $(GTK_LIBS)
-======= end
xmppconsole_la_LIBADD = $(GTK_LIBS)
endif # PLUGINS
--
cgit v1.2.1
From 7341097c624984bcaff9d29db6d1bee3175f6e16 Mon Sep 17 00:00:00 2001
From: Arnold Noronha
Date: Wed, 14 Oct 2009 02:52:43 +0000
Subject: save the style path across sessions.
---
pidgin/plugins/adiumthemes/webkit.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 5d033762a3..74ed4ea9b6 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -658,6 +658,7 @@ style_changed (GtkWidget* combobox, gpointer null)
g_free (name);
g_free (cur_style_dir);
cur_style_dir = g_strdup (iter->data);;
+ purple_prefs_set_string ("/plugins/gtk/adiumthemes/stylepath", cur_style_dir);
/* inform the user that existing conversations haven't changed */
dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, "The style for existing conversations have not been changed. Please close and re-open the conversation for the changes to take effect.");
@@ -846,7 +847,7 @@ init_plugin(PurplePlugin *plugin) {
purple_prefs_add_none ("/plugins");
purple_prefs_add_none ("/plugins/gtk");
purple_prefs_add_none ("/plugins/gtk/adiumthemes");
- purple_prefs_add_string ("/plugins/gtk/adiumthemes/csspath", "");
+ purple_prefs_add_string ("/plugins/gtk/adiumthemes/stylepath", "");
}
PURPLE_INIT_PLUGIN(webkit, init_plugin, info)
--
cgit v1.2.1
From 50d18703639013582deb9656fa5a5faa3e528d0b Mon Sep 17 00:00:00 2001
From: Jorge Villase?or
Date: Sat, 6 Feb 2010 22:08:41 +0000
Subject: Don't crash if we don't have any theme installed.
---
pidgin/plugins/adiumthemes/webkit.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/pidgin/plugins/adiumthemes/webkit.c b/pidgin/plugins/adiumthemes/webkit.c
index 74ed4ea9b6..e6fcd18cdb 100644
--- a/pidgin/plugins/adiumthemes/webkit.c
+++ b/pidgin/plugins/adiumthemes/webkit.c
@@ -39,6 +39,7 @@
/* Purple headers */
#include
#include
+#include
#include
#include
#include
@@ -551,8 +552,15 @@ style_set_default ()
const char *stylepath = purple_prefs_get_string ("/plugins/gtk/adiumthemes/stylepath");
g_assert (cur_style_dir == NULL);
- if (stylepath)
+ if (stylepath && *stylepath)
styles = g_list_prepend (styles, g_strdup (stylepath));
+ else {
+ purple_notify_error(handle, _("Webkit themes"),
+ _("Can't find installed styles"),
+ _("Please install some theme and verify the installation path"));
+
+ return;
+ }
/* pick any one that works. Note that we have first preference
* for the one in the userdir */
--
cgit v1.2.1
From 3ac4bddc8a03bf9a05e19816e10c99f9ad6df17a Mon Sep 17 00:00:00 2001
From: Jorge Villase?or
Date: Sat, 6 Feb 2010 22:18:05 +0000
Subject: webkit: Scroll to end when appending html.
Most of the code was taken from imhtml.
---
pidgin/gtkconv.c | 2 ++
pidgin/gtkwebview.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++
pidgin/gtkwebview.h | 16 +++++++++++++
3 files changed, 85 insertions(+)
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
index 1a7e59770a..42546046be 100644
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -4915,6 +4915,8 @@ setup_common_pane(PidginConversation *gtkconv)
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (webview_sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtkconv->webview = gtk_webview_new ();
+ gtk_webview_set_vadjustment(GTK_WEBVIEW(gtkconv->webview),
+ gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(webview_sw)));
gtk_container_add (GTK_CONTAINER (webview_sw), gtkconv->webview);
gtk_widget_set_size_request(gtkconv->webview, -1, 0);
diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
index f88fb5a51a..bd90579bb7 100644
--- a/pidgin/gtkwebview.c
+++ b/pidgin/gtkwebview.c
@@ -48,6 +48,9 @@ struct GtkWebViewPriv {
/* JS execute queue */
GQueue *js_queue;
gboolean is_loading;
+ GtkAdjustment *vadj;
+ guint scroll_src;
+ GTimer *scroll_time;
};
GtkWidget* gtk_webview_new (void)
@@ -290,6 +293,10 @@ char *gtk_webview_quote_js_string(const char *text)
return g_string_free (str, FALSE);
}
+void gtk_webview_set_vadjustment(GtkWebView *webview, GtkAdjustment *vadj)
+{
+ webview->priv->vadj = vadj;
+}
/* this is a "hack", my plan is to eventually handle this
* correctly using a signals and a plugin: the plugin will have
@@ -304,6 +311,7 @@ gtk_webview_append_html (GtkWebView* view, const char* html)
printf ("script: %s\n", script);
webkit_web_view_execute_script (WEBKIT_WEB_VIEW (view), script);
view->priv->empty = FALSE;
+ gtk_webview_scroll_to_end(view, TRUE);
g_free (script);
g_free (escaped);
}
@@ -313,6 +321,65 @@ gboolean gtk_webview_is_empty (GtkWebView *view)
return view->priv->empty;
}
+#define MAX_SCROLL_TIME 0.4 /* seconds */
+#define SCROLL_DELAY 33 /* milliseconds */
+
+/*
+ * Smoothly scroll a WebView.
+ *
+ * @return TRUE if the window needs to be scrolled further, FALSE if we're at the bottom.
+ */
+static gboolean smooth_scroll_cb(gpointer data)
+{
+ struct GtkWebViewPriv *priv = data;
+ GtkAdjustment *adj = priv->vadj;
+ gdouble max_val = adj->upper - adj->page_size;
+ gdouble scroll_val = gtk_adjustment_get_value(adj) + ((max_val - gtk_adjustment_get_value(adj)) / 3);
+
+ g_return_val_if_fail(priv->scroll_time != NULL, FALSE);
+
+ if (g_timer_elapsed(priv->scroll_time, NULL) > MAX_SCROLL_TIME || scroll_val >= max_val) {
+ /* time's up. jump to the end and kill the timer */
+ gtk_adjustment_set_value(adj, max_val);
+ g_timer_destroy(priv->scroll_time);
+ priv->scroll_time = NULL;
+ g_source_remove(priv->scroll_src);
+ priv->scroll_src = 0;
+ return FALSE;
+ }
+
+ /* scroll by 1/3rd the remaining distance */
+ gtk_adjustment_set_value(adj, scroll_val);
+ return TRUE;
+}
+
+static gboolean scroll_idle_cb(gpointer data)
+{
+ struct GtkWebViewPriv *priv = data;
+ GtkAdjustment *adj = priv->vadj;
+ if(adj) {
+ gtk_adjustment_set_value(adj, adj->upper - adj->page_size);
+ }
+ priv->scroll_src = 0;
+ return FALSE;
+}
+
+void gtk_webview_scroll_to_end(GtkWebView *webview, gboolean smooth)
+{
+ struct GtkWebViewPriv *priv = webview->priv;
+ if (priv->scroll_time)
+ g_timer_destroy(priv->scroll_time);
+ if (priv->scroll_src)
+ g_source_remove(priv->scroll_src);
+ if(smooth) {
+ priv->scroll_time = g_timer_new();
+ priv->scroll_src = g_timeout_add_full(G_PRIORITY_LOW, SCROLL_DELAY, smooth_scroll_cb, priv, NULL);
+ } else {
+ priv->scroll_time = NULL;
+ priv->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, priv, NULL);
+ }
+}
+
GType gtk_webview_get_type (void)
{
static GType mview_type = 0;
diff --git a/pidgin/gtkwebview.h b/pidgin/gtkwebview.h
index 574c4ae262..ff5a59dfdc 100644
--- a/pidgin/gtkwebview.h
+++ b/pidgin/gtkwebview.h
@@ -72,6 +72,14 @@ GType gtk_webview_get_type (void);
*/
GtkWidget* gtk_webview_new (void);
+/**
+ * Set the vertical adjustment for the GtkWebView.
+ *
+ * @param webview The GtkWebView.
+ * @param vadj The GtkAdjustment that control the webview.
+ */
+void gtk_webview_set_vadjustment(GtkWebView *webview, GtkAdjustment *vadj);
+
/**
* A very basic routine to append html, which can be considered
* equivalent to a "document.write" using JavaScript.
@@ -124,4 +132,12 @@ void gtk_webview_safe_execute_script (GtkWebView *webview, const char* script);
*/
char* gtk_webview_quote_js_string (const char* str);
+/**
+ * Scrolls the Webview to the end of its contents.
+ *
+ * @param webview The GtkWebView.
+ * @param smoth A boolean indicating if smooth scrolling should be used.
+ */
+void gtk_webview_scroll_to_end(GtkWebView *webview, gboolean smooth);
+
#endif /* _PIDGIN_WEBVIEW_H_ */
--
cgit v1.2.1
From 6e4f412d7a684f21ad94f572d5226e4f42bb2a41 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 16 Feb 2010 06:54:06 +0000
Subject: Fix some more GTK+3 stuff in gtkconv.c.
---
pidgin/gtkconv.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
index 502d9be088..5d70f7b8f4 100644
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -3610,6 +3610,17 @@ regenerate_media_items(PidginWindow *win)
purple_prpl_get_media_caps(account,
purple_conversation_get_name(conv));
+#if GTK_CHECK_VERSION(2,6,0)
+ gtk_action_set_sensitive(win->audio_call,
+ caps & PURPLE_MEDIA_CAPS_AUDIO
+ ? TRUE : FALSE);
+ gtk_action_set_sensitive(win->video_call,
+ caps & PURPLE_MEDIA_CAPS_VIDEO
+ ? TRUE : FALSE);
+ gtk_action_set_sensitive(win->audio_video_call,
+ caps & PURPLE_MEDIA_CAPS_AUDIO_VIDEO
+ ? TRUE : FALSE);
+#else
gtk_widget_set_sensitive(win->audio_call,
caps & PURPLE_MEDIA_CAPS_AUDIO
? TRUE : FALSE);
@@ -3619,16 +3630,29 @@ regenerate_media_items(PidginWindow *win)
gtk_widget_set_sensitive(win->audio_video_call,
caps & PURPLE_MEDIA_CAPS_AUDIO_VIDEO
? TRUE : FALSE);
+#endif
} else if (purple_conversation_get_type(conv)
== PURPLE_CONV_TYPE_CHAT) {
/* for now, don't care about chats... */
+#if GTK_CHECK_VERSION(2,6,0)
+ gtk_action_set_sensitive(win->audio_call, FALSE);
+ gtk_action_set_sensitive(win->video_call, FALSE);
+ gtk_action_set_sensitive(win->audio_video_call, FALSE);
+#else
gtk_widget_set_sensitive(win->audio_call, FALSE);
gtk_widget_set_sensitive(win->video_call, FALSE);
gtk_widget_set_sensitive(win->audio_video_call, FALSE);
+#endif
} else {
+#if GTK_CHECK_VERSION(2,6,0)
+ gtk_action_set_sensitive(win->audio_call, FALSE);
+ gtk_action_set_sensitive(win->video_call, FALSE);
+ gtk_action_set_sensitive(win->audio_video_call, FALSE);
+#else
gtk_widget_set_sensitive(win->audio_call, FALSE);
gtk_widget_set_sensitive(win->video_call, FALSE);
gtk_widget_set_sensitive(win->audio_video_call, FALSE);
+#endif
}
#endif
}
@@ -10208,8 +10232,12 @@ pidgin_conv_window_remove_gtkconv(PidginWindow *win, PidginConversation *gtkconv
conv_type = purple_conversation_get_type(gtkconv->active_conv);
index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont);
+#if GTK_CHECK_VERSION(2,10,0)
+ g_object_ref_sink(G_OBJECT(gtkconv->tab_cont));
+#else
g_object_ref(gtkconv->tab_cont);
gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont));
+#endif
gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index);
--
cgit v1.2.1
From acc563d90dfdf3d3fb19e2d9dae1bf8127d0ff8f Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 16 Feb 2010 07:40:57 +0000
Subject: Fix some new uses of GtkTooltips for GTK+ > 2.12.
---
pidgin/gtkrequest.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c
index 59217cabec..36bb868a37 100644
--- a/pidgin/gtkrequest.c
+++ b/pidgin/gtkrequest.c
@@ -85,7 +85,9 @@ pidgin_widget_decorate_account(GtkWidget *cont, PurpleAccount *account)
{
GtkWidget *image;
GdkPixbuf *pixbuf;
+#if !GTK_CHECK_VERSION(2,12,0)
GtkTooltips *tips;
+#endif
if (!account)
return;
@@ -94,8 +96,12 @@ pidgin_widget_decorate_account(GtkWidget *cont, PurpleAccount *account)
image = gtk_image_new_from_pixbuf(pixbuf);
g_object_unref(G_OBJECT(pixbuf));
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_widget_set_tooltip_text(image, purple_account_get_username(account));
+#else
tips = gtk_tooltips_new();
gtk_tooltips_set_tip(tips, image, purple_account_get_username(account), NULL);
+#endif
if (GTK_IS_DIALOG(cont)) {
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(cont)->action_area), image, FALSE, TRUE, 0);
--
cgit v1.2.1
From 06ddb54c84eaf839c1264cd63ff4f566d27e043a Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 16 Feb 2010 08:21:11 +0000
Subject: Update GtkMedia window to use GtkUIManager.
---
pidgin/gtkmedia.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/pidgin/gtkmedia.c b/pidgin/gtkmedia.c
index bae6ad3901..8328622f5e 100644
--- a/pidgin/gtkmedia.c
+++ b/pidgin/gtkmedia.c
@@ -84,7 +84,11 @@ struct _PidginMediaPrivate
gchar *screenname;
gulong level_handler_id;
+#if GTK_CHECK_VERSION(2,4,0)
+ GtkUIManager *ui;
+#else
GtkItemFactory *item_factory;
+#endif
GtkWidget *menubar;
GtkWidget *statusbar;
@@ -260,13 +264,33 @@ pidgin_x_error_handler(Display *display, XErrorEvent *event)
#endif
static void
+#if GTK_CHECK_VERSION(2,4,0)
+menu_hangup(GtkAction *action, gpointer data)
+#else
menu_hangup(gpointer data, guint action, GtkWidget *item)
+#endif
{
PidginMedia *gtkmedia = PIDGIN_MEDIA(data);
purple_media_stream_info(gtkmedia->priv->media,
PURPLE_MEDIA_INFO_HANGUP, NULL, NULL, TRUE);
}
+#if GTK_CHECK_VERSION(2,4,0)
+static const GtkActionEntry menu_entries[] = {
+ { "MediaMenu", NULL, N_("_Media"), NULL, NULL, NULL },
+ { "Hangup", NULL, N_("_Hangup"), NULL, NULL, G_CALLBACK(menu_hangup) },
+};
+
+static const char *media_menu =
+""
+ ""
+ ""
+ ""
+ ""
+ ""
+"";
+
+#else
static GtkItemFactoryEntry menu_items[] = {
{ N_("/_Media"), NULL, NULL, 0, "", NULL },
{ N_("/Media/_Hangup"), NULL, menu_hangup, 0, "- ", NULL },
@@ -279,13 +303,45 @@ item_factory_translate_func (const char *path, gpointer func_data)
{
return _(path);
}
+#endif
static GtkWidget *
setup_menubar(PidginMedia *window)
{
+#if GTK_CHECK_VERSION(2,4,0)
+ GtkActionGroup *action_group;
+ GError *error;
+#endif
GtkAccelGroup *accel_group;
GtkWidget *menu;
+#if GTK_CHECK_VERSION(2,4,0)
+ action_group = gtk_action_group_new("MediaActions");
+ gtk_action_group_add_actions(action_group,
+ menu_entries,
+ G_N_ELEMENTS(menu_entries),
+ GTK_WINDOW(window));
+#ifdef ENABLE_NLS
+ gtk_action_group_set_translation_domain(action_group,
+ PACKAGE);
+#endif
+
+ window->priv->ui = gtk_ui_manager_new();
+ gtk_ui_manager_insert_action_group(window->priv->ui, action_group, 0);
+
+ accel_group = gtk_ui_manager_get_accel_group(window->priv->ui);
+ gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
+
+ error = NULL;
+ if (!gtk_ui_manager_add_ui_from_string(window->priv->ui, media_menu, -1, &error))
+ {
+ g_message("building menus failed: %s", error->message);
+ g_error_free(error);
+ exit(EXIT_FAILURE);
+ }
+
+ menu = gtk_ui_manager_get_widget(window->priv->ui, "/Media");
+#else
accel_group = gtk_accel_group_new ();
gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
g_object_unref(accel_group);
@@ -304,6 +360,7 @@ setup_menubar(PidginMedia *window)
menu = gtk_item_factory_get_widget(
window->priv->item_factory, "");
+#endif
gtk_widget_show(menu);
return menu;
@@ -384,10 +441,17 @@ pidgin_media_dispose(GObject *media)
gtkmedia->priv->media = NULL;
}
+#if GTK_CHECK_VERSION(2,4,0)
+ if (gtkmedia->priv->ui) {
+ g_object_unref(gtkmedia->priv->ui);
+ gtkmedia->priv->ui = NULL;
+ }
+#else
if (gtkmedia->priv->item_factory) {
g_object_unref(gtkmedia->priv->item_factory);
gtkmedia->priv->item_factory = NULL;
}
+#endif
G_OBJECT_CLASS(parent_class)->dispose(media);
}
--
cgit v1.2.1
From 08b827ec2fb12aed25b947bec77bc0d5ce3c5b34 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Tue, 16 Feb 2010 08:29:28 +0000
Subject: Remove some deprecated functions.
---
pidgin/gtkutils.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
index 4491117eb0..99debee34b 100644
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -406,13 +406,13 @@ pidgin_pixbuf_button_from_stock(const char *text, const char *icon,
gtk_container_add(GTK_CONTAINER(button), bbox);
if (icon) {
- gtk_box_pack_start_defaults(GTK_BOX(bbox), ibox);
+ gtk_box_pack_start(GTK_BOX(bbox), ibox, TRUE, TRUE, 0);
image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON);
gtk_box_pack_end(GTK_BOX(ibox), image, FALSE, TRUE, 0);
}
if (text) {
- gtk_box_pack_start_defaults(GTK_BOX(bbox), lbox);
+ gtk_box_pack_start(GTK_BOX(bbox), lbox, TRUE, TRUE, 0);
label = gtk_label_new(NULL);
gtk_label_set_text_with_mnemonic(GTK_LABEL(label), text);
gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
@@ -892,7 +892,11 @@ pidgin_account_option_menu_new(PurpleAccount *default_account,
}
gboolean
+#if GTK_CHECK_VERSION(2,4,0)
+pidgin_check_if_dir(const char *path, gpointer filesel)
+#else
pidgin_check_if_dir(const char *path, GtkFileSelection *filesel)
+#endif
{
char *dirname = NULL;
@@ -901,7 +905,9 @@ pidgin_check_if_dir(const char *path, GtkFileSelection *filesel)
if (path[strlen(path) - 1] != G_DIR_SEPARATOR) {
dirname = g_strconcat(path, G_DIR_SEPARATOR_S, NULL);
}
+#if !GTK_CHECK_VERSION(2,4,0)
gtk_file_selection_set_filename(filesel, (dirname != NULL) ? dirname : path);
+#endif
g_free(dirname);
return TRUE;
}
--
cgit v1.2.1
From 6ac77ef48341bc07105a786c2ca96d64b87776b5 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Fri, 19 Feb 2010 07:21:14 +0000
Subject: disapproval of revision '1762d0df9a12b1d11b971176664e1d69634f08e5'
---
pidgin/gtkutils.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
index 99debee34b..4491117eb0 100644
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -406,13 +406,13 @@ pidgin_pixbuf_button_from_stock(const char *text, const char *icon,
gtk_container_add(GTK_CONTAINER(button), bbox);
if (icon) {
- gtk_box_pack_start(GTK_BOX(bbox), ibox, TRUE, TRUE, 0);
+ gtk_box_pack_start_defaults(GTK_BOX(bbox), ibox);
image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON);
gtk_box_pack_end(GTK_BOX(ibox), image, FALSE, TRUE, 0);
}
if (text) {
- gtk_box_pack_start(GTK_BOX(bbox), lbox, TRUE, TRUE, 0);
+ gtk_box_pack_start_defaults(GTK_BOX(bbox), lbox);
label = gtk_label_new(NULL);
gtk_label_set_text_with_mnemonic(GTK_LABEL(label), text);
gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
@@ -892,11 +892,7 @@ pidgin_account_option_menu_new(PurpleAccount *default_account,
}
gboolean
-#if GTK_CHECK_VERSION(2,4,0)
-pidgin_check_if_dir(const char *path, gpointer filesel)
-#else
pidgin_check_if_dir(const char *path, GtkFileSelection *filesel)
-#endif
{
char *dirname = NULL;
@@ -905,9 +901,7 @@ pidgin_check_if_dir(const char *path, GtkFileSelection *filesel)
if (path[strlen(path) - 1] != G_DIR_SEPARATOR) {
dirname = g_strconcat(path, G_DIR_SEPARATOR_S, NULL);
}
-#if !GTK_CHECK_VERSION(2,4,0)
gtk_file_selection_set_filename(filesel, (dirname != NULL) ? dirname : path);
-#endif
g_free(dirname);
return TRUE;
}
--
cgit v1.2.1
From 990b11a636fd63e951c18ec20e94eda679736dc4 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Fri, 19 Feb 2010 07:23:38 +0000
Subject: Remove some deprecated functions, without extra changes this time.
---
pidgin/gtkutils.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
index 4491117eb0..df9b2f62de 100644
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -406,13 +406,13 @@ pidgin_pixbuf_button_from_stock(const char *text, const char *icon,
gtk_container_add(GTK_CONTAINER(button), bbox);
if (icon) {
- gtk_box_pack_start_defaults(GTK_BOX(bbox), ibox);
+ gtk_box_pack_start(GTK_BOX(bbox), ibox, TRUE, TRUE, 0);
image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON);
gtk_box_pack_end(GTK_BOX(ibox), image, FALSE, TRUE, 0);
}
if (text) {
- gtk_box_pack_start_defaults(GTK_BOX(bbox), lbox);
+ gtk_box_pack_start(GTK_BOX(bbox), lbox, TRUE, TRUE, 0);
label = gtk_label_new(NULL);
gtk_label_set_text_with_mnemonic(GTK_LABEL(label), text);
gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
--
cgit v1.2.1
From ef370aeea4bd29016a334ff00529c224a295f501 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Sat, 5 Jun 2010 22:30:51 +0000
Subject: With 2.7.0, we don't need these GTK_CHECK_VERSION's any more.
---
pidgin/gtkprefs.c | 80 ++-----------------------------------------------------
1 file changed, 2 insertions(+), 78 deletions(-)
diff --git a/pidgin/gtkprefs.c b/pidgin/gtkprefs.c
index 0bb8b54839..91fece25a1 100644
--- a/pidgin/gtkprefs.c
+++ b/pidgin/gtkprefs.c
@@ -196,13 +196,12 @@ dropdown_set(GObject *w, const char *key)
int int_value;
gboolean bool_value;
PurplePrefType type;
-
-#if GTK_CHECK_VERSION(2,4,0)
GtkTreeIter iter;
GtkTreeModel *tree_model;
tree_model = gtk_combo_box_get_model(GTK_COMBO_BOX(w));
- gtk_combo_box_get_active_iter(GTK_COMBO_BOX(w), &iter);
+ if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(w), &iter))
+ return;
type = GPOINTER_TO_INT(g_object_get_data(w, "type"));
@@ -227,24 +226,6 @@ dropdown_set(GObject *w, const char *key)
purple_prefs_set_bool(key, bool_value);
}
-#else
- type = GPOINTER_TO_INT(g_object_get_data(w, "type"));
-
- if (type == PURPLE_PREF_INT) {
- int_value = GPOINTER_TO_INT(g_object_get_data(w, "value"));
-
- purple_prefs_set_int(key, int_value);
- }
- else if (type == PURPLE_PREF_STRING) {
- str_value = (const char *)g_object_get_data(w, "value");
-
- purple_prefs_set_string(key, str_value);
- }
- else if (type == PURPLE_PREF_BOOLEAN) {
- bool_value = (gboolean)GPOINTER_TO_INT(g_object_get_data(w, "value"));
- purple_prefs_set_bool(key, bool_value);
- }
-#endif
}
GtkWidget *
@@ -260,7 +241,6 @@ pidgin_prefs_dropdown_from_list(GtkWidget *box, const gchar *title,
int int_value = 0;
const char *str_value = NULL;
gboolean bool_value = FALSE;
-#if GTK_CHECK_VERSION(2,4,0)
GtkListStore *store;
GtkTreeIter iter;
GtkTreeIter active;
@@ -333,62 +313,6 @@ pidgin_prefs_dropdown_from_list(GtkWidget *box, const gchar *title,
g_signal_connect(G_OBJECT(dropdown), "changed",
G_CALLBACK(dropdown_set), (char *)key);
-#else
- GtkWidget *opt, *menu;
- int o = 0;
-
- g_return_val_if_fail(menuitems != NULL, NULL);
-
- dropdown = gtk_option_menu_new();
- menu = gtk_menu_new();
-
- if (type == PURPLE_PREF_INT)
- stored_int = purple_prefs_get_int(key);
- else if (type == PURPLE_PREF_STRING)
- stored_str = purple_prefs_get_string(key);
- else if (type == PURPLE_PREF_BOOLEAN)
- stored_bool = purple_prefs_get_bool(key);
-
- while (menuitems != NULL && (text = (char *)menuitems->data) != NULL) {
- menuitems = g_list_next(menuitems);
- g_return_val_if_fail(menuitems != NULL, NULL);
-
- opt = gtk_menu_item_new_with_label(text);
-
- g_object_set_data(G_OBJECT(opt), "type", GINT_TO_POINTER(type));
- g_object_set_data(G_OBJECT(opt), "value", menuitems->data);
-
- if (type == PURPLE_PREF_INT)
- int_value = GPOINTER_TO_INT(menuitems->data);
- else if (type == PURPLE_PREF_STRING)
- str_value = (const char *)menuitems->data;
- else if (type == PURPLE_PREF_BOOLEAN)
- bool_value = (gboolean)GPOINTER_TO_INT(menuitems->data);
-
- g_signal_connect(G_OBJECT(opt), "activate",
- G_CALLBACK(dropdown_set), (char *)key);
-
- gtk_widget_show(opt);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt);
-
- if ((type == PURPLE_PREF_INT && stored_int == int_value) ||
- (type == PURPLE_PREF_STRING && stored_str != NULL &&
- !strcmp(stored_str, str_value)) ||
- (type == PURPLE_PREF_BOOLEAN &&
- (stored_bool == bool_value))) {
-
- gtk_menu_set_active(GTK_MENU(menu), o);
- }
-
- menuitems = g_list_next(menuitems);
-
- o++;
- }
-
- gtk_option_menu_set_menu(GTK_OPTION_MENU(dropdown), menu);
-
-#endif
-
pidgin_add_widget_to_vbox(GTK_BOX(box), title, NULL, dropdown, FALSE, &label);
return label;
--
cgit v1.2.1
From 055fe069a7cedcbd7e2394c51f5b165865729ce0 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Sun, 25 Jul 2010 22:37:17 +0000
Subject: gtk_widget_[gs]et_{mapped,realized} were added in GTK+ 2.20.
---
pidgin/plugins/ticker/gtkticker.c | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/pidgin/plugins/ticker/gtkticker.c b/pidgin/plugins/ticker/gtkticker.c
index 38ce49ed6e..d4c11a8105 100644
--- a/pidgin/plugins/ticker/gtkticker.c
+++ b/pidgin/plugins/ticker/gtkticker.c
@@ -21,28 +21,24 @@
* GtkTicker Copyright 2000 Syd Logan
*/
-/* FIXME: GTK+ deprecated GTK_WIDGET_MAPPED/REALIZED, but don't provide
- accessor functions yet. */
-#undef GSEAL_ENABLE
-
#include "gtkticker.h"
#include
-/* These don't seem to be in a release yet. See BZ #69872 */
-#define gtk_widget_is_mapped(x) GTK_WIDGET_MAPPED(x)
-#define gtk_widget_is_realized(x) GTK_WIDGET_REALIZED(x)
-#define gtk_widget_set_realized(x,y) do {\
- if (y) \
- GTK_WIDGET_SET_FLAGS(x, GTK_REALIZED); \
- else \
- GTK_WIDGET_UNSET_FLAGS(x, GTK_REALIZED); \
-} while(0)
+#if !GTK_CHECK_VERSION(2,20,0)
+#define gtk_widget_get_mapped(x) GTK_WIDGET_MAPPED(x)
#define gtk_widget_set_mapped(x,y) do {\
if (y) \
GTK_WIDGET_SET_FLAGS(x, GTK_MAPPED); \
else \
GTK_WIDGET_UNSET_FLAGS(x, GTK_MAPPED); \
} while(0)
+#define gtk_widget_get_realized(x) GTK_WIDGET_REALIZED(x)
+#define gtk_widget_set_realized(x,y) do {\
+ if (y) \
+ GTK_WIDGET_SET_FLAGS(x, GTK_REALIZED); \
+ else \
+ GTK_WIDGET_UNSET_FLAGS(x, GTK_REALIZED); \
+} while(0)
#if !GTK_CHECK_VERSION(2,18,0)
#define gtk_widget_get_visible(x) GTK_WIDGET_VISIBLE(x)
@@ -51,6 +47,7 @@
#define gtk_widget_get_window(x) x->window
#endif
#endif
+#endif
static void gtk_ticker_compute_offsets (GtkTicker *ticker);
static void gtk_ticker_class_init (GtkTickerClass *klass);
@@ -181,13 +178,13 @@ static void gtk_ticker_put (GtkTicker *ticker, GtkWidget *widget)
ticker->children = g_list_append (ticker->children, child_info);
- if (gtk_widget_is_realized (ticker))
+ if (gtk_widget_get_realized (ticker))
gtk_widget_realize (widget);
if (gtk_widget_get_visible (GTK_WIDGET (ticker)) &&
gtk_widget_get_visible (widget))
{
- if (gtk_widget_is_mapped (GTK_WIDGET (ticker)))
+ if (gtk_widget_get_mapped (GTK_WIDGET (ticker)))
gtk_widget_map (widget);
gtk_widget_queue_resize (GTK_WIDGET (ticker));
@@ -298,7 +295,7 @@ static void gtk_ticker_map (GtkWidget *widget)
children = children->next;
if (gtk_widget_get_visible (child->widget) &&
- !gtk_widget_is_mapped (child->widget))
+ !gtk_widget_get_mapped (child->widget))
gtk_widget_map (child->widget);
}
@@ -474,7 +471,7 @@ static void gtk_ticker_size_allocate (GtkWidget *widget,
#else
widget->allocation = *allocation;
#endif
- if (gtk_widget_is_realized (widget))
+ if (gtk_widget_get_realized (widget))
gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x,
allocation->y,
--
cgit v1.2.1
From 564d4a1ba6bb3b6ab09710f9c0cf19605aa6b0dd Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Sun, 25 Jul 2010 23:38:18 +0000
Subject: Fix some additional tooltip calls.
---
pidgin/gtkconv.c | 4 ++++
pidgin/gtkimhtmltoolbar.c | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
index 80ecfaff14..44edcb85b0 100644
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -5287,8 +5287,12 @@ pidgin_conv_setup_quickfind(PidginConversation *gtkconv, GtkWidget *container)
close = pidgin_create_small_button(gtk_label_new("×"));
gtk_box_pack_start(GTK_BOX(widget), close, FALSE, FALSE, 0);
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_widget_set_tooltip_text(close, _("Close Find bar"));
+#else
gtk_tooltips_set_tip(gtkconv->tooltips, close,
_("Close Find bar"), NULL);
+#endif
label = gtk_label_new(_("Find:"));
gtk_box_pack_start(GTK_BOX(widget), label, FALSE, FALSE, 10);
diff --git a/pidgin/gtkimhtmltoolbar.c b/pidgin/gtkimhtmltoolbar.c
index 87f3b461bd..4e22d45b23 100644
--- a/pidgin/gtkimhtmltoolbar.c
+++ b/pidgin/gtkimhtmltoolbar.c
@@ -1282,7 +1282,11 @@ static void gtk_imhtmltoolbar_create_old_buttons(GtkIMHtmlToolbar *toolbar)
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(send_attention_cb), toolbar);
g_object_set_data(G_OBJECT(toolbar), "attention", button);
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_widget_set_tooltip_text(button, _("Send Attention"));
+#else
gtk_tooltips_set_tip(toolbar->tooltips, button, _("Send Attention"), NULL);
+#endif
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(toolbar), hbox, FALSE, FALSE, 0);
--
cgit v1.2.1
From 4f7401ca30a93c42f4a68a20bff3a0bd7bd5f925 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Sun, 25 Jul 2010 23:39:10 +0000
Subject: Fix blist menu and small compile error.
---
pidgin/gtkblist.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index bbf7d462e3..bf10f3d417 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -3766,6 +3766,7 @@ static const GtkActionEntry blist_menu_entries[] = {
{ "Plugins", PIDGIN_STOCK_TOOLBAR_PLUGINS, N_("Plu_gins"), "U", NULL, pidgin_plugin_dialog_show },
{ "Preferences", GTK_STOCK_PREFERENCES, N_("Pr_eferences"), "P", NULL, pidgin_prefs_show },
{ "Privacy", NULL, N_("Pr_ivacy"), NULL, NULL, pidgin_privacy_dialog_show },
+ { "SetMood", NULL, N_("Set _Mood"), "O", NULL, set_mood_show },
{ "FileTransfers", PIDGIN_STOCK_TOOLBAR_TRANSFER, N_("_File Transfers"), "T", NULL, G_CALLBACK(gtk_blist_show_xfer_dialog_cb) },
{ "RoomList", NULL, N_("R_oom List"), NULL, NULL, pidgin_roomlist_dialog_show },
{ "SystemLog", NULL, N_("System _Log"), NULL, NULL, gtk_blist_show_systemlog_cb },
@@ -3826,10 +3827,11 @@ static const char *blist_menu =
""
""
""
+ ""
""
""
""
- ""
+ ""
""
""
""
@@ -7261,7 +7263,7 @@ static void pidgin_blist_destroy(PurpleBuddyList *list)
purple_signals_disconnect_by_handle(gtkblist);
if (gtkblist->headline_close)
- gdk_pixbuf_unref(gtkblist->headline_close);
+ g_object_unref(G_OBJECT(gtkblist->headline_close));
gtk_widget_destroy(gtkblist->window);
--
cgit v1.2.1
From 10d6ed80e2b32d34f934f4ea538d46c927b8bcdc Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Sun, 25 Jul 2010 23:40:05 +0000
Subject: Let GtkFileSelection stuff compile for now.
---
pidgin/gtkutils.c | 7 +++++++
pidgin/gtkutils.h | 4 ++++
2 files changed, 11 insertions(+)
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
index 5a5e689946..6ea81f183d 100644
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -913,6 +913,12 @@ pidgin_account_option_menu_new(PurpleAccount *default_account,
}
gboolean
+#if GTK_CHECK_VERSION(2,4,0)
+pidgin_check_if_dir(const char *path, gpointer filesel)
+{
+ return FALSE;
+}
+#else
pidgin_check_if_dir(const char *path, GtkFileSelection *filesel)
{
char *dirname = NULL;
@@ -929,6 +935,7 @@ pidgin_check_if_dir(const char *path, GtkFileSelection *filesel)
return FALSE;
}
+#endif
void
pidgin_setup_gtkspell(GtkTextView *textview)
diff --git a/pidgin/gtkutils.h b/pidgin/gtkutils.h
index 53b05a9c1a..3783d9714e 100644
--- a/pidgin/gtkutils.h
+++ b/pidgin/gtkutils.h
@@ -411,7 +411,11 @@ void pidgin_setup_screenname_autocomplete(GtkWidget *entry, GtkWidget *optmenu,
*
* @return TRUE if given path is a directory, FALSE otherwise.
*/
+#if GTK_CHECK_VERSION(2,4,0)
+gboolean pidgin_check_if_dir(const char *path, gpointer filesel);
+#else
gboolean pidgin_check_if_dir(const char *path, GtkFileSelection *filesel);
+#endif
/**
* Sets up GtkSpell for the given GtkTextView, reporting errors
--
cgit v1.2.1
From aa501096a308e2b1915dd04b8f56d2a669cf049e Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Mon, 26 Jul 2010 04:14:44 +0000
Subject: Remove all the old GTK_CHECK_VERSION stuff. Of course, this makes
this branch strictly 3.0.0 only.
---
pidgin/gtkblist.c | 457 +------------------------------------------------
pidgin/gtkblist.h | 4 -
pidgin/gtkconv.c | 481 +++++++---------------------------------------------
pidgin/gtkconvwin.h | 35 +---
pidgin/gtkdocklet.c | 2 +-
pidgin/gtkmedia.c | 54 ------
pidgin/gtkutils.c | 25 ---
pidgin/gtkutils.h | 16 --
8 files changed, 66 insertions(+), 1008 deletions(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index bf10f3d417..967c10bd56 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -123,12 +123,8 @@ typedef struct
#define PIDGIN_BUDDY_LIST_GET_PRIVATE(list) \
((PidginBuddyListPrivate *)((list)->priv))
-#if GTK_CHECK_VERSION(2,4,0)
static guint accounts_merge_id;
static GtkActionGroup *accounts_action_group = NULL;
-#else
-static GtkWidget *accountmenu = NULL;
-#endif
static guint visibility_manager_count = 0;
static GdkVisibilityState gtk_blist_visibility = GDK_VISIBILITY_UNOBSCURED;
@@ -142,10 +138,8 @@ static void sort_method_none(PurpleBlistNode *node, PurpleBuddyList *blist, GtkT
static void sort_method_alphabetical(PurpleBlistNode *node, PurpleBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter);
static void sort_method_status(PurpleBlistNode *node, PurpleBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter);
static void sort_method_log_activity(PurpleBlistNode *node, PurpleBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur, GtkTreeIter *iter);
-#if GTK_CHECK_VERSION(2,4,0)
static guint sort_merge_id;
static GtkActionGroup *sort_action_group = NULL;
-#endif
static PidginBuddyList *gtkblist = NULL;
@@ -157,9 +151,6 @@ static void pidgin_blist_update(PurpleBuddyList *list, PurpleBlistNode *node);
static void pidgin_blist_update_group(PurpleBuddyList *list, PurpleBlistNode *node);
static void pidgin_blist_update_contact(PurpleBuddyList *list, PurpleBlistNode *node);
static char *pidgin_get_tooltip_text(PurpleBlistNode *node, gboolean full);
-#if !GTK_CHECK_VERSION(2,4,0)
-static const char *item_factory_translate_func (const char *path, gpointer func_data);
-#endif
static gboolean get_iter_from_node(PurpleBlistNode *node, GtkTreeIter *iter);
static gboolean buddy_is_displayable(PurpleBuddy *buddy);
static void redo_buddy_list(PurpleBuddyList *list, gboolean remove, gboolean rerender);
@@ -2053,8 +2044,6 @@ pidgin_blist_popup_menu_cb(GtkWidget *tv, void *user_data)
return handled;
}
-#if GTK_CHECK_VERSION(2,4,0)
-
static void gtk_blist_show_xfer_dialog_cb(GtkAction *item, gpointer data)
{
pidgin_xfer_dialog_show(NULL);
@@ -2112,74 +2101,13 @@ static void pidgin_blist_mute_sounds_cb(GtkToggleAction *item, gpointer data)
gtk_toggle_action_get_active(item));
}
-#else /* GTK_CHECK_VERSION(2,4,0) */
-
-static void pidgin_blist_buddy_details_cb(gpointer data, guint action, GtkWidget *item)
-{
- pidgin_set_cursor(gtkblist->window, GDK_WATCH);
-
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons",
- gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)));
-
- pidgin_clear_cursor(gtkblist->window);
-}
-
-static void pidgin_blist_show_idle_time_cb(gpointer data, guint action, GtkWidget *item)
-{
- pidgin_set_cursor(gtkblist->window, GDK_WATCH);
-
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_idle_time",
- gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)));
-
- pidgin_clear_cursor(gtkblist->window);
-}
-
-static void pidgin_blist_show_protocol_icons_cb(gpointer data, guint action, GtkWidget *item)
-{
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_protocol_icons",
- gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)));
-}
-
-static void pidgin_blist_show_empty_groups_cb(gpointer data, guint action, GtkWidget *item)
-{
- pidgin_set_cursor(gtkblist->window, GDK_WATCH);
-
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_empty_groups",
- gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)));
-
- pidgin_clear_cursor(gtkblist->window);
-}
-
-static void pidgin_blist_edit_mode_cb(gpointer callback_data, guint callback_action,
- GtkWidget *checkitem)
-{
- pidgin_set_cursor(gtkblist->window, GDK_WATCH);
-
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_offline_buddies",
- gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(checkitem)));
-
- pidgin_clear_cursor(gtkblist->window);
-}
-
-static void pidgin_blist_mute_sounds_cb(gpointer data, guint action, GtkWidget *item)
-{
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/sound/mute",
- gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)));
-}
-
-#endif /* GTK_CHECK_VERSION(2,4,0) */
static void
pidgin_blist_mute_pref_cb(const char *name, PurplePrefType type,
gconstpointer value, gpointer data)
{
-#if GTK_CHECK_VERSION(2,4,0)
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtk_ui_manager_get_action(gtkblist->ui,
"/BList/ToolsMenu/MuteSounds")), (gboolean)GPOINTER_TO_INT(value));
-#else
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(gtkblist->ift,
- N_("/Tools/Mute Sounds"))), (gboolean)GPOINTER_TO_INT(value));
-#endif
}
static void
@@ -2191,11 +2119,7 @@ pidgin_blist_sound_method_pref_cb(const char *name, PurplePrefType type,
if(!strcmp(value, "none"))
sensitive = FALSE;
-#if GTK_CHECK_VERSION(2,4,0)
gtk_action_set_sensitive(gtk_ui_manager_get_action(gtkblist->ui, "/BList/ToolsMenu/MuteSounds"), sensitive);
-#else
- gtk_widget_set_sensitive(gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Mute Sounds")), sensitive);
-#endif
}
static void
@@ -3737,7 +3661,7 @@ set_mood_show(void)
/***************************************************
* Crap *
***************************************************/
-#if GTK_CHECK_VERSION(2,4,0)
+#if 1
/* TODO: fill out tooltips... */
static const GtkActionEntry blist_menu_entries[] = {
/* Buddies menu */
@@ -4738,7 +4662,7 @@ static void pidgin_blist_hide_node(PurpleBuddyList *list, PurpleBlistNode *node,
static const char *require_connection[] =
{
-#if GTK_CHECK_VERSION(2,4,0)
+#if 1
"/BList/BuddiesMenu/NewInstantMessage",
"/BList/BuddiesMenu/JoinAChat",
"/BList/BuddiesMenu/GetUserInfo",
@@ -4765,11 +4689,7 @@ static const int require_connection_size = sizeof(require_connection)
static void
update_menu_bar(PidginBuddyList *gtkblist)
{
-#if GTK_CHECK_VERSION(2,4,0)
GtkAction *action;
-#else
- GtkWidget *widget;
-#endif
gboolean sensitive;
int i;
@@ -4779,7 +4699,6 @@ update_menu_bar(PidginBuddyList *gtkblist)
sensitive = (purple_connections_get_all() != NULL);
-#if GTK_CHECK_VERSION(2,4,0)
for (i = 0; i < require_connection_size; i++)
{
action = gtk_ui_manager_get_action(gtkblist->ui, require_connection[i]);
@@ -4797,25 +4716,6 @@ update_menu_bar(PidginBuddyList *gtkblist)
action = gtk_ui_manager_get_action(gtkblist->ui, "/BList/ToolsMenu/RoomList");
gtk_action_set_sensitive(action, pidgin_roomlist_is_showable());
-#else
- for (i = 0; i < require_connection_size; i++)
- {
- widget = gtk_item_factory_get_widget(gtkblist->ift, require_connection[i]);
- gtk_widget_set_sensitive(widget, sensitive);
- }
-
- widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Join a Chat..."));
- gtk_widget_set_sensitive(widget, pidgin_blist_joinchat_is_showable());
-
- widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Add Chat..."));
- gtk_widget_set_sensitive(widget, pidgin_blist_joinchat_is_showable());
-
- widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Privacy"));
- gtk_widget_set_sensitive(widget, sensitive);
-
- widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Room List"));
- gtk_widget_set_sensitive(widget, pidgin_roomlist_is_showable());
-#endif
}
static void
@@ -5106,14 +5006,6 @@ enum {
NUM_TARGETS
};
-#if !GTK_CHECK_VERSION(2,4,0)
-static const char *
-item_factory_translate_func (const char *path, gpointer func_data)
-{
- return _((char *)path);
-}
-#endif
-
void pidgin_blist_setup_sort_methods()
{
const char *id;
@@ -6061,10 +5953,8 @@ static void pidgin_blist_show(PurpleBuddyList *list)
GtkWidget *close;
char *pretty, *tmp;
const char *theme_name;
-#if GTK_CHECK_VERSION(2,4,0)
GtkActionGroup *action_group;
GError *error;
-#endif
GtkAccelGroup *accel_group;
GtkTreeSelection *selection;
GtkTargetEntry dte[] = {{"PURPLE_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW},
@@ -6114,7 +6004,6 @@ static void pidgin_blist_show(PurpleBuddyList *list)
gtk_widget_add_events(gtkblist->window, GDK_VISIBILITY_NOTIFY_MASK);
/******************************* Menu bar *************************************/
-#if GTK_CHECK_VERSION(2,4,0)
action_group = gtk_action_group_new("BListActions");
gtk_action_group_add_actions(action_group,
blist_menu_entries,
@@ -6149,28 +6038,6 @@ static void pidgin_blist_show(PurpleBuddyList *list)
gtk_widget_show(gtkblist->menutray);
gtk_widget_show(menu);
gtk_box_pack_start(GTK_BOX(gtkblist->main_vbox), menu, FALSE, FALSE, 0);
-#else
- accel_group = gtk_accel_group_new();
- gtk_window_add_accel_group(GTK_WINDOW (gtkblist->window), accel_group);
- g_object_unref(accel_group);
- gtkblist->ift = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "", accel_group);
- gtk_item_factory_set_translate_func(gtkblist->ift,
- (GtkTranslateFunc)item_factory_translate_func,
- NULL, NULL);
- gtk_item_factory_create_items(gtkblist->ift, G_N_ENTRIES(blist_menu),
- blist_menu, NULL);
- pidgin_load_accels();
- g_signal_connect(G_OBJECT(accel_group), "accel-changed", G_CALLBACK(pidgin_save_accels_cb), NULL);
-
- menu = gtk_item_factory_get_widget(gtkblist->ift, "");
- gtkblist->menutray = pidgin_menu_tray_new();
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtkblist->menutray);
- gtk_widget_show(gtkblist->menutray);
- gtk_widget_show(menu);
- gtk_box_pack_start(GTK_BOX(gtkblist->main_vbox), menu, FALSE, FALSE, 0);
-
- accountmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Accounts"));
-#endif
/****************************** Notebook *************************************/
gtkblist->notebook = gtk_notebook_new();
@@ -6362,7 +6229,6 @@ static void pidgin_blist_show(PurpleBuddyList *list)
/* set the Show Offline Buddies option. must be done
* after the treeview or faceprint gets mad. -Robot101
*/
-#if GTK_CHECK_VERSION(2,4,0)
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtk_ui_manager_get_action(gtkblist->ui, "/BList/BuddiesMenu/ShowMenu/ShowOffline")),
purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_offline_buddies"));
@@ -6384,30 +6250,6 @@ static void pidgin_blist_show(PurpleBuddyList *list)
if(!strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"), "none"))
gtk_action_set_sensitive(gtk_ui_manager_get_action(gtkblist->ui, "/BList/ToolsMenu/MuteSounds"), FALSE);
-#else
-
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show/Offline Buddies"))),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_offline_buddies"));
-
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show/Empty Groups"))),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_empty_groups"));
-
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Tools/Mute Sounds"))),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/sound/mute"));
-
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show/Buddy Details"))),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons"));
-
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show/Idle Times"))),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_idle_time"));
-
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show/Protocol Icons"))),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_protocol_icons"));
-
- if(!strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"), "none"))
- gtk_widget_set_sensitive(gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Mute Sounds")), FALSE);
-#endif
-
/* Update some dynamic things */
update_menu_bar(gtkblist);
pidgin_blist_update_plugin_actions();
@@ -7283,11 +7125,7 @@ static void pidgin_blist_destroy(PurpleBuddyList *list)
gtkblist->window = gtkblist->vbox = gtkblist->treeview = NULL;
g_object_unref(G_OBJECT(gtkblist->treemodel));
gtkblist->treemodel = NULL;
-#if GTK_CHECK_VERSION(2,4,0)
g_object_unref(G_OBJECT(gtkblist->ui));
-#else
- g_object_unref(G_OBJECT(gtkblist->ift));
-#endif
g_object_unref(G_OBJECT(gtkblist->empty_avatar));
gdk_cursor_unref(gtkblist->hand_cursor);
@@ -7301,9 +7139,6 @@ static void pidgin_blist_destroy(PurpleBuddyList *list)
g_free(priv);
g_free(gtkblist);
-#if !GTK_CHECK_VERSION(2,4,0)
- accountmenu = NULL;
-#endif
gtkblist = NULL;
purple_prefs_disconnect_by_handle(pidgin_blist_get_handle());
}
@@ -8313,7 +8148,6 @@ plugin_act(GtkObject *obj, PurplePluginAction *pam)
pam->callback(pam);
}
-#if GTK_CHECK_VERSION(2,4,0)
static void
build_plugin_actions(GtkActionGroup *action_group, GString *ui, char *parent,
PurplePlugin *plugin, gpointer context)
@@ -8351,42 +8185,6 @@ build_plugin_actions(GtkActionGroup *action_group, GString *ui, char *parent,
g_list_free(actions);
}
-#else
-static void
-build_plugin_actions(GtkWidget *menu, PurplePlugin *plugin,
- gpointer context)
-{
- GtkWidget *menuitem;
- PurplePluginAction *action = NULL;
- GList *actions, *l;
-
- actions = PURPLE_PLUGIN_ACTIONS(plugin, context);
-
- for (l = actions; l != NULL; l = l->next)
- {
- if (l->data)
- {
- action = (PurplePluginAction *) l->data;
- action->plugin = plugin;
- action->context = context;
-
- menuitem = gtk_menu_item_new_with_label(action->label);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
-
- g_signal_connect(G_OBJECT(menuitem), "activate",
- G_CALLBACK(plugin_act), action);
- g_object_set_data_full(G_OBJECT(menuitem), "plugin_action",
- action,
- (GDestroyNotify)purple_plugin_action_free);
- gtk_widget_show(menuitem);
- }
- else
- pidgin_separator(menu);
- }
-
- g_list_free(actions);
-}
-#endif
static void
modify_account_cb(GtkWidget *widget, gpointer data)
@@ -8421,7 +8219,6 @@ pidgin_blist_update_accounts_menu(void)
{
GList *accounts = NULL;
-#if GTK_CHECK_VERSION(2,4,0)
GtkAction *action;
GString *accounts_ui;
GString *enable_ui;
@@ -8523,164 +8320,10 @@ purple_debug_info("blist", "The account menu is {%s}\n", ui_string);
g_string_free(enable_ui, TRUE);
g_string_free(accounts_ui, TRUE);
g_free(ui_string);
-#else
- GtkWidget *menuitem = NULL, *submenu = NULL;
- GList *l = NULL;
- GtkAccelGroup *accel_group = NULL;
- gboolean disabled_accounts = FALSE;
- gboolean enabled_accounts = FALSE;
-
- if (accountmenu == NULL)
- return;
-
- /* Clear the old Accounts menu */
- for (l = gtk_container_get_children(GTK_CONTAINER(accountmenu)); l; l = g_list_delete_link(l, l)) {
- menuitem = l->data;
-
- if (menuitem != gtk_item_factory_get_widget(gtkblist->ift, N_("/Accounts/Manage Accounts")))
- gtk_widget_destroy(menuitem);
- }
-
- for (accounts = purple_accounts_get_all(); accounts; accounts = accounts->next) {
- char *buf = NULL;
- GtkWidget *image = NULL;
- PurpleAccount *account = NULL;
- GdkPixbuf *pixbuf = NULL;
-
- account = accounts->data;
-
- if(!purple_account_get_enabled(account, PIDGIN_UI)) {
- if (!disabled_accounts) {
- menuitem = gtk_menu_item_new_with_label(_("Enable Account"));
- gtk_menu_shell_append(GTK_MENU_SHELL(accountmenu), menuitem);
-
- submenu = gtk_menu_new();
- gtk_menu_set_accel_group(GTK_MENU(submenu), accel_group);
- gtk_menu_set_accel_path(GTK_MENU(submenu), N_("/Accounts/Enable Account"));
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
-
- disabled_accounts = TRUE;
- }
-
- buf = g_strconcat(purple_account_get_username(account), " (",
- purple_account_get_protocol_name(account), ")", NULL);
- menuitem = gtk_image_menu_item_new_with_label(buf);
- g_free(buf);
- pixbuf = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL);
- if (pixbuf != NULL)
- {
- if (!purple_account_is_connected(account))
- gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, 0.0, FALSE);
- image = gtk_image_new_from_pixbuf(pixbuf);
- g_object_unref(G_OBJECT(pixbuf));
- gtk_widget_show(image);
- gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
- }
- g_signal_connect(G_OBJECT(menuitem), "activate",
- G_CALLBACK(enable_account_cb), account);
- gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem);
- } else {
- enabled_accounts = TRUE;
- }
- }
-
- if (!enabled_accounts) {
- gtk_widget_show_all(accountmenu);
- return;
- }
-
- pidgin_separator(accountmenu);
- accel_group = gtk_menu_get_accel_group(GTK_MENU(accountmenu));
-
- for (accounts = purple_accounts_get_all(); accounts; accounts = accounts->next) {
- char *buf = NULL;
- char *accel_path_buf = NULL;
- GtkWidget *image = NULL;
- PurpleConnection *gc = NULL;
- PurpleAccount *account = NULL;
- GdkPixbuf *pixbuf = NULL;
- PurplePlugin *plugin = NULL;
- PurplePluginProtocolInfo *prpl_info;
-
- account = accounts->data;
-
- if (!purple_account_get_enabled(account, PIDGIN_UI))
- continue;
-
- buf = g_strconcat(purple_account_get_username(account), " (",
- purple_account_get_protocol_name(account), ")", NULL);
- menuitem = gtk_image_menu_item_new_with_label(buf);
- accel_path_buf = g_strconcat(N_("/Accounts/"), buf, NULL);
- g_free(buf);
- pixbuf = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL);
- if (pixbuf != NULL) {
- if (!purple_account_is_connected(account))
- gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf,
- 0.0, FALSE);
- image = gtk_image_new_from_pixbuf(pixbuf);
- g_object_unref(G_OBJECT(pixbuf));
- gtk_widget_show(image);
- gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
- }
- gtk_menu_shell_append(GTK_MENU_SHELL(accountmenu), menuitem);
-
- submenu = gtk_menu_new();
- gtk_menu_set_accel_group(GTK_MENU(submenu), accel_group);
- gtk_menu_set_accel_path(GTK_MENU(submenu), accel_path_buf);
- g_free(accel_path_buf);
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
-
-
- menuitem = gtk_menu_item_new_with_mnemonic(_("_Edit Account"));
- g_signal_connect(G_OBJECT(menuitem), "activate",
- G_CALLBACK(modify_account_cb), account);
- gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem);
-
- pidgin_separator(submenu);
-
- gc = purple_account_get_connection(account);
- plugin = gc && PURPLE_CONNECTION_IS_CONNECTED(gc) ? gc->prpl : NULL;
- prpl_info = plugin ? PURPLE_PLUGIN_PROTOCOL_INFO(plugin) : NULL;
-
- if (prpl_info &&
- (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_moods) ||
- PURPLE_PLUGIN_HAS_ACTIONS(plugin))) {
- if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_moods) &&
- gc->flags & PURPLE_CONNECTION_SUPPORT_MOODS) {
-
- if (purple_account_get_status(account, "mood")) {
- menuitem = gtk_menu_item_new_with_mnemonic(_("Set _Mood..."));
- g_signal_connect(G_OBJECT(menuitem), "activate",
- G_CALLBACK(set_mood_cb), account);
- gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem);
- }
- }
- if (PURPLE_PLUGIN_HAS_ACTIONS(plugin)) {
- build_plugin_actions(submenu, plugin, gc);
- }
- } else {
- menuitem = gtk_menu_item_new_with_label(_("No actions available"));
- gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem);
- gtk_widget_set_sensitive(menuitem, FALSE);
- }
-
- pidgin_separator(submenu);
-
- menuitem = gtk_menu_item_new_with_mnemonic(_("_Disable"));
- g_signal_connect(G_OBJECT(menuitem), "activate",
- G_CALLBACK(disable_account_cb), account);
- gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem);
- }
- gtk_widget_show_all(accountmenu);
-#endif
}
-#if GTK_CHECK_VERSION(2,4,0)
static guint plugins_merge_id;
static GtkActionGroup *plugins_action_group = NULL;
-#else
-static GList *plugin_submenus = NULL;
-#endif
void
pidgin_blist_update_plugin_actions(void)
@@ -8688,7 +8331,6 @@ pidgin_blist_update_plugin_actions(void)
PurplePlugin *plugin = NULL;
GList *l;
-#if GTK_CHECK_VERSION(2,4,0)
GtkAction *action;
GString *plugins_ui;
gchar *ui_string;
@@ -8745,53 +8387,8 @@ purple_debug_info("blist", "The plugins menu is {%s}\n", ui_string);
g_string_free(plugins_ui, TRUE);
g_free(ui_string);
-#else
- GtkWidget *menuitem, *submenu;
- GtkAccelGroup *accel_group;
- GtkWidget *pluginmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools"));
-
- g_return_if_fail(pluginmenu != NULL);
-
- /* Remove old plugin action submenus from the Tools menu */
- for (l = plugin_submenus; l; l = l->next)
- gtk_widget_destroy(GTK_WIDGET(l->data));
- g_list_free(plugin_submenus);
- plugin_submenus = NULL;
-
- accel_group = gtk_menu_get_accel_group(GTK_MENU(pluginmenu));
-
- /* Add a submenu for each plugin with custom actions */
- for (l = purple_plugins_get_loaded(); l; l = l->next) {
- char *path;
-
- plugin = (PurplePlugin *) l->data;
-
- if (PURPLE_IS_PROTOCOL_PLUGIN(plugin))
- continue;
-
- if (!PURPLE_PLUGIN_HAS_ACTIONS(plugin))
- continue;
-
- menuitem = gtk_image_menu_item_new_with_label(_(plugin->info->name));
- gtk_menu_shell_append(GTK_MENU_SHELL(pluginmenu), menuitem);
-
- plugin_submenus = g_list_append(plugin_submenus, menuitem);
-
- submenu = gtk_menu_new();
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
-
- gtk_menu_set_accel_group(GTK_MENU(submenu), accel_group);
- path = g_strdup_printf("%s/Tools/%s", gtkblist->ift->path, plugin->info->name);
- gtk_menu_set_accel_path(GTK_MENU(submenu), path);
- g_free(path);
-
- build_plugin_actions(submenu, plugin, NULL);
- }
- gtk_widget_show_all(pluginmenu);
-#endif
}
-#if GTK_CHECK_VERSION(2,4,0)
static void
sortmethod_act(GtkRadioAction *action, GtkRadioAction *current, char *id)
{
@@ -8805,21 +8402,6 @@ sortmethod_act(GtkRadioAction *action, GtkRadioAction *current, char *id)
pidgin_clear_cursor(gtkblist->window);
}
}
-#else
-static void
-sortmethod_act(GtkCheckMenuItem *checkmenuitem, char *id)
-{
- if (gtk_check_menu_item_get_active(checkmenuitem))
- {
- pidgin_set_cursor(gtkblist->window, GDK_WATCH);
- /* This is redundant. I think. */
- /* pidgin_blist_sort_method_set(id); */
- purple_prefs_set_string(PIDGIN_PREFS_ROOT "/blist/sort_type", id);
-
- pidgin_clear_cursor(gtkblist->window);
- }
-}
-#endif
void
pidgin_blist_update_sort_methods(void)
@@ -8829,7 +8411,6 @@ pidgin_blist_update_sort_methods(void)
GSList *sl = NULL;
const char *m = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/blist/sort_type");
-#if GTK_CHECK_VERSION(2,4,0)
GtkRadioAction *action;
GString *ui_string;
@@ -8878,38 +8459,4 @@ pidgin_blist_update_sort_methods(void)
sort_merge_id = gtk_ui_manager_add_ui_from_string(gtkblist->ui, ui_string->str, -1, NULL);
g_string_free(ui_string, TRUE);
-#else
- GtkWidget *menuitem = NULL, *activeitem = NULL;
- GtkWidget *sortmenu;
-
- if ((gtkblist == NULL) || (gtkblist->ift == NULL))
- return;
-
- g_return_if_fail(m != NULL);
-
- sortmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Sort Buddies"));
-
- if (sortmenu == NULL)
- return;
-
- /* Clear the old menu */
- for (l = gtk_container_get_children(GTK_CONTAINER(sortmenu)); l; l = g_list_delete_link(l, l)) {
- menuitem = l->data;
- gtk_widget_destroy(GTK_WIDGET(menuitem));
- }
-
- for (l = pidgin_blist_sort_methods; l; l = l->next) {
- method = (PidginBlistSortMethod *) l->data;
- menuitem = gtk_radio_menu_item_new_with_label(sl, _(method->name));
- if (g_str_equal(m, method->id))
- activeitem = menuitem;
- sl = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem));
- gtk_menu_shell_append(GTK_MENU_SHELL(sortmenu), menuitem);
- g_signal_connect(G_OBJECT(menuitem), "toggled",
- G_CALLBACK(sortmethod_act), method->id);
- gtk_widget_show(menuitem);
- }
- if (activeitem)
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(activeitem), TRUE);
-#endif
}
diff --git a/pidgin/gtkblist.h b/pidgin/gtkblist.h
index 6858ff0757..2bfbd135ed 100644
--- a/pidgin/gtkblist.h
+++ b/pidgin/gtkblist.h
@@ -82,11 +82,7 @@ struct _PidginBuddyList {
GtkCellRenderer *text_rend;
-#if GTK_CHECK_VERSION(2,4,0)
GtkUIManager *ui;
-#else
- GtkItemFactory *ift;
-#endif
GtkWidget *menutray; /**< The menu tray widget. */
GtkWidget *menutrayicon; /**< The menu tray icon. */
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
index 44edcb85b0..8f4cbd304c 100644
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -160,9 +160,6 @@ static void conv_set_unseen(PurpleConversation *gtkconv, PidginUnseenState state
static void gtkconv_set_unseen(PidginConversation *gtkconv, PidginUnseenState state);
static void update_typing_icon(PidginConversation *gtkconv);
static void update_typing_message(PidginConversation *gtkconv, const char *message);
-#if !GTK_CHECK_VERSION(2,6,0)
-static const char *item_factory_translate_func (const char *path, gpointer func_data);
-#endif
gboolean pidgin_conv_has_focus(PurpleConversation *conv);
static GdkColor* generate_nick_colors(guint *numcolors, GdkColor background);
static gboolean color_is_visible(GdkColor foreground, GdkColor background, int color_contrast, int brightness_contrast);
@@ -982,11 +979,7 @@ invite_cb(GtkWidget *widget, PidginConversation *gtkconv)
}
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_new_conv_cb(GtkAction *action, gpointer data)
-#else
-menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
pidgin_dialogs_im();
}
@@ -1033,11 +1026,7 @@ savelog_writefile_cb(void *user_data, const char *filename)
* plaintext v. HTML file.
*/
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_save_as_cb(GtkAction *action, gpointer data)
-#else
-menu_save_as_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = data;
PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
@@ -1067,11 +1056,7 @@ menu_save_as_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_view_log_cb(GtkAction *action, gpointer data)
-#else
-menu_view_log_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1127,11 +1112,7 @@ menu_view_log_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_clear_cb(GtkAction *action, gpointer data)
-#else
-menu_clear_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1141,11 +1122,7 @@ menu_clear_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_find_cb(GtkAction *action, gpointer data)
-#else
-menu_find_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *gtkwin = data;
PidginConversation *gtkconv = pidgin_conv_window_get_active_gtkconv(gtkwin);
@@ -1155,7 +1132,6 @@ menu_find_cb(gpointer data, guint action, GtkWidget *widget)
#ifdef USE_VV
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_initiate_media_call_cb(GtkAction *action, gpointer data)
{
PidginWindow *win = (PidginWindow *)data;
@@ -1169,29 +1145,10 @@ menu_initiate_media_call_cb(GtkAction *action, gpointer data)
action == win->audio_video_call ? PURPLE_MEDIA_AUDIO |
PURPLE_MEDIA_VIDEO : PURPLE_MEDIA_NONE);
}
-#else
-menu_initiate_media_call_cb(gpointer data, guint action, GtkWidget *widget)
-{
- PidginWindow *win = (PidginWindow *)data;
- PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
- PurpleAccount *account = purple_conversation_get_account(conv);
-
- purple_prpl_initiate_media(account,
- purple_conversation_get_name(conv),
- action == 0 ? PURPLE_MEDIA_AUDIO :
- action == 1 ? PURPLE_MEDIA_VIDEO :
- action == 2 ? PURPLE_MEDIA_AUDIO |
- PURPLE_MEDIA_VIDEO : PURPLE_MEDIA_NONE);
-}
-#endif
#endif
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_send_file_cb(GtkAction *action, gpointer data)
-#else
-menu_send_file_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = data;
PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
@@ -1203,11 +1160,7 @@ menu_send_file_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_get_attention_cb(GtkAction *ation, gpointer data)
-#else
-menu_get_attention_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = data;
PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
@@ -1219,11 +1172,7 @@ menu_get_attention_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_add_pounce_cb(GtkAction *action, gpointer data)
-#else
-menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1235,11 +1184,7 @@ menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_insert_link_cb(GtkAction *action, gpointer data)
-#else
-menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = data;
PidginConversation *gtkconv;
@@ -1253,11 +1198,7 @@ menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_insert_image_cb(GtkAction *action, gpointer data)
-#else
-menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1274,11 +1215,7 @@ menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget)
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_alias_cb(GtkAction *action, gpointer data)
-#else
-menu_alias_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1305,11 +1242,7 @@ menu_alias_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_get_info_cb(GtkAction *action, gpointer data)
-#else
-menu_get_info_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1320,11 +1253,7 @@ menu_get_info_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_invite_cb(GtkAction *action, gpointer data)
-#else
-menu_invite_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1335,11 +1264,7 @@ menu_invite_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_block_cb(GtkAction *action, gpointer data)
-#else
-menu_block_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1350,11 +1275,7 @@ menu_block_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_unblock_cb(GtkAction *action, gpointer data)
-#else
-menu_unblock_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1365,11 +1286,7 @@ menu_unblock_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_add_remove_cb(GtkAction *action, gpointer data)
-#else
-menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1414,11 +1331,7 @@ hide_conv(PidginConversation *gtkconv, gboolean closetimer)
}
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_close_conv_cb(GtkAction *action, gpointer data)
-#else
-menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = data;
@@ -1426,11 +1339,7 @@ menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_logging_cb(GtkAction *action, gpointer data)
-#else
-menu_logging_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1442,11 +1351,7 @@ menu_logging_cb(gpointer data, guint action, GtkWidget *widget)
if (conv == NULL)
return;
-#if GTK_CHECK_VERSION(2,6,0)
logging = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
-#else
- logging = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
-#endif
if (logging == purple_conversation_is_logging(conv))
return;
@@ -1499,26 +1404,14 @@ menu_logging_cb(gpointer data, guint action, GtkWidget *widget)
}
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_toolbar_cb(GtkAction *action, gpointer data)
{
purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar",
gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)));
}
-#else
-menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget)
-{
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar",
- gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)));
-}
-#endif
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_sounds_cb(GtkAction *action, gpointer data)
-#else
-menu_sounds_cb(gpointer data, guint action, GtkWidget *widget)
-#endif
{
PidginWindow *win = data;
PurpleConversation *conv;
@@ -1533,30 +1426,18 @@ menu_sounds_cb(gpointer data, guint action, GtkWidget *widget)
gtkconv = PIDGIN_CONVERSATION(conv);
gtkconv->make_sound =
-#if GTK_CHECK_VERSION(2,6,0)
gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
-#else
- gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
-#endif
node = get_conversation_blist_node(conv);
if (node)
purple_blist_node_set_bool(node, "gtk-mute-sound", !gtkconv->make_sound);
}
static void
-#if GTK_CHECK_VERSION(2,6,0)
menu_timestamps_cb(GtkAction *action, gpointer data)
{
purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps",
gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)));
}
-#else
-menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget)
-{
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps",
- gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)));
-}
-#endif
static void
chat_do_im(PidginConversation *gtkconv, const char *who)
@@ -2363,13 +2244,8 @@ pidgin_conv_switch_active_conversation(PurpleConversation *conv)
purple_conversation_close_logs(old_conv);
gtkconv->active_conv = conv;
-#if GTK_CHECK_VERSION(2,6,0)
purple_conversation_set_logging(conv,
gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(gtkconv->win->menu.logging)));
-#else
- purple_conversation_set_logging(conv,
- gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtkconv->win->menu.logging)));
-#endif
entry = GTK_IMHTML(gtkconv->entry);
protocol_name = purple_account_get_protocol_name(conv->account);
@@ -3192,7 +3068,7 @@ pidgin_conv_get_window(PidginConversation *gtkconv)
return gtkconv->win;
}
-#if GTK_CHECK_VERSION(2,6,0)
+#if 1
static GtkActionEntry menu_entries[] =
/* TODO: fill out tooltips... */
@@ -3363,16 +3239,6 @@ static GtkItemFactoryEntry menu_items[] =
{ N_("/Options/Show Formatting _Toolbars"), NULL, menu_toolbar_cb, 0, "", NULL },
{ N_("/Options/Show Ti_mestamps"), NULL, menu_timestamps_cb, 0, "", NULL },
};
-
-static const int menu_item_count =
-sizeof(menu_items) / sizeof(*menu_items);
-
-static const char *
-item_factory_translate_func (const char *path, gpointer func_data)
-{
- return _(path);
-}
-
#endif
static void
@@ -3384,31 +3250,18 @@ sound_method_pref_changed_cb(const char *name, PurplePrefType type,
if (!strcmp(method, "none"))
{
-#if GTK_CHECK_VERSION(2,6,0)
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.sounds),
FALSE);
gtk_action_set_sensitive(win->menu.sounds, FALSE);
-#else
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds),
- FALSE);
- gtk_widget_set_sensitive(win->menu.sounds, FALSE);
-#endif
}
else
{
PidginConversation *gtkconv = pidgin_conv_window_get_active_gtkconv(win);
-#if GTK_CHECK_VERSION(2,6,0)
if (gtkconv != NULL)
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.sounds),
gtkconv->make_sound);
gtk_action_set_sensitive(win->menu.sounds, TRUE);
-#else
- if (gtkconv != NULL)
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds),
- gtkconv->make_sound);
- gtk_widget_set_sensitive(win->menu.sounds, TRUE);
-#endif
}
}
@@ -3536,7 +3389,6 @@ regenerate_media_items(PidginWindow *win)
purple_prpl_get_media_caps(account,
purple_conversation_get_name(conv));
-#if GTK_CHECK_VERSION(2,6,0)
gtk_action_set_sensitive(win->audio_call,
caps & PURPLE_MEDIA_CAPS_AUDIO
? TRUE : FALSE);
@@ -3546,39 +3398,16 @@ regenerate_media_items(PidginWindow *win)
gtk_action_set_sensitive(win->audio_video_call,
caps & PURPLE_MEDIA_CAPS_AUDIO_VIDEO
? TRUE : FALSE);
-#else
- gtk_widget_set_sensitive(win->audio_call,
- caps & PURPLE_MEDIA_CAPS_AUDIO
- ? TRUE : FALSE);
- gtk_widget_set_sensitive(win->video_call,
- caps & PURPLE_MEDIA_CAPS_VIDEO
- ? TRUE : FALSE);
- gtk_widget_set_sensitive(win->audio_video_call,
- caps & PURPLE_MEDIA_CAPS_AUDIO_VIDEO
- ? TRUE : FALSE);
-#endif
} else if (purple_conversation_get_type(conv)
== PURPLE_CONV_TYPE_CHAT) {
/* for now, don't care about chats... */
-#if GTK_CHECK_VERSION(2,6,0)
gtk_action_set_sensitive(win->audio_call, FALSE);
gtk_action_set_sensitive(win->video_call, FALSE);
gtk_action_set_sensitive(win->audio_video_call, FALSE);
-#else
- gtk_widget_set_sensitive(win->audio_call, FALSE);
- gtk_widget_set_sensitive(win->video_call, FALSE);
- gtk_widget_set_sensitive(win->audio_video_call, FALSE);
-#endif
} else {
-#if GTK_CHECK_VERSION(2,6,0)
gtk_action_set_sensitive(win->audio_call, FALSE);
gtk_action_set_sensitive(win->video_call, FALSE);
gtk_action_set_sensitive(win->audio_video_call, FALSE);
-#else
- gtk_widget_set_sensitive(win->audio_call, FALSE);
- gtk_widget_set_sensitive(win->video_call, FALSE);
- gtk_widget_set_sensitive(win->audio_video_call, FALSE);
-#endif
}
#endif
}
@@ -3671,7 +3500,7 @@ regenerate_plugins_items(PidginWindow *win)
#endif
}
-#if !GTK_CHECK_VERSION(2,6,0)
+#if 0
static void menubar_activated(GtkWidget *item, gpointer data)
{
PidginWindow *win = data;
@@ -3702,8 +3531,6 @@ setup_menubar(PidginWindow *win)
{
GtkAccelGroup *accel_group;
const char *method;
-
-#if GTK_CHECK_VERSION(2,6,0)
GtkActionGroup *action_group;
GError *error;
@@ -3834,133 +3661,6 @@ setup_menubar(PidginWindow *win)
"/Conversation/OptionsMenu/ShowTimestamps");
win->menu.show_icon = NULL;
-#else
- GtkWidget *menuitem;
-
- accel_group = gtk_accel_group_new ();
- gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group);
- g_object_unref(accel_group);
-
- win->menu.item_factory =
- gtk_item_factory_new(GTK_TYPE_MENU_BAR, "", accel_group);
-
- gtk_item_factory_set_translate_func(win->menu.item_factory,
- (GtkTranslateFunc)item_factory_translate_func,
- NULL, NULL);
-
- gtk_item_factory_create_items(win->menu.item_factory, menu_item_count,
- menu_items, win);
- g_signal_connect(G_OBJECT(accel_group), "accel-changed",
- G_CALLBACK(pidgin_save_accels_cb), NULL);
-
- /* Make sure the 'Conversation -> More' menuitems are regenerated whenever
- * the 'Conversation' menu pops up because the entries can change after the
- * conversation is created. */
- menuitem = gtk_item_factory_get_item(win->menu.item_factory, N_("/Conversation"));
- g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(menubar_activated), win);
-
- win->menu.menubar =
- gtk_item_factory_get_widget(win->menu.item_factory, "");
-
- win->menu.view_log =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Conversation/View Log"));
-
-#ifdef USE_VV
- win->audio_call =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Conversation/Media/Audio Call"));
- win->video_call =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Conversation/Media/Video Call"));
- win->audio_video_call =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Conversation/Media/Audio\\/Video Call"));
-#endif
-
- /* --- */
-
- win->menu.send_file =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Conversation/Send File..."));
-
- g_object_set_data(G_OBJECT(win->window), "get_attention",
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Conversation/Get Attention")));
- win->menu.add_pounce =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Conversation/Add Buddy Pounce..."));
-
- /* --- */
-
- win->menu.get_info =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Conversation/Get Info"));
-
- win->menu.invite =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Conversation/Invite..."));
-
- /* --- */
-
- win->menu.alias =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Conversation/Alias..."));
-
- win->menu.block =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Conversation/Block..."));
-
- win->menu.unblock =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Conversation/Unblock..."));
-
- win->menu.add =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Conversation/Add..."));
-
- win->menu.remove =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Conversation/Remove..."));
-
- /* --- */
-
- win->menu.insert_link =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Conversation/Insert Link..."));
-
- win->menu.insert_image =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Conversation/Insert Image..."));
-
- /* --- */
-
- win->menu.logging =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Options/Enable Logging"));
- win->menu.sounds =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Options/Enable Sounds"));
- method = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method");
- if (method != NULL && !strcmp(method, "none"))
- {
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds),
- FALSE);
- gtk_widget_set_sensitive(win->menu.sounds, FALSE);
- }
- purple_prefs_connect_callback(win, PIDGIN_PREFS_ROOT "/sound/method",
- sound_method_pref_changed_cb, win);
-
- win->menu.show_formatting_toolbar =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Options/Show Formatting Toolbars"));
- win->menu.show_timestamps =
- gtk_item_factory_get_widget(win->menu.item_factory,
- N_("/Options/Show Timestamps"));
- win->menu.show_icon = NULL;
-
-#endif
-
win->menu.tray = pidgin_menu_tray_new();
gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar),
win->menu.tray);
@@ -4142,8 +3842,7 @@ update_send_to_selection(PidginWindow *win)
if (!(b = purple_find_buddy(account, conv->name)))
return FALSE;
-#if GTK_CHECK_VERSION(2,6,0)
-#else
+#if 0 /* TODO */
gtk_widget_show(win->menu.send_to);
menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(win->menu.send_to));
@@ -4275,8 +3974,7 @@ compare_buddy_presence(PurplePresence *p1, PurplePresence *p2)
static void
generate_send_to_items(PidginWindow *win)
{
-#if GTK_CHECK_VERSION(2,6,0)
-#else
+#if 0 /* TODO */
GtkWidget *menu;
GSList *group = NULL;
GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
@@ -6870,16 +6568,6 @@ pidgin_conv_send_confirm(PurpleConversation *conv, const char *message)
gtk_imhtml_append_text(GTK_IMHTML(gtkconv->entry), message, 0);
}
-/* Mask functions with ones from newer GTK+ */
-#if GTK_CHECK_VERSION(2,6,0)
-#define gtk_widget_set_sensitive_ gtk_widget_set_sensitive
-#define gtk_widget_show_ gtk_widget_show
-#define gtk_widget_hide_ gtk_widget_hide
-#define gtk_widget_set_sensitive gtk_action_set_sensitive
-#define gtk_widget_show(x) gtk_action_set_visible((x), TRUE)
-#define gtk_widget_hide(x) gtk_action_set_visible((x), FALSE)
-#endif
-
/*
* Makes sure all the menu items and all the buttons are hidden/shown and
* sensitive/insensitive. This is called after changing tabs and when an
@@ -6918,57 +6606,57 @@ gray_stuff_out(PidginConversation *gtkconv)
/* Show stuff that applies to IMs, hide stuff that applies to chats */
/* Deal with menu items */
- gtk_widget_show(win->menu.view_log);
- gtk_widget_show(win->menu.send_file);
- gtk_widget_show(g_object_get_data(G_OBJECT(win->window), "get_attention"));
- gtk_widget_show(win->menu.add_pounce);
- gtk_widget_show(win->menu.get_info);
- gtk_widget_hide(win->menu.invite);
- gtk_widget_show(win->menu.alias);
+ gtk_action_set_visible(win->menu.view_log, TRUE);
+ gtk_action_set_visible(win->menu.send_file, TRUE);
+ gtk_action_set_visible(g_object_get_data(G_OBJECT(win->window), "get_attention"), TRUE);
+ gtk_action_set_visible(win->menu.add_pounce, TRUE);
+ gtk_action_set_visible(win->menu.get_info, TRUE);
+ gtk_action_set_visible(win->menu.invite, FALSE);
+ gtk_action_set_visible(win->menu.alias, TRUE);
if (purple_privacy_check(account, purple_conversation_get_name(conv))) {
- gtk_widget_hide(win->menu.unblock);
- gtk_widget_show(win->menu.block);
+ gtk_action_set_visible(win->menu.unblock, FALSE);
+ gtk_action_set_visible(win->menu.block, TRUE);
} else {
- gtk_widget_hide(win->menu.block);
- gtk_widget_show(win->menu.unblock);
+ gtk_action_set_visible(win->menu.block, FALSE);
+ gtk_action_set_visible(win->menu.unblock, TRUE);
}
if ((account == NULL) || purple_find_buddy(account, purple_conversation_get_name(conv)) == NULL) {
- gtk_widget_show(win->menu.add);
- gtk_widget_hide(win->menu.remove);
+ gtk_action_set_visible(win->menu.add, TRUE);
+ gtk_action_set_visible(win->menu.remove, FALSE);
} else {
- gtk_widget_show(win->menu.remove);
- gtk_widget_hide(win->menu.add);
+ gtk_action_set_visible(win->menu.remove, TRUE);
+ gtk_action_set_visible(win->menu.add, FALSE);
}
- gtk_widget_show(win->menu.insert_link);
- gtk_widget_show(win->menu.insert_image);
+ gtk_action_set_visible(win->menu.insert_link, TRUE);
+ gtk_action_set_visible(win->menu.insert_image, TRUE);
} else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
/* Show stuff that applies to Chats, hide stuff that applies to IMs */
/* Deal with menu items */
- gtk_widget_show(win->menu.view_log);
- gtk_widget_hide(win->menu.send_file);
- gtk_widget_hide(g_object_get_data(G_OBJECT(win->window), "get_attention"));
- gtk_widget_hide(win->menu.add_pounce);
- gtk_widget_hide(win->menu.get_info);
- gtk_widget_show(win->menu.invite);
- gtk_widget_show(win->menu.alias);
- gtk_widget_hide(win->menu.block);
- gtk_widget_hide(win->menu.unblock);
+ gtk_action_set_visible(win->menu.view_log, TRUE);
+ gtk_action_set_visible(win->menu.send_file, FALSE);
+ gtk_action_set_visible(g_object_get_data(G_OBJECT(win->window), "get_attention"), FALSE);
+ gtk_action_set_visible(win->menu.add_pounce, FALSE);
+ gtk_action_set_visible(win->menu.get_info, FALSE);
+ gtk_action_set_visible(win->menu.invite, TRUE);
+ gtk_action_set_visible(win->menu.alias, TRUE);
+ gtk_action_set_visible(win->menu.block, FALSE);
+ gtk_action_set_visible(win->menu.unblock, FALSE);
if ((account == NULL) || purple_blist_find_chat(account, purple_conversation_get_name(conv)) == NULL) {
/* If the chat is NOT in the buddy list */
- gtk_widget_show(win->menu.add);
- gtk_widget_hide(win->menu.remove);
+ gtk_action_set_visible(win->menu.add, TRUE);
+ gtk_action_set_visible(win->menu.remove, FALSE);
} else {
/* If the chat IS in the buddy list */
- gtk_widget_hide(win->menu.add);
- gtk_widget_show(win->menu.remove);
+ gtk_action_set_visible(win->menu.add, FALSE);
+ gtk_action_set_visible(win->menu.remove, TRUE);
}
- gtk_widget_show(win->menu.insert_link);
- gtk_widget_show(win->menu.insert_image);
+ gtk_action_set_visible(win->menu.insert_link, TRUE);
+ gtk_action_set_visible(win->menu.insert_image, TRUE);
}
/*
@@ -7013,30 +6701,30 @@ gray_stuff_out(PidginConversation *gtkconv)
gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), purple_account_get_protocol_id(account));
/* Deal with menu items */
- gtk_widget_set_sensitive(win->menu.view_log, TRUE);
- gtk_widget_set_sensitive(win->menu.add_pounce, TRUE);
- gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL));
- gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL));
- gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & PURPLE_CONNECTION_HTML));
- gtk_widget_set_sensitive(win->menu.insert_image, !(conv->features & PURPLE_CONNECTION_NO_IMAGES));
+ gtk_action_set_sensitive(win->menu.view_log, TRUE);
+ gtk_action_set_sensitive(win->menu.add_pounce, TRUE);
+ gtk_action_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL));
+ gtk_action_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL));
+ gtk_action_set_sensitive(win->menu.insert_link, (conv->features & PURPLE_CONNECTION_HTML));
+ gtk_action_set_sensitive(win->menu.insert_image, !(conv->features & PURPLE_CONNECTION_NO_IMAGES));
if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
{
- gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL));
- gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL));
- gtk_widget_set_sensitive(win->menu.send_file,
+ gtk_action_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL));
+ gtk_action_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL));
+ gtk_action_set_sensitive(win->menu.send_file,
(prpl_info->send_file != NULL && (!prpl_info->can_receive_file ||
prpl_info->can_receive_file(gc, purple_conversation_get_name(conv)))));
- gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(win->window), "get_attention"), (prpl_info->send_attention != NULL));
- gtk_widget_set_sensitive(win->menu.alias,
+ gtk_action_set_sensitive(g_object_get_data(G_OBJECT(win->window), "get_attention"), (prpl_info->send_attention != NULL));
+ gtk_action_set_sensitive(win->menu.alias,
(account != NULL) &&
(purple_find_buddy(account, purple_conversation_get_name(conv)) != NULL));
}
else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
{
- gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL));
- gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL));
- gtk_widget_set_sensitive(win->menu.alias,
+ gtk_action_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL));
+ gtk_action_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL));
+ gtk_action_set_sensitive(win->menu.alias,
(account != NULL) &&
(purple_blist_find_chat(account, purple_conversation_get_name(conv)) != NULL));
}
@@ -7046,18 +6734,18 @@ gray_stuff_out(PidginConversation *gtkconv)
/* Or it's a chat that we've left. */
/* Then deal with menu items */
- gtk_widget_set_sensitive(win->menu.view_log, TRUE);
- gtk_widget_set_sensitive(win->menu.send_file, FALSE);
- gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(win->window),
+ gtk_action_set_sensitive(win->menu.view_log, TRUE);
+ gtk_action_set_sensitive(win->menu.send_file, FALSE);
+ gtk_action_set_sensitive(g_object_get_data(G_OBJECT(win->window),
"get_attention"), FALSE);
- gtk_widget_set_sensitive(win->menu.add_pounce, TRUE);
- gtk_widget_set_sensitive(win->menu.get_info, FALSE);
- gtk_widget_set_sensitive(win->menu.invite, FALSE);
- gtk_widget_set_sensitive(win->menu.alias, FALSE);
- gtk_widget_set_sensitive(win->menu.add, FALSE);
- gtk_widget_set_sensitive(win->menu.remove, FALSE);
- gtk_widget_set_sensitive(win->menu.insert_link, TRUE);
- gtk_widget_set_sensitive(win->menu.insert_image, FALSE);
+ gtk_action_set_sensitive(win->menu.add_pounce, TRUE);
+ gtk_action_set_sensitive(win->menu.get_info, FALSE);
+ gtk_action_set_sensitive(win->menu.invite, FALSE);
+ gtk_action_set_sensitive(win->menu.alias, FALSE);
+ gtk_action_set_sensitive(win->menu.add, FALSE);
+ gtk_action_set_sensitive(win->menu.remove, FALSE);
+ gtk_action_set_sensitive(win->menu.insert_link, TRUE);
+ gtk_action_set_sensitive(win->menu.insert_image, FALSE);
}
/*
@@ -7089,17 +6777,6 @@ gray_stuff_out(PidginConversation *gtkconv)
}
}
-/* Restore the functions */
-#if GTK_CHECK_VERSION(2,6,0)
-#undef gtk_widget_set_sensitive
-#undef gtk_widget_show
-#undef gtk_widget_hide
-
-#define gtk_widget_set_sensitive gtk_widget_set_sensitive_
-#define gtk_widget_show gtk_widget_show_
-#define gtk_widget_hide gtk_widget_hide_
-#endif
-
static void
pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields)
{
@@ -7756,15 +7433,9 @@ show_timestamps_pref_cb(const char *name, PurplePrefType type,
gtkconv = PIDGIN_CONVERSATION(conv);
win = gtkconv->win;
-#if GTK_CHECK_VERSION(2,6,0)
gtk_toggle_action_set_active(
GTK_TOGGLE_ACTION(win->menu.show_timestamps),
(gboolean)GPOINTER_TO_INT(value));
-#else
- gtk_check_menu_item_set_active(
- GTK_CHECK_MENU_ITEM(win->menu.show_timestamps),
- (gboolean)GPOINTER_TO_INT(value));
-#endif
gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),
(gboolean)GPOINTER_TO_INT(value));
@@ -7790,15 +7461,9 @@ show_formatting_toolbar_pref_cb(const char *name, PurplePrefType type,
gtkconv = PIDGIN_CONVERSATION(conv);
win = gtkconv->win;
-#if GTK_CHECK_VERSION(2,6,0)
gtk_toggle_action_set_active(
GTK_TOGGLE_ACTION(win->menu.show_formatting_toolbar),
(gboolean)GPOINTER_TO_INT(value));
-#else
- gtk_check_menu_item_set_active(
- GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar),
- (gboolean)GPOINTER_TO_INT(value));
-#endif
if ((gboolean)GPOINTER_TO_INT(value))
gtk_widget_show(gtkconv->toolbar);
@@ -9054,8 +8719,7 @@ infopane_press_cb(GtkWidget *widget, GdkEventButton *e, PidginConversation *gtkc
/* Right click was pressed. Popup the context menu. */
GtkWidget *menu = gtk_menu_new(), *sub;
gboolean populated = populate_menu_with_options(menu, gtkconv, TRUE);
-#if GTK_CHECK_VERSION(2,6,0)
-#else
+#if 0 /* TODO */
sub = gtk_menu_item_get_submenu(GTK_MENU_ITEM(gtkconv->win->menu.send_to));
if (sub && GTK_WIDGET_IS_SENSITIVE(gtkconv->win->menu.send_to)) {
@@ -9578,13 +9242,8 @@ switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num,
/* Update the menubar */
-#if GTK_CHECK_VERSION(2,6,0)
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(gtkconv->win->menu.logging),
purple_conversation_is_logging(conv));
-#else
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkconv->win->menu.logging),
- purple_conversation_is_logging(conv));
-#endif
generate_send_to_items(win);
regenerate_options_items(win);
@@ -9593,7 +9252,6 @@ switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num,
pidgin_conv_switch_active_conversation(conv);
sound_method = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method");
-#if GTK_CHECK_VERSION(2,6,0)
if (strcmp(sound_method, "none") != 0)
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.sounds),
gtkconv->make_sound);
@@ -9603,17 +9261,6 @@ switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num,
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.show_timestamps),
purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps"));
-#else
- if (strcmp(sound_method, "none") != 0)
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds),
- gtkconv->make_sound);
-
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar"));
-
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps"));
-#endif
/*
* We pause icons when they are not visible. If this icon should
@@ -9863,11 +9510,7 @@ pidgin_conv_window_destroy(PidginWindow *win)
}
gtk_widget_destroy(win->window);
-#if GTK_CHECK_VERSION(2,6,0)
g_object_unref(G_OBJECT(win->menu.ui));
-#else
- g_object_unref(G_OBJECT(win->menu.item_factory));
-#endif
purple_notify_close_with_handle(win);
purple_signals_disconnect_by_handle(win);
diff --git a/pidgin/gtkconvwin.h b/pidgin/gtkconvwin.h
index 5dc0718949..ee42f17e61 100644
--- a/pidgin/gtkconvwin.h
+++ b/pidgin/gtkconvwin.h
@@ -46,10 +46,8 @@ struct _PidginWindow
struct
{
-/* Some necessary functions were only added in 2.6.0 */
GtkWidget *menubar;
-#if GTK_CHECK_VERSION(2,6,0)
GtkAction *view_log;
GtkAction *send_file;
@@ -70,28 +68,7 @@ struct _PidginWindow
GtkAction *sounds;
GtkAction *show_formatting_toolbar;
GtkAction *show_timestamps;
-#else
- GtkWidget *view_log;
-
- GtkWidget *send_file;
- GtkWidget *add_pounce;
- GtkWidget *get_info;
- GtkWidget *invite;
-
- GtkWidget *alias;
- GtkWidget *block;
- GtkWidget *unblock;
- GtkWidget *add;
- GtkWidget *remove;
-
- GtkWidget *insert_link;
- GtkWidget *insert_image;
-
- GtkWidget *logging;
- GtkWidget *sounds;
- GtkWidget *show_formatting_toolbar;
- GtkWidget *show_timestamps;
-#endif
+
GtkWidget *show_icon;
GtkWidget *send_to;
@@ -100,11 +77,7 @@ struct _PidginWindow
GtkWidget *typing_icon;
-#if GTK_CHECK_VERSION(2,6,0)
GtkUIManager *ui;
-#else
- GtkItemFactory *item_factory;
-#endif
} menu;
@@ -126,15 +99,9 @@ struct _PidginWindow
gint drag_leave_signal;
/* Media menu options. */
-#if GTK_CHECK_VERSION(2,6,0)
GtkAction *audio_call;
GtkAction *video_call;
GtkAction *audio_video_call;
-#else
- GtkWidget *audio_call;
- GtkWidget *video_call;
- GtkWidget *audio_video_call;
-#endif
};
/*@}*/
diff --git a/pidgin/gtkdocklet.c b/pidgin/gtkdocklet.c
index 571222e017..3ab5801a75 100644
--- a/pidgin/gtkdocklet.c
+++ b/pidgin/gtkdocklet.c
@@ -523,7 +523,7 @@ add_account_statuses(GtkWidget *menu, PurpleAccount *account)
new_menu_item_with_status_icon(menu,
purple_status_type_get_name(status_type),
prim, G_CALLBACK(activate_status_account_cb),
- status_type, 0, 0, NULL);
+ GINT_TO_POINTER(status_type), 0, 0, NULL);
}
}
diff --git a/pidgin/gtkmedia.c b/pidgin/gtkmedia.c
index 982fcb2d6a..23287a0cec 100644
--- a/pidgin/gtkmedia.c
+++ b/pidgin/gtkmedia.c
@@ -84,11 +84,7 @@ struct _PidginMediaPrivate
gchar *screenname;
gulong level_handler_id;
-#if GTK_CHECK_VERSION(2,4,0)
GtkUIManager *ui;
-#else
- GtkItemFactory *item_factory;
-#endif
GtkWidget *menubar;
GtkWidget *statusbar;
@@ -264,18 +260,13 @@ pidgin_x_error_handler(Display *display, XErrorEvent *event)
#endif
static void
-#if GTK_CHECK_VERSION(2,4,0)
menu_hangup(GtkAction *action, gpointer data)
-#else
-menu_hangup(gpointer data, guint action, GtkWidget *item)
-#endif
{
PidginMedia *gtkmedia = PIDGIN_MEDIA(data);
purple_media_stream_info(gtkmedia->priv->media,
PURPLE_MEDIA_INFO_HANGUP, NULL, NULL, TRUE);
}
-#if GTK_CHECK_VERSION(2,4,0)
static const GtkActionEntry menu_entries[] = {
{ "MediaMenu", NULL, N_("_Media"), NULL, NULL, NULL },
{ "Hangup", NULL, N_("_Hangup"), NULL, NULL, G_CALLBACK(menu_hangup) },
@@ -290,32 +281,14 @@ static const char *media_menu =
""
"";
-#else
-static GtkItemFactoryEntry menu_items[] = {
- { N_("/_Media"), NULL, NULL, 0, "", NULL },
- { N_("/Media/_Hangup"), NULL, menu_hangup, 0, "
- ", NULL },
-};
-
-static gint menu_item_count = sizeof(menu_items) / sizeof(menu_items[0]);
-
-static const char *
-item_factory_translate_func (const char *path, gpointer func_data)
-{
- return _(path);
-}
-#endif
-
static GtkWidget *
setup_menubar(PidginMedia *window)
{
-#if GTK_CHECK_VERSION(2,4,0)
GtkActionGroup *action_group;
GError *error;
-#endif
GtkAccelGroup *accel_group;
GtkWidget *menu;
-#if GTK_CHECK_VERSION(2,4,0)
action_group = gtk_action_group_new("MediaActions");
gtk_action_group_add_actions(action_group,
menu_entries,
@@ -341,26 +314,6 @@ setup_menubar(PidginMedia *window)
}
menu = gtk_ui_manager_get_widget(window->priv->ui, "/Media");
-#else
- accel_group = gtk_accel_group_new ();
- gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
- g_object_unref(accel_group);
-
- window->priv->item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR,
- "", accel_group);
-
- gtk_item_factory_set_translate_func(window->priv->item_factory,
- (GtkTranslateFunc)item_factory_translate_func,
- NULL, NULL);
-
- gtk_item_factory_create_items(window->priv->item_factory,
- menu_item_count, menu_items, window);
- g_signal_connect(G_OBJECT(accel_group), "accel-changed",
- G_CALLBACK(pidgin_save_accels_cb), NULL);
-
- menu = gtk_item_factory_get_widget(
- window->priv->item_factory, "");
-#endif
gtk_widget_show(menu);
return menu;
@@ -441,17 +394,10 @@ pidgin_media_dispose(GObject *media)
gtkmedia->priv->media = NULL;
}
-#if GTK_CHECK_VERSION(2,4,0)
if (gtkmedia->priv->ui) {
g_object_unref(gtkmedia->priv->ui);
gtkmedia->priv->ui = NULL;
}
-#else
- if (gtkmedia->priv->item_factory) {
- g_object_unref(gtkmedia->priv->item_factory);
- gtkmedia->priv->item_factory = NULL;
- }
-#endif
G_OBJECT_CLASS(parent_class)->dispose(media);
}
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
index 6ea81f183d..7ebfd05471 100644
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -912,31 +912,6 @@ pidgin_account_option_menu_new(PurpleAccount *default_account,
return optmenu;
}
-gboolean
-#if GTK_CHECK_VERSION(2,4,0)
-pidgin_check_if_dir(const char *path, gpointer filesel)
-{
- return FALSE;
-}
-#else
-pidgin_check_if_dir(const char *path, GtkFileSelection *filesel)
-{
- char *dirname = NULL;
-
- if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
- /* append a / if needed */
- if (path[strlen(path) - 1] != G_DIR_SEPARATOR) {
- dirname = g_strconcat(path, G_DIR_SEPARATOR_S, NULL);
- }
- gtk_file_selection_set_filename(filesel, (dirname != NULL) ? dirname : path);
- g_free(dirname);
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
void
pidgin_setup_gtkspell(GtkTextView *textview)
{
diff --git a/pidgin/gtkutils.h b/pidgin/gtkutils.h
index 3783d9714e..750860841f 100644
--- a/pidgin/gtkutils.h
+++ b/pidgin/gtkutils.h
@@ -401,22 +401,6 @@ gboolean pidgin_screenname_autocomplete_default_filter(const PidginBuddyCompleti
*/
void pidgin_setup_screenname_autocomplete(GtkWidget *entry, GtkWidget *optmenu, gboolean all);
-/**
- * Check if the given path is a directory or not. If it is, then modify
- * the given GtkFileSelection dialog so that it displays the given path.
- * If the given path is not a directory, then do nothing.
- *
- * @param path The path entered in the file selection window by the user.
- * @param filesel The file selection window.
- *
- * @return TRUE if given path is a directory, FALSE otherwise.
- */
-#if GTK_CHECK_VERSION(2,4,0)
-gboolean pidgin_check_if_dir(const char *path, gpointer filesel);
-#else
-gboolean pidgin_check_if_dir(const char *path, GtkFileSelection *filesel);
-#endif
-
/**
* Sets up GtkSpell for the given GtkTextView, reporting errors
* if encountered.
--
cgit v1.2.1
From 9dd114428f2d4a8548aa9670815a74d694e52197 Mon Sep 17 00:00:00 2001
From: Gabriel Schulhof
Date: Mon, 26 Jul 2010 05:35:10 +0000
Subject: Apply final changes from nix_nix's patch.
Closes #1332.
committer: Elliott Sales de Andrade
---
pidgin/gtkaccount.c | 42 ++++++++--
pidgin/gtkutils.c | 171 ++++++++++++++------------------------
pidgin/plugins/contact_priority.c | 7 +-
3 files changed, 97 insertions(+), 123 deletions(-)
diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c
index 03f05a49a8..c1a8fc5ab3 100644
--- a/pidgin/gtkaccount.c
+++ b/pidgin/gtkaccount.c
@@ -160,6 +160,37 @@ static void add_user_options(AccountPrefsDialog *dialog, GtkWidget *parent);
static void add_protocol_options(AccountPrefsDialog *dialog);
static void add_proxy_options(AccountPrefsDialog *dialog, GtkWidget *parent);
+static const char *
+google_talk_default_domain_hackery(GtkWidget *protocol_combo, const char *value_if_gtalk)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ const char *value = NULL;
+
+ model = gtk_combo_box_get_model(GTK_COMBO_BOX(protocol_combo));
+ if (model != NULL && gtk_combo_box_get_active_iter(GTK_COMBO_BOX(protocol_combo), &iter)) {
+ char *protocol = NULL;
+
+ /* protocol is not stored as G_TYPE_STRING in the model so no g_free necessary */
+ gtk_tree_model_get(model, &iter, 2, &protocol, -1);
+ if (protocol && !strcmp("prpl-jabber", protocol)) {
+ char *item_name = NULL;
+
+ gtk_tree_model_get(model, &iter, 1, &item_name, -1);
+ if (item_name) {
+ if (!strcmp(item_name, _("Google Talk")))
+ value = value_if_gtalk;
+ g_free(item_name);
+ }
+ /* If it's not GTalk, but still Jabber then the value is not NULL, it's empty */
+ if (NULL == value)
+ value = "";
+ }
+ }
+
+ return value;
+}
+
static GtkWidget *
add_pref_box(AccountPrefsDialog *dialog, GtkWidget *parent,
const char *text, GtkWidget *widget)
@@ -417,8 +448,6 @@ add_login_options(AccountPrefsDialog *dialog, GtkWidget *parent)
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *entry;
- GtkWidget *menu;
- GtkWidget *item;
GList *user_splits;
GList *l, *l2;
char *username = NULL;
@@ -557,11 +586,8 @@ add_login_options(AccountPrefsDialog *dialog, GtkWidget *parent)
value = purple_account_user_split_get_default_value(split);
/* Google Talk default domain hackery! */
- menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(dialog->protocol_menu));
- item = gtk_menu_get_active(GTK_MENU(menu));
- if (value == NULL && g_object_get_data(G_OBJECT(item), "fake") &&
- !strcmp(purple_account_user_split_get_text(split), _("Domain")))
- value = "gmail.com";
+ if (!strcmp(_("Domain"), purple_account_user_split_get_text(split)) && !value)
+ value = google_talk_default_domain_hackery(dialog->protocol_menu, "gmail.com");
if (value != NULL)
gtk_entry_set_text(GTK_ENTRY(entry), value);
@@ -2607,5 +2633,3 @@ pidgin_account_uninit(void)
purple_signals_disconnect_by_handle(pidgin_account_get_handle());
purple_signals_unregister_by_instance(pidgin_account_get_handle());
}
-
-
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
index 7ebfd05471..535bda7ff5 100644
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -70,7 +70,7 @@
#include "pidgin/minidialog.h"
typedef struct {
- GtkWidget *menu;
+ GtkTreeModel *model;
gint default_item;
} AopMenu;
@@ -527,68 +527,35 @@ pidgin_make_frame(GtkWidget *parent, const char *title)
}
static gpointer
-aop_option_menu_get_selected(GtkWidget *optmenu, GtkWidget **p_item)
+aop_option_menu_get_selected(GtkWidget *optmenu)
{
- GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
- GtkWidget *item = gtk_menu_get_active(GTK_MENU(menu));
- if (p_item)
- (*p_item) = item;
- return item ? g_object_get_data(G_OBJECT(item), "aop_per_item_data") : NULL;
+ gpointer data = NULL;
+ GtkTreeIter iter;
+
+ g_return_val_if_fail(optmenu != NULL, NULL);
+
+ if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(optmenu), &iter))
+ gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu)), &iter, 2, &data, -1);
+
+ return data;
}
static void
aop_menu_cb(GtkWidget *optmenu, GCallback cb)
{
- GtkWidget *item;
- gpointer per_item_data;
-
- per_item_data = aop_option_menu_get_selected(optmenu, &item);
-
if (cb != NULL) {
- ((void (*)(GtkWidget *, gpointer, gpointer))cb)(item, per_item_data, g_object_get_data(G_OBJECT(optmenu), "user_data"));
+ ((void (*)(GtkWidget *, gpointer, gpointer))cb)(NULL,
+ aop_option_menu_get_selected(optmenu),
+ g_object_get_data(G_OBJECT(optmenu), "user_data"));
}
}
-static GtkWidget *
-aop_menu_item_new(GtkSizeGroup *sg, GdkPixbuf *pixbuf, const char *lbl, gpointer per_item_data, const char *data)
+static void
+aop_option_menu_replace_menu(GtkWidget *optmenu, AopMenu *new_aop_menu)
{
- GtkWidget *item;
- GtkWidget *hbox;
- GtkWidget *image;
- GtkWidget *label;
-
- item = gtk_menu_item_new();
- gtk_widget_show(item);
-
- hbox = gtk_hbox_new(FALSE, 4);
- gtk_widget_show(hbox);
-
- /* Create the image */
- if (pixbuf == NULL)
- image = gtk_image_new();
- else
- image = gtk_image_new_from_pixbuf(pixbuf);
- gtk_widget_show(image);
-
- if (sg)
- gtk_size_group_add_widget(sg, image);
-
- /* Create the label */
- label = gtk_label_new (lbl);
- gtk_widget_show (label);
- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
- gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
-
- gtk_container_add(GTK_CONTAINER(item), hbox);
- gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
-
- g_object_set_data(G_OBJECT (item), data, per_item_data);
- g_object_set_data(G_OBJECT (item), "aop_per_item_data", per_item_data);
-
- pidgin_set_accessible_label(item, label);
-
- return item;
+ gtk_combo_box_set_model(GTK_COMBO_BOX(optmenu), new_aop_menu->model);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(optmenu), new_aop_menu->default_item);
+ g_object_set_data_full(G_OBJECT(optmenu), "aop_menu", new_aop_menu, (GDestroyNotify)g_free);
}
static GdkPixbuf *
@@ -629,16 +596,19 @@ pidgin_create_prpl_icon_from_prpl(PurplePlugin *prpl, PidginPrplIconSize size, P
static GtkWidget *
aop_option_menu_new(AopMenu *aop_menu, GCallback cb, gpointer user_data)
{
- GtkWidget *optmenu;
+ GtkWidget *optmenu = NULL;
+ GtkCellRenderer *cr = NULL;
- optmenu = gtk_option_menu_new();
+ optmenu = gtk_combo_box_new();
gtk_widget_show(optmenu);
- gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), aop_menu->menu);
-
- if (aop_menu->default_item != -1)
- gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), aop_menu->default_item);
-
- g_object_set_data_full(G_OBJECT(optmenu), "aop_menu", aop_menu, (GDestroyNotify)g_free);
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(optmenu), cr = gtk_cell_renderer_pixbuf_new(), FALSE);
+ gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(optmenu), cr, "pixbuf", 0);
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(optmenu), cr = gtk_cell_renderer_text_new(), TRUE);
+ gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(optmenu), cr, "text", 1);
+
+ aop_option_menu_replace_menu(optmenu, aop_menu);
+ if (aop_menu->default_item == -1)
+ gtk_combo_box_set_active(GTK_COMBO_BOX(optmenu), 0);
g_object_set_data(G_OBJECT(optmenu), "user_data", user_data);
g_signal_connect(G_OBJECT(optmenu), "changed", G_CALLBACK(aop_menu_cb), cb);
@@ -646,33 +616,21 @@ aop_option_menu_new(AopMenu *aop_menu, GCallback cb, gpointer user_data)
return optmenu;
}
-static void
-aop_option_menu_replace_menu(GtkWidget *optmenu, AopMenu *new_aop_menu)
-{
- if (gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)))
- gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu));
-
- gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), new_aop_menu->menu);
-
- if (new_aop_menu->default_item != -1)
- gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), new_aop_menu->default_item);
-
- g_object_set_data_full(G_OBJECT(optmenu), "aop_menu", new_aop_menu, (GDestroyNotify)g_free);
-}
-
static void
aop_option_menu_select_by_data(GtkWidget *optmenu, gpointer data)
{
- guint idx;
- GList *llItr = NULL;
-
- for (idx = 0, llItr = GTK_MENU_SHELL(gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)))->children;
- llItr != NULL;
- llItr = llItr->next, idx++) {
- if (data == g_object_get_data(G_OBJECT(llItr->data), "aop_per_item_data")) {
- gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), idx);
- break;
- }
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gpointer iter_data;
+ model = gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu));
+ if (gtk_tree_model_get_iter_first(model, &iter)) {
+ do {
+ gtk_tree_model_get(model, &iter, 2, &iter_data, -1);
+ if (iter_data == data) {
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(optmenu), &iter);
+ return;
+ }
+ } while (gtk_tree_model_iter_next(model, &iter));
}
}
@@ -683,16 +641,17 @@ create_protocols_menu(const char *default_proto_id)
PurplePluginProtocolInfo *prpl_info;
PurplePlugin *plugin;
GdkPixbuf *pixbuf = NULL;
- GtkSizeGroup *sg;
+ GtkTreeIter iter;
+ GtkListStore *ls;
GList *p;
const char *gtalk_name = NULL;
int i;
+ ls = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER);
+
aop_menu = g_malloc0(sizeof(AopMenu));
aop_menu->default_item = -1;
- aop_menu->menu = gtk_menu_new();
- gtk_widget_show(aop_menu->menu);
- sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+ aop_menu->model = GTK_TREE_MODEL(ls);
if (purple_find_prpl("prpl-jabber"))
gtalk_name = _("Google Talk");
@@ -707,14 +666,11 @@ create_protocols_menu(const char *default_proto_id)
if (gtalk_name && strcmp(gtalk_name, plugin->info->name) < 0) {
char *filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols",
"16", "google-talk.png", NULL);
- GtkWidget *item;
-
pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
g_free(filename);
- gtk_menu_shell_append(GTK_MENU_SHELL(aop_menu->menu),
- item = aop_menu_item_new(sg, pixbuf, gtalk_name, "prpl-jabber", "protocol"));
- g_object_set_data(G_OBJECT(item), "fake", GINT_TO_POINTER(1));
+ gtk_list_store_append(ls, &iter);
+ gtk_list_store_set(ls, &iter, 0, pixbuf, 1, gtalk_name, 2, "prpl-jabber", -1);
if (pixbuf)
g_object_unref(pixbuf);
@@ -725,8 +681,8 @@ create_protocols_menu(const char *default_proto_id)
pixbuf = pidgin_create_prpl_icon_from_prpl(plugin, PIDGIN_PRPL_ICON_SMALL, NULL);
- gtk_menu_shell_append(GTK_MENU_SHELL(aop_menu->menu),
- aop_menu_item_new(sg, pixbuf, plugin->info->name, plugin->info->id, "protocol"));
+ gtk_list_store_append(ls, &iter);
+ gtk_list_store_set(ls, &iter, 0, pixbuf, 1, plugin->info->name, 2, plugin->info->id, -1);
if (pixbuf)
g_object_unref(pixbuf);
@@ -734,9 +690,6 @@ create_protocols_menu(const char *default_proto_id)
if (default_proto_id != NULL && !strcmp(plugin->info->id, default_proto_id))
aop_menu->default_item = i;
}
-
- g_object_unref(sg);
-
return aop_menu;
}
@@ -750,13 +703,13 @@ pidgin_protocol_option_menu_new(const char *id, GCallback cb,
const char *
pidgin_protocol_option_menu_get_selected(GtkWidget *optmenu)
{
- return (const char *)aop_option_menu_get_selected(optmenu, NULL);
+ return (const char *)aop_option_menu_get_selected(optmenu);
}
PurpleAccount *
pidgin_account_option_menu_get_selected(GtkWidget *optmenu)
{
- return (PurpleAccount *)aop_option_menu_get_selected(optmenu, NULL);
+ return (PurpleAccount *)aop_option_menu_get_selected(optmenu);
}
static AopMenu *
@@ -768,7 +721,8 @@ create_account_menu(PurpleAccount *default_account,
GdkPixbuf *pixbuf = NULL;
GList *list;
GList *p;
- GtkSizeGroup *sg;
+ GtkListStore *ls;
+ GtkTreeIter iter;
int i;
char buf[256];
@@ -777,11 +731,11 @@ create_account_menu(PurpleAccount *default_account,
else
list = purple_connections_get_all();
+ ls = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER);
+
aop_menu = g_malloc0(sizeof(AopMenu));
aop_menu->default_item = -1;
- aop_menu->menu = gtk_menu_new();
- gtk_widget_show(aop_menu->menu);
- sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+ aop_menu->model = GTK_TREE_MODEL(ls);
for (p = list, i = 0; p != NULL; p = p->next, i++) {
PurplePlugin *plugin;
@@ -820,8 +774,8 @@ create_account_menu(PurpleAccount *default_account,
purple_account_get_protocol_name(account));
}
- gtk_menu_shell_append(GTK_MENU_SHELL(aop_menu->menu),
- aop_menu_item_new(sg, pixbuf, buf, account, "account"));
+ gtk_list_store_append(ls, &iter);
+ gtk_list_store_set(ls, &iter, 0, pixbuf, 1, buf, 2, account, -1);
if (pixbuf)
g_object_unref(pixbuf);
@@ -829,9 +783,6 @@ create_account_menu(PurpleAccount *default_account,
if (default_account && account == default_account)
aop_menu->default_item = i;
}
-
- g_object_unref(sg);
-
return aop_menu;
}
@@ -842,7 +793,7 @@ regenerate_account_menu(GtkWidget *optmenu)
PurpleAccount *account;
PurpleFilterAccountFunc filter_func;
- account = (PurpleAccount *)aop_option_menu_get_selected(optmenu, NULL);
+ account = (PurpleAccount *)aop_option_menu_get_selected(optmenu);
show_all = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(optmenu), "show_all"));
filter_func = g_object_get_data(G_OBJECT(optmenu), "filter_func");
diff --git a/pidgin/plugins/contact_priority.c b/pidgin/plugins/contact_priority.c
index e59566b481..5ec79d973d 100644
--- a/pidgin/plugins/contact_priority.c
+++ b/pidgin/plugins/contact_priority.c
@@ -35,11 +35,11 @@ select_account(GtkWidget *widget, PurpleAccount *account, gpointer data)
}
static void
-account_update(GtkWidget *widget, GtkOptionMenu *optmenu)
+account_update(GtkWidget *widget, GtkWidget *optmenu)
{
PurpleAccount *account = NULL;
- account = g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(optmenu)))), "account");
+ account = pidgin_account_option_menu_get_selected(optmenu);
purple_account_set_int(account, "score", gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)));
}
@@ -147,8 +147,7 @@ get_config_frame(PurplePlugin *plugin)
gtk_box_pack_start(GTK_BOX(hbox), optmenu, FALSE, FALSE, 0);
/* this is where we set up the spin button we made above */
- account = g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu))))),
- "account");
+ account = pidgin_account_option_menu_get_selected(optmenu);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),
(gdouble)purple_account_get_int(account, "score", 0));
gtk_spin_button_set_adjustment(GTK_SPIN_BUTTON(spin), GTK_ADJUSTMENT(adj));
--
cgit v1.2.1
From f6c23f659469fd76f8fa6d7729bafdd71ae2f1b6 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Mon, 26 Jul 2010 05:38:41 +0000
Subject: Supply something for the widget.
---
pidgin/gtkutils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
index 535bda7ff5..befe79571a 100644
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -544,7 +544,7 @@ static void
aop_menu_cb(GtkWidget *optmenu, GCallback cb)
{
if (cb != NULL) {
- ((void (*)(GtkWidget *, gpointer, gpointer))cb)(NULL,
+ ((void (*)(GtkWidget *, gpointer, gpointer))cb)(optmenu,
aop_option_menu_get_selected(optmenu),
g_object_get_data(G_OBJECT(optmenu), "user_data"));
}
--
cgit v1.2.1
From 19b008e32b744d1b125ecbc8d2109bfc27da1da1 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Mon, 26 Jul 2010 05:40:49 +0000
Subject: Remove an extra "fake" check.
---
pidgin/gtkaccount.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c
index c1a8fc5ab3..697fad65be 100644
--- a/pidgin/gtkaccount.c
+++ b/pidgin/gtkaccount.c
@@ -245,7 +245,7 @@ set_dialog_icon(AccountPrefsDialog *dialog, gpointer data, size_t len, gchar *ne
}
static void
-set_account_protocol_cb(GtkWidget *item, const char *id,
+set_account_protocol_cb(GtkWidget *widget, const char *id,
AccountPrefsDialog *dialog)
{
PurplePlugin *new_plugin;
@@ -271,8 +271,7 @@ set_account_protocol_cb(GtkWidget *item, const char *id,
gtk_widget_grab_focus(dialog->protocol_menu);
- if (!dialog->prpl_info || !dialog->prpl_info->register_user ||
- g_object_get_data(G_OBJECT(item), "fake")) {
+ if (!dialog->prpl_info || !dialog->prpl_info->register_user) {
gtk_widget_hide(dialog->register_button);
} else {
if (dialog->prpl_info != NULL &&
--
cgit v1.2.1
From 5fb41b5e0dce8cca1900b535f5310b72cd4cde19 Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Sat, 20 Nov 2010 22:34:25 +0000
Subject: use the actual gtk+-3.0 package as the GTK+ dependency, for now
require the current preview version (2.91.5). Warning, it not yet compile
successfully
---
configure.ac | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 6c52b2ab37..35a720dc4a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -416,11 +416,11 @@ else
fi
if test "x$enable_gtkui" = "xyes" ; then
- PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.10.0], , [
+ PKG_CHECK_MODULES(GTK, [gtk+-3.0 >= 2.91.5], , [
AC_MSG_RESULT(no)
AC_MSG_ERROR([
-You must have GTK+ 2.10.0 or newer development headers installed to compile
+You must have GTK+ 2.91.5 or newer development headers installed to compile
Pidgin. If you want to build only Finch then specify --disable-gtkui when
running configure.
])])
--
cgit v1.2.1
From 2dabd7753e18b4e41d5da4f99e7a5c0f6dbf3290 Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Thu, 25 Nov 2010 22:30:18 +0000
Subject: compiles using GTK+ 3 from git, beware it does not yet run, in fact
it crashes...
---
pidgin/gtkaccount.c | 26 ++--
pidgin/gtkblist-theme-loader.c | 3 +-
pidgin/gtkblist.c | 185 ++++++++++++++----------
pidgin/gtkcellrendererexpander.c | 90 +++++++-----
pidgin/gtkconv.c | 288 ++++++++++++++++++++++----------------
pidgin/gtkdebug.c | 20 +--
pidgin/gtkdialogs.c | 13 +-
pidgin/gtkdialogs.h | 2 +-
pidgin/gtkdnd-hints.c | 48 ++++---
pidgin/gtkdocklet-gtk.c | 13 +-
pidgin/gtkdocklet.c | 10 +-
pidgin/gtkidle.c | 6 +-
pidgin/gtkimhtml.c | 253 +++++++++++++++++++++------------
pidgin/gtkimhtmltoolbar.c | 84 ++++++-----
pidgin/gtklog.c | 17 ++-
pidgin/gtkmain.c | 2 +-
pidgin/gtkmedia.c | 4 +-
pidgin/gtkmenutray.c | 16 +--
pidgin/gtknotify.c | 32 +++--
pidgin/gtkplugin.c | 23 +--
pidgin/gtkpounce.c | 20 +--
pidgin/gtkprefs.c | 25 ++--
pidgin/gtkprivacy.c | 8 +-
pidgin/gtkrequest.c | 57 +++++---
pidgin/gtkroomlist.c | 24 ++--
pidgin/gtksavedstatuses.c | 2 +-
pidgin/gtkscrollbook.c | 6 +-
pidgin/gtksmiley.c | 15 +-
pidgin/gtksourceundomanager.c | 3 +-
pidgin/gtkstatusbox.c | 89 ++++++------
pidgin/gtkutils.c | 60 ++++----
pidgin/gtkwhiteboard.c | 106 ++++++++------
pidgin/gtkwhiteboard.h | 2 +-
pidgin/minidialog.c | 2 +-
pidgin/pidgintooltip.c | 7 +-
pidgin/plugins/contact_priority.c | 2 +-
pidgin/plugins/convcolors.c | 4 +-
pidgin/plugins/disco/gtkdisco.c | 9 +-
pidgin/plugins/markerline.c | 2 +
pidgin/plugins/themeedit.c | 1 -
pidgin/plugins/ticker/gtkticker.c | 8 +-
pidgin/plugins/timestamp.c | 2 +-
pidgin/plugins/timestamp_format.c | 3 +-
pidgin/plugins/vvconfig.c | 4 +-
pidgin/plugins/xmppconsole.c | 86 ++++++------
45 files changed, 1005 insertions(+), 677 deletions(-)
diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c
index 4954c56b93..9a57ba387f 100644
--- a/pidgin/gtkaccount.c
+++ b/pidgin/gtkaccount.c
@@ -378,9 +378,11 @@ static void
account_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y,
GtkSelectionData *sd, guint info, guint t, AccountPrefsDialog *dialog)
{
- gchar *name = (gchar *)sd->data;
-
- if ((sd->length >= 0) && (sd->format == 8)) {
+ const gchar *name = (gchar *) gtk_selection_data_get_data(sd);
+ gint length = gtk_selection_data_get_length(sd);
+ gint format = gtk_selection_data_get_format(sd);
+
+ if (length >= 0 && format == 8) {
/* Well, it looks like the drag event was cool.
* Let's do something with it */
if (!g_ascii_strncasecmp(name, "file://", 7)) {
@@ -1050,7 +1052,7 @@ proxy_type_changed_cb(GtkWidget *menu, AccountPrefsDialog *dialog)
dialog->new_proxy_type == PURPLE_PROXY_NONE ||
dialog->new_proxy_type == PURPLE_PROXY_USE_ENVVAR) {
- gtk_widget_hide_all(dialog->proxy_vbox);
+ gtk_widget_hide(dialog->proxy_vbox);
}
else
gtk_widget_show_all(dialog->proxy_vbox);
@@ -1145,7 +1147,7 @@ add_proxy_options(AccountPrefsDialog *dialog, GtkWidget *parent)
if (type == PURPLE_PROXY_USE_GLOBAL || type == PURPLE_PROXY_NONE ||
type == PURPLE_PROXY_USE_ENVVAR)
- gtk_widget_hide_all(vbox2);
+ gtk_widget_hide(vbox2);
if ((value = purple_proxy_info_get_host(proxy_info)) != NULL)
@@ -1169,7 +1171,7 @@ add_proxy_options(AccountPrefsDialog *dialog, GtkWidget *parent)
dialog->new_proxy_type = PURPLE_PROXY_USE_GLOBAL;
gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->proxy_dropdown),
dialog->new_proxy_type + 1);
- gtk_widget_hide_all(vbox2);
+ gtk_widget_hide(vbox2);
}
/* Connect signals. */
@@ -1709,7 +1711,10 @@ drag_data_get_cb(GtkWidget *widget, GdkDragContext *ctx,
GtkSelectionData *data, guint info, guint time,
AccountsWindow *dialog)
{
- if (data->target == gdk_atom_intern("PURPLE_ACCOUNT", FALSE)) {
+
+ GdkAtom target = gtk_selection_data_get_target(data);
+
+ if (target == gdk_atom_intern("PURPLE_ACCOUNT", FALSE)) {
GtkTreeRowReference *ref;
GtkTreePath *source_row;
GtkTreeIter iter;
@@ -1780,13 +1785,16 @@ drag_data_received_cb(GtkWidget *widget, GdkDragContext *ctx,
guint x, guint y, GtkSelectionData *sd,
guint info, guint t, AccountsWindow *dialog)
{
- if (sd->target == gdk_atom_intern("PURPLE_ACCOUNT", FALSE) && sd->data) {
+ GdkAtom target = gtk_selection_data_get_target(sd);
+ const guchar *data = gtk_selection_data_get_data(sd);
+
+ if (target == gdk_atom_intern("PURPLE_ACCOUNT", FALSE) && data) {
gint dest_index;
PurpleAccount *a = NULL;
GtkTreePath *path = NULL;
GtkTreeViewDropPosition position;
- memcpy(&a, sd->data, sizeof(a));
+ memcpy(&a, data, sizeof(a));
if (gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), x, y,
&path, &position)) {
diff --git a/pidgin/gtkblist-theme-loader.c b/pidgin/gtkblist-theme-loader.c
index 4cb6bb87c5..eeb1817590 100644
--- a/pidgin/gtkblist-theme-loader.c
+++ b/pidgin/gtkblist-theme-loader.c
@@ -65,7 +65,8 @@ parse_color(xmlnode *node, const char *tag)
GdkColor color;
if (temp && gdk_color_parse(temp, &color)) {
- gdk_colormap_alloc_color(gdk_colormap_get_system(), &color, FALSE, TRUE);
+ /* TODO: fix this for gtk+ 3.0 */
+ /*gdk_colormap_alloc_color(gdk_colormap_get_system(), &color, FALSE, TRUE);*/
return gdk_color_copy(&color);
} else {
return NULL;
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index bc454c973c..0bc841f154 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -244,7 +244,7 @@ static gboolean gtk_blist_configure_cb(GtkWidget *w, GdkEventConfigure *event, g
/* check for visibility because when we aren't visible, this will *
* give us bogus (0,0) coordinates. - xOr */
- if (GTK_WIDGET_VISIBLE(w))
+ if (gtk_widget_get_visible(w))
gtk_window_get_position(GTK_WINDOW(w), &x, &y);
else
return FALSE; /* carry on normally */
@@ -990,20 +990,23 @@ make_blist_request_dialog(PidginBlistRequestData *data, PurpleAccount *account,
gtkblist = PIDGIN_BLIST(purple_get_blist());
blist_window = gtkblist ? GTK_WINDOW(gtkblist->window) : NULL;
+ /* TODO: set no separator in gtk+ 3... */
data->window = gtk_dialog_new_with_buttons(title,
- blist_window, GTK_DIALOG_NO_SEPARATOR,
- NULL);
+ blist_window, 0, NULL);
gtk_window_set_transient_for(GTK_WINDOW(data->window), blist_window);
gtk_dialog_set_default_response(GTK_DIALOG(data->window), GTK_RESPONSE_OK);
gtk_container_set_border_width(GTK_CONTAINER(data->window), PIDGIN_HIG_BOX_SPACE);
gtk_window_set_resizable(GTK_WINDOW(data->window), FALSE);
- gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(data->window)->vbox), PIDGIN_HIG_BORDER);
- gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), PIDGIN_HIG_BOX_SPACE);
+ gtk_box_set_spacing(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(data->window))),
+ PIDGIN_HIG_BORDER);
+ gtk_container_set_border_width(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(data->window))),
+ PIDGIN_HIG_BOX_SPACE);
gtk_window_set_role(GTK_WINDOW(data->window), window_role);
hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER);
- gtk_container_add(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), hbox);
+ gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(data->window))),
+ hbox);
gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
@@ -1066,7 +1069,7 @@ rebuild_chat_entries(PidginChatData *data, const char *default_chat_name)
if (pce->is_int)
{
- GtkObject *adjust;
+ GtkAdjustment *adjust;
adjust = gtk_adjustment_new(pce->min, pce->min, pce->max,
1, 10, 10);
input = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1, 0);
@@ -1627,11 +1630,11 @@ gtk_blist_key_press_cb(GtkWidget *tv, GdkEventKey *event, gpointer data)
pidgin_retrieve_user_info(buddy->account->gc, buddy->name);
} else {
switch (event->keyval) {
- case GDK_F2:
+ case GDK_KEY_F2:
gtk_blist_menu_alias_cb(tv, node);
break;
- case GDK_Left:
+ case GDK_KEY_Left:
path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter);
if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(tv), path)) {
/* Collapse the Group */
@@ -1653,7 +1656,7 @@ gtk_blist_key_press_cb(GtkWidget *tv, GdkEventKey *event, gpointer data)
gtk_tree_path_free(path);
break;
- case GDK_Right:
+ case GDK_KEY_Right:
path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter);
if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(tv), path)) {
/* Expand the Group */
@@ -2276,9 +2279,9 @@ static void pidgin_blist_drag_data_get_cb(GtkWidget *widget,
guint time,
gpointer null)
{
-
- if (data->target == gdk_atom_intern("PURPLE_BLIST_NODE", FALSE))
- {
+ GdkAtom target = gtk_selection_data_get_target(data);
+
+ if (target == gdk_atom_intern("PURPLE_BLIST_NODE", FALSE)) {
GtkTreeRowReference *ref = g_object_get_data(G_OBJECT(dc), "gtk-tree-view-source-row");
GtkTreePath *sourcerow = gtk_tree_row_reference_get_path(ref);
GtkTreeIter iter;
@@ -2297,9 +2300,7 @@ static void pidgin_blist_drag_data_get_cb(GtkWidget *widget,
sizeof (node));
gtk_tree_path_free(sourcerow);
- }
- else if (data->target == gdk_atom_intern("application/x-im-contact", FALSE))
- {
+ } else if (target == gdk_atom_intern("application/x-im-contact", FALSE)) {
GtkTreeRowReference *ref;
GtkTreePath *sourcerow;
GtkTreeIter iter;
@@ -2382,16 +2383,19 @@ static void pidgin_blist_drag_data_get_cb(GtkWidget *widget,
static void pidgin_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y,
GtkSelectionData *sd, guint info, guint t)
{
+ GdkAtom target = gtk_selection_data_get_target(sd);
+ const guchar *data = gtk_selection_data_get_data(sd);
+
if (gtkblist->drag_timeout) {
g_source_remove(gtkblist->drag_timeout);
gtkblist->drag_timeout = 0;
}
- if (sd->target == gdk_atom_intern("PURPLE_BLIST_NODE", FALSE) && sd->data) {
+ if (target == gdk_atom_intern("PURPLE_BLIST_NODE", FALSE) && data) {
PurpleBlistNode *n = NULL;
GtkTreePath *path = NULL;
GtkTreeViewDropPosition position;
- memcpy(&n, sd->data, sizeof(n));
+ memcpy(&n, data, sizeof(n));
if(gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), x, y, &path, &position)) {
/* if we're here, I think it means the drop is ok */
GtkTreeIter iter;
@@ -2530,12 +2534,10 @@ static void pidgin_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc,
}
gtk_tree_path_free(path);
- gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t);
+ gtk_drag_finish(dc, TRUE, (gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE), t);
}
- }
- else if (sd->target == gdk_atom_intern("application/x-im-contact",
- FALSE) && sd->data)
- {
+ } else if (target == gdk_atom_intern("application/x-im-contact",
+ FALSE) && data) {
PurpleGroup *group = NULL;
GtkTreePath *path = NULL;
GtkTreeViewDropPosition position;
@@ -2573,7 +2575,7 @@ static void pidgin_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc,
}
}
- if (pidgin_parse_x_im_contact((const char *)sd->data, FALSE, &account,
+ if (pidgin_parse_x_im_contact((const char *) data, FALSE, &account,
&protocol, &username, &alias))
{
if (account == NULL)
@@ -2597,9 +2599,10 @@ static void pidgin_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc,
if (path != NULL)
gtk_tree_path_free(path);
- gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t);
+ gtk_drag_finish(dc, TRUE,
+ (gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE), t);
}
- else if (sd->target == gdk_atom_intern("text/x-vcard", FALSE) && sd->data)
+ else if (target == gdk_atom_intern("text/x-vcard", FALSE) && data)
{
gboolean result;
PurpleGroup *group = NULL;
@@ -2635,10 +2638,11 @@ static void pidgin_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc,
}
}
- result = parse_vcard((const gchar *)sd->data, group);
+ result = parse_vcard((const gchar *) data, group);
- gtk_drag_finish(dc, result, (dc->action == GDK_ACTION_MOVE), t);
- } else if (sd->target == gdk_atom_intern("text/uri-list", FALSE) && sd->data) {
+ gtk_drag_finish(dc, result,
+ (gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE), t);
+ } else if (target == gdk_atom_intern("text/uri-list", FALSE) && data) {
GtkTreePath *path = NULL;
GtkTreeViewDropPosition position;
@@ -2659,7 +2663,8 @@ static void pidgin_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc,
if (PURPLE_BLIST_NODE_IS_BUDDY(node) || PURPLE_BLIST_NODE_IS_CONTACT(node)) {
PurpleBuddy *b = PURPLE_BLIST_NODE_IS_BUDDY(node) ? PURPLE_BUDDY(node) : purple_contact_get_priority_buddy(PURPLE_CONTACT(node));
pidgin_dnd_file_manage(sd, b->account, b->name);
- gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t);
+ gtk_drag_finish(dc, TRUE,
+ (gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE), t);
} else {
gtk_drag_finish(dc, FALSE, FALSE, t);
}
@@ -2997,7 +3002,7 @@ pidgin_blist_paint_tip(GtkWidget *widget, gpointer null)
if(gtkblist->tooltipdata == NULL)
return FALSE;
- style = gtkblist->tipwindow->style;
+ style = gtk_widget_get_style(gtkblist->tipwindow);
max_text_width = 0;
max_avatar_width = 0;
@@ -3023,73 +3028,102 @@ pidgin_blist_paint_tip(GtkWidget *widget, gpointer null)
for(l = gtkblist->tooltipdata; l; l = l->next)
{
struct tooltip_data *td = l->data;
-
+ cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtkblist->tipwindow));
+
if (td->avatar && pidgin_gdk_pixbuf_is_opaque(td->avatar))
{
if (dir == GTK_TEXT_DIR_RTL)
- gtk_paint_flat_box(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- NULL, gtkblist->tipwindow, "tooltip",
- TOOLTIP_BORDER -1, current_height -1, td->avatar_width +2, td->avatar_height + 2);
+ gtk_paint_flat_box(style, cr, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
+ gtkblist->tipwindow, "tooltip",
+ TOOLTIP_BORDER -1, current_height -1, td->avatar_width +2,
+ td->avatar_height + 2);
else
- gtk_paint_flat_box(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- NULL, gtkblist->tipwindow, "tooltip",
+ gtk_paint_flat_box(style, cr, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
+ gtkblist->tipwindow, "tooltip",
max_width - (td->avatar_width+ TOOLTIP_BORDER)-1,
current_height-1,td->avatar_width+2, td->avatar_height+2);
}
if (td->status_icon) {
- if (dir == GTK_TEXT_DIR_RTL)
+ if (dir == GTK_TEXT_DIR_RTL) {
+ gdk_cairo_set_source_pixbuf(cr, td->status_icon,
+ max_width - TOOLTIP_BORDER - status_size, current_height);
+ cairo_paint(cr);
+ /*
gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, td->status_icon,
0, 0, max_width - TOOLTIP_BORDER - status_size, current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
- else
+ */
+ } else {
+ gdk_cairo_set_source_pixbuf(cr, td->status_icon, TOOLTIP_BORDER, current_height);
+ cairo_paint(cr);
+ /*
gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, td->status_icon,
0, 0, TOOLTIP_BORDER, current_height, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0);
- }
+ */
+ }
+ }
if(td->avatar) {
- if (dir == GTK_TEXT_DIR_RTL)
+ if (dir == GTK_TEXT_DIR_RTL) {
+ gdk_cairo_set_source_pixbuf(cr, td->avatar, TOOLTIP_BORDER, current_height);
+ cairo_paint(cr);
+ /*
gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL,
td->avatar, 0, 0, TOOLTIP_BORDER, current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
- else
+ */
+ } else {
+ gdk_cairo_set_source_pixbuf(cr, td->avatar,
+ max_width - (td->avatar_width + TOOLTIP_BORDER), current_height);
+ cairo_paint(cr);
+ /*
gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL,
td->avatar, 0, 0, max_width - (td->avatar_width + TOOLTIP_BORDER),
current_height, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0);
+ */
+ }
}
- if (!td->avatar_is_prpl_icon && td->prpl_icon)
+ if (!td->avatar_is_prpl_icon && td->prpl_icon) {
+ gdk_cairo_set_source_pixbuf(cr, td->prpl_icon, prpl_col,
+ current_height + ((td->name_height / 2) - (PRPL_SIZE / 2)));
+ cairo_paint(cr);
+ /*
gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, td->prpl_icon,
0, 0,
prpl_col,
current_height + ((td->name_height / 2) - (PRPL_SIZE / 2)),
-1 , -1, GDK_RGB_DITHER_NONE, 0, 0);
+ */
+ }
if (td->name_layout) {
if (dir == GTK_TEXT_DIR_RTL) {
- gtk_paint_layout(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, FALSE,
- NULL, gtkblist->tipwindow, "tooltip",
+ gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE,
+ gtkblist->tipwindow, "tooltip",
max_width -(TOOLTIP_BORDER + status_size + SMALL_SPACE) - PANGO_PIXELS(300000),
current_height, td->name_layout);
} else {
- gtk_paint_layout (style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, FALSE,
- NULL, gtkblist->tipwindow, "tooltip",
+ gtk_paint_layout (style, cr, GTK_STATE_NORMAL, FALSE,
+ gtkblist->tipwindow, "tooltip",
TOOLTIP_BORDER + status_size + SMALL_SPACE, current_height, td->name_layout);
}
}
if (td->layout) {
if (dir != GTK_TEXT_DIR_RTL) {
- gtk_paint_layout (style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, FALSE,
- NULL, gtkblist->tipwindow, "tooltip",
+ gtk_paint_layout (style, cr, GTK_STATE_NORMAL, FALSE,
+ gtkblist->tipwindow, "tooltip",
TOOLTIP_BORDER + status_size + SMALL_SPACE, current_height + td->name_height, td->layout);
} else {
- gtk_paint_layout(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, FALSE,
- NULL, gtkblist->tipwindow, "tooltip",
+ gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE,
+ gtkblist->tipwindow, "tooltip",
max_width - (TOOLTIP_BORDER + status_size + SMALL_SPACE) - PANGO_PIXELS(300000),
current_height + td->name_height,
td->layout);
}
}
+ cairo_destroy(cr);
current_height += MAX(td->name_height + td->height, td->avatar_height) + td->padding;
}
return FALSE;
@@ -3243,7 +3277,8 @@ static gboolean pidgin_blist_expand_timeout(GtkWidget *tv)
pidgin_blist_expand_contact_cb(NULL, node);
gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, >kblist->contact_rect);
- gdk_drawable_get_size(GDK_DRAWABLE(tv->window), &(gtkblist->contact_rect.width), NULL);
+ gtkblist->contact_rect.width =
+ gdk_window_get_width(GDK_DRAWABLE(gtk_widget_get_window(tv)));
gtkblist->mouseover_contact = node;
gtk_tree_path_down (path);
while (gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &i, path)) {
@@ -4575,7 +4610,7 @@ static void pidgin_blist_restore_position(void)
/* if the window exists, is hidden, we're saving positions, and the
* position is sane... */
if (gtkblist && gtkblist->window &&
- !GTK_WIDGET_VISIBLE(gtkblist->window) && blist_width != 0) {
+ !gtk_widget_get_visible(gtkblist->window) && blist_width != 0) {
blist_x = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/blist/x");
blist_y = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/blist/y");
@@ -4605,7 +4640,7 @@ static gboolean pidgin_blist_refresh_timer(PurpleBuddyList *list)
PurpleBlistNode *gnode, *cnode;
if (gtk_blist_visibility == GDK_VISIBILITY_FULLY_OBSCURED
- || !GTK_WIDGET_VISIBLE(gtkblist->window))
+ || !gtk_widget_get_visible(gtkblist->window))
return TRUE;
for(gnode = list->root; gnode; gnode = gnode->next) {
@@ -5117,7 +5152,7 @@ gtk_blist_window_key_press_cb(GtkWidget *w, GdkEventKey *event, PidginBuddyList
widget = gtk_window_get_focus(GTK_WINDOW(gtkblist->window));
if (GTK_IS_IMHTML(widget) || GTK_IS_ENTRY(widget)) {
- if (gtk_bindings_activate(GTK_OBJECT(widget), event->keyval, event->state))
+ if (gtk_bindings_activate(G_OBJECT(widget), event->keyval, event->state))
return TRUE;
}
return FALSE;
@@ -5126,14 +5161,14 @@ gtk_blist_window_key_press_cb(GtkWidget *w, GdkEventKey *event, PidginBuddyList
static gboolean
headline_box_enter_cb(GtkWidget *widget, GdkEventCrossing *event, PidginBuddyList *gtkblist)
{
- gdk_window_set_cursor(widget->window, gtkblist->hand_cursor);
+ gdk_window_set_cursor(gtk_widget_get_window(widget), gtkblist->hand_cursor);
return FALSE;
}
static gboolean
headline_box_leave_cb(GtkWidget *widget, GdkEventCrossing *event, PidginBuddyList *gtkblist)
{
- gdk_window_set_cursor(widget->window, gtkblist->arrow_cursor);
+ gdk_window_set_cursor(gtk_widget_get_window(widget), gtkblist->arrow_cursor);
return FALSE;
}
@@ -5267,7 +5302,7 @@ generic_error_enable_cb(PurpleAccount *account)
}
static void
-generic_error_destroy_cb(GtkObject *dialog,
+generic_error_destroy_cb(GtkWidget *dialog,
PurpleAccount *account)
{
g_hash_table_remove(gtkblist->connection_errors, account);
@@ -5629,17 +5664,22 @@ paint_headline_hbox (GtkWidget *widget,
GdkEventExpose *event,
gpointer user_data)
{
- gtk_paint_flat_box (widget->style,
- widget->window,
+ cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(widget));
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation(widget, &allocation);
+ gtk_paint_flat_box (gtk_widget_get_style(widget),
+ cr,
GTK_STATE_NORMAL,
GTK_SHADOW_OUT,
- NULL,
widget,
"tooltip",
- widget->allocation.x + 1,
- widget->allocation.y + 1,
- widget->allocation.width - 2,
- widget->allocation.height - 2);
+ allocation.x + 1,
+ allocation.y + 1,
+ allocation.width - 2,
+ allocation.height - 2);
+ cairo_destroy(cr);
+
return FALSE;
}
@@ -5979,7 +6019,9 @@ static void pidgin_blist_show(PurpleBuddyList *list)
G_CALLBACK(blist_focus_cb), gtkblist);
g_signal_connect(G_OBJECT(gtkblist->window), "focus-out-event",
G_CALLBACK(blist_focus_cb), gtkblist);
- GTK_WINDOW(gtkblist->window)->allow_shrink = TRUE;
+
+ /* TODO: how is this done in gtk+ 3.0? */
+ /*GTK_WINDOW(gtkblist->window)->allow_shrink = TRUE;*/
gtkblist->main_vbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(gtkblist->main_vbox);
@@ -7138,7 +7180,8 @@ static void pidgin_blist_set_visible(PurpleBuddyList *list, gboolean show)
return;
if (show) {
- if(!PIDGIN_WINDOW_ICONIFIED(gtkblist->window) && !GTK_WIDGET_VISIBLE(gtkblist->window))
+ if(!PIDGIN_WINDOW_ICONIFIED(gtkblist->window) &&
+ !gtk_widget_get_visible(gtkblist->window))
purple_signal_emit(pidgin_blist_get_handle(), "gtkblist-unhiding", gtkblist);
pidgin_blist_restore_position();
gtk_window_present(GTK_WINDOW(gtkblist->window));
@@ -7147,7 +7190,7 @@ static void pidgin_blist_set_visible(PurpleBuddyList *list, gboolean show)
purple_signal_emit(pidgin_blist_get_handle(), "gtkblist-hiding", gtkblist);
gtk_widget_hide(gtkblist->window);
} else {
- if (!GTK_WIDGET_VISIBLE(gtkblist->window))
+ if (!gtk_widget_get_visible(gtkblist->window))
gtk_widget_show(gtkblist->window);
gtk_window_iconify(GTK_WINDOW(gtkblist->window));
}
@@ -7523,7 +7566,7 @@ void
pidgin_blist_toggle_visibility()
{
if (gtkblist && gtkblist->window) {
- if (GTK_WIDGET_VISIBLE(gtkblist->window)) {
+ if (gtk_widget_get_visible(gtkblist->window)) {
/* make the buddy list visible if it is iconified or if it is
* obscured and not currently focused (the focus part ensures
* that we do something reasonable if the buddy list is obscured
@@ -7588,7 +7631,7 @@ pidgin_blist_set_headline(const char *text, GdkPixbuf *pixbuf, GCallback callbac
static void
set_urgent(void)
{
- if (gtkblist->window && !GTK_WIDGET_HAS_FOCUS(gtkblist->window))
+ if (gtkblist->window && !gtk_widget_is_focus(gtkblist->window))
pidgin_set_urgent(GTK_WINDOW(gtkblist->window), TRUE);
}
@@ -8131,7 +8174,7 @@ static void sort_method_log_activity(PurpleBlistNode *node, PurpleBuddyList *bli
}
static void
-plugin_act(GtkObject *obj, PurplePluginAction *pam)
+plugin_act(GtkWidget *obj, PurplePluginAction *pam)
{
if (pam && pam->callback)
pam->callback(pam);
diff --git a/pidgin/gtkcellrendererexpander.c b/pidgin/gtkcellrendererexpander.c
index a5bb6c8a98..9a46ab87cc 100644
--- a/pidgin/gtkcellrendererexpander.c
+++ b/pidgin/gtkcellrendererexpander.c
@@ -44,24 +44,23 @@ static void pidgin_cell_renderer_expander_init (PidginCellRendererExpander
static void pidgin_cell_renderer_expander_class_init (PidginCellRendererExpanderClass *class);
static void pidgin_cell_renderer_expander_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
- GdkRectangle *cell_area,
+ const GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height);
static void pidgin_cell_renderer_expander_render (GtkCellRenderer *cell,
- GdkWindow *window,
+ cairo_t *cr,
GtkWidget *widget,
- GdkRectangle *background_area,
- GdkRectangle *cell_area,
- GdkRectangle *expose_area,
- guint flags);
+ const GdkRectangle *background_area,
+ const GdkRectangle *cell_area,
+ GtkCellRendererState flags);
static gboolean pidgin_cell_renderer_expander_activate (GtkCellRenderer *r,
GdkEvent *event,
GtkWidget *widget,
const gchar *p,
- GdkRectangle *bg,
- GdkRectangle *cell,
+ const GdkRectangle *bg,
+ const GdkRectangle *cell,
GtkCellRendererState flags);
static void pidgin_cell_renderer_expander_finalize (GObject *gobject);
@@ -108,9 +107,10 @@ GType pidgin_cell_renderer_expander_get_type (void)
static void pidgin_cell_renderer_expander_init (PidginCellRendererExpander *cellexpander)
{
- GTK_CELL_RENDERER(cellexpander)->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE;
- GTK_CELL_RENDERER(cellexpander)->xpad = 0;
- GTK_CELL_RENDERER(cellexpander)->ypad = 2;
+ g_object_set(G_OBJECT(cellexpander), "mode",
+ GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL);
+ /*GTK_CELL_RENDERER(cellexpander)->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE;*/
+ gtk_cell_renderer_set_padding(GTK_CELL_RENDERER(cellexpander), 0, 2);
}
static void pidgin_cell_renderer_expander_class_init (PidginCellRendererExpanderClass *class)
@@ -190,7 +190,7 @@ GtkCellRenderer *pidgin_cell_renderer_expander_new(void)
static void pidgin_cell_renderer_expander_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
- GdkRectangle *cell_area,
+ const GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
@@ -199,11 +199,17 @@ static void pidgin_cell_renderer_expander_get_size (GtkCellRenderer *cell,
gint calc_width;
gint calc_height;
gint expander_size;
-
+ gint xpad;
+ gint ypad;
+ gfloat xalign;
+ gfloat yalign;
+
gtk_widget_style_get(widget, "expander-size", &expander_size, NULL);
- calc_width = (gint) cell->xpad * 2 + expander_size;
- calc_height = (gint) cell->ypad * 2 + expander_size;
+ gtk_cell_renderer_get_padding(cell, &xpad, &ypad);
+ gtk_cell_renderer_get_alignment(cell, &xalign, &yalign);
+ calc_width = (gint) xpad * 2 + expander_size;
+ calc_height = (gint) ypad * 2 + expander_size;
if (width)
*width = calc_width;
@@ -215,12 +221,12 @@ static void pidgin_cell_renderer_expander_get_size (GtkCellRenderer *cell,
{
if (x_offset)
{
- *x_offset = cell->xalign * (cell_area->width - calc_width);
+ *x_offset = xalign * (cell_area->width - calc_width);
*x_offset = MAX (*x_offset, 0);
}
if (y_offset)
{
- *y_offset = cell->yalign * (cell_area->height - calc_height);
+ *y_offset = yalign * (cell_area->height - calc_height);
*y_offset = MAX (*y_offset, 0);
}
}
@@ -228,56 +234,64 @@ static void pidgin_cell_renderer_expander_get_size (GtkCellRenderer *cell,
static void pidgin_cell_renderer_expander_render(GtkCellRenderer *cell,
- GdkWindow *window,
+ cairo_t *cr,
GtkWidget *widget,
- GdkRectangle *background_area,
- GdkRectangle *cell_area,
- GdkRectangle *expose_area,
- guint flags)
+ const GdkRectangle *background_area,
+ const GdkRectangle *cell_area,
+ GtkCellRendererState flags)
{
PidginCellRendererExpander *cellexpander = (PidginCellRendererExpander *) cell;
gboolean set;
gint width, height;
GtkStateType state;
-
+ gint xpad;
+ gint ypad;
+ gboolean is_expanded;
+ GtkAllocation allocation;
+
+ gtk_cell_renderer_get_padding(cell, &xpad, &ypad);
+ g_object_get(G_OBJECT(cell), "expanded", &is_expanded, NULL);
+
if (!cellexpander->is_expander)
return;
width = cell_area->width;
height = cell_area->height;
- if (!cell->sensitive)
+ if (!gtk_widget_get_sensitive(GTK_WIDGET(cell)))
state = GTK_STATE_INSENSITIVE;
else if (flags & GTK_CELL_RENDERER_PRELIT)
state = GTK_STATE_PRELIGHT;
- else if (GTK_WIDGET_HAS_FOCUS (widget) && flags & GTK_CELL_RENDERER_SELECTED)
+ else if (gtk_widget_has_focus(widget) && flags & GTK_CELL_RENDERER_SELECTED)
state = GTK_STATE_ACTIVE;
else
state = GTK_STATE_NORMAL;
- width -= cell->xpad*2;
- height -= cell->ypad*2;
+ width -= xpad*2;
+ height -= ypad*2;
- gtk_paint_expander (widget->style,
- window, state,
- NULL, widget, "treeview",
- cell_area->x + cell->xpad + (width / 2),
- cell_area->y + cell->ypad + (height / 2),
- cell->is_expanded ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED);
+ gtk_paint_expander (gtk_widget_get_style(widget),
+ cr, state,
+ widget, "treeview",
+ cell_area->x + xpad + (width / 2),
+ cell_area->y + ypad + (height / 2),
+ is_expanded ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED);
/* only draw the line if the color isn't set - this prevents a bug where the hline appears only under the expander */
g_object_get(cellexpander, "cell-background-set", &set, NULL);
- if (cell->is_expanded && !set)
- gtk_paint_hline (widget->style, window, state, NULL, widget, NULL, 0,
- widget->allocation.width, cell_area->y + cell_area->height);
+ gtk_widget_get_allocation(widget, &allocation);
+
+ if (is_expanded && !set)
+ gtk_paint_hline (gtk_widget_get_style(widget), cr, state, widget, NULL, 0,
+ allocation.width, cell_area->y + cell_area->height);
}
static gboolean pidgin_cell_renderer_expander_activate(GtkCellRenderer *r,
GdkEvent *event,
GtkWidget *widget,
const gchar *p,
- GdkRectangle *bg,
- GdkRectangle *cell,
+ const GdkRectangle *bg,
+ const GdkRectangle *cell,
GtkCellRendererState flags)
{
GtkTreePath *path = gtk_tree_path_new_from_string(p);
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
index 18d824e092..f574159d81 100644
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -778,15 +778,17 @@ invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y,
InviteBuddyInfo *info = (InviteBuddyInfo *)data;
const char *convprotocol;
gboolean success = TRUE;
-
+ GdkAtom target = gtk_selection_data_get_target(sd);
+
convprotocol = purple_account_get_protocol_id(purple_conversation_get_account(info->conv));
- if (sd->target == gdk_atom_intern("PURPLE_BLIST_NODE", FALSE))
+ if (target == gdk_atom_intern("PURPLE_BLIST_NODE", FALSE))
{
PurpleBlistNode *node = NULL;
PurpleBuddy *buddy;
-
- memcpy(&node, sd->data, sizeof(node));
+ const guchar *data = gtk_selection_data_get_data(sd);
+
+ memcpy(&node, data, sizeof(node));
if (PURPLE_BLIST_NODE_IS_CONTACT(node))
buddy = purple_contact_get_priority_buddy((PurpleContact *)node);
@@ -805,15 +807,16 @@ invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y,
else
gtk_entry_set_text(GTK_ENTRY(info->entry), purple_buddy_get_name(buddy));
- gtk_drag_finish(dc, success, (dc->action == GDK_ACTION_MOVE), t);
+ gtk_drag_finish(dc, success,
+ gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE, t);
}
- else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE))
+ else if (target == gdk_atom_intern("application/x-im-contact", FALSE))
{
char *protocol = NULL;
char *username = NULL;
PurpleAccount *account;
- if (pidgin_parse_x_im_contact((const char *)sd->data, FALSE, &account,
+ if (pidgin_parse_x_im_contact((const char *) data, FALSE, &account,
&protocol, &username, NULL))
{
if (account == NULL)
@@ -838,7 +841,8 @@ invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y,
g_free(username);
g_free(protocol);
- gtk_drag_finish(dc, success, (dc->action == GDK_ACTION_MOVE), t);
+ gtk_drag_finish(dc, success,
+ gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE, t);
}
}
@@ -880,12 +884,15 @@ invite_cb(GtkWidget *widget, PidginConversation *gtkconv)
GTK_RESPONSE_OK);
gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), PIDGIN_HIG_BOX_SPACE);
gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE);
+ /* TODO: set no separator using GTK+ 3.0 */
+ /*
gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE);
-
+ */
+
info->window = GTK_WIDGET(invite_dialog);
/* Setup the outside spacing. */
- vbox = GTK_DIALOG(invite_dialog)->vbox;
+ vbox = gtk_dialog_get_content_area(GTK_DIALOG(invite_dialog));
gtk_box_set_spacing(GTK_BOX(vbox), PIDGIN_HIG_BORDER);
gtk_container_set_border_width(GTK_CONTAINER(vbox), PIDGIN_HIG_BOX_SPACE);
@@ -1078,8 +1085,8 @@ menu_view_log_cb(GtkAction *action, gpointer data)
gtkblist = pidgin_blist_get_default_gtk_blist();
cursor = gdk_cursor_new(GDK_WATCH);
- gdk_window_set_cursor(gtkblist->window->window, cursor);
- gdk_window_set_cursor(win->window->window, cursor);
+ gdk_window_set_cursor(gtk_widget_get_window(gtkblist->window), cursor);
+ gdk_window_set_cursor(gtk_widget_get_window(win->window), cursor);
gdk_cursor_unref(cursor);
#if GTK_CHECK_VERSION(2,4,0) && !GTK_CHECK_VERSION(2,6,0) //FIXME: What?
gdk_display_flush(gdk_drawable_get_display(GDK_DRAWABLE(widget->window)));
@@ -1096,8 +1103,8 @@ menu_view_log_cb(GtkAction *action, gpointer data)
{
pidgin_log_show_contact((PurpleContact *)node->parent);
g_slist_free(buddies);
- gdk_window_set_cursor(gtkblist->window->window, NULL);
- gdk_window_set_cursor(win->window->window, NULL);
+ gdk_window_set_cursor(gtk_widget_get_window(gtkblist->window), NULL);
+ gdk_window_set_cursor(gtk_widget_get_window(win->window), NULL);
return;
}
}
@@ -1105,8 +1112,8 @@ menu_view_log_cb(GtkAction *action, gpointer data)
pidgin_log_show(type, name, account);
- gdk_window_set_cursor(gtkblist->window->window, NULL);
- gdk_window_set_cursor(win->window->window, NULL);
+ gdk_window_set_cursor(gtk_widget_get_window(gtkblist->window), NULL);
+ gdk_window_set_cursor(gtk_widget_get_window(win->window), NULL);
}
static void
@@ -1919,7 +1926,7 @@ conv_keypress_common(PidginConversation *gtkconv, GdkEventKey *event)
/* If CTRL was held down... */
if (event->state & GDK_CONTROL_MASK) {
switch (event->keyval) {
- case GDK_Page_Down:
+ case GDK_KEY_Page_Down:
case ']':
if (!pidgin_conv_window_get_gtkconv_at_index(win, curconv + 1))
gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0);
@@ -1928,7 +1935,7 @@ conv_keypress_common(PidginConversation *gtkconv, GdkEventKey *event)
return TRUE;
break;
- case GDK_Page_Up:
+ case GDK_KEY_Page_Up:
case '[':
if (!pidgin_conv_window_get_gtkconv_at_index(win, curconv - 1))
gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1);
@@ -1937,9 +1944,9 @@ conv_keypress_common(PidginConversation *gtkconv, GdkEventKey *event)
return TRUE;
break;
- case GDK_Tab:
- case GDK_KP_Tab:
- case GDK_ISO_Left_Tab:
+ case GDK_KEY_Tab:
+ case GDK_KEY_KP_Tab:
+ case GDK_KEY_ISO_Left_Tab:
if (event->state & GDK_SHIFT_MASK) {
move_to_next_unread_tab(gtkconv, FALSE);
} else {
@@ -1949,20 +1956,20 @@ conv_keypress_common(PidginConversation *gtkconv, GdkEventKey *event)
return TRUE;
break;
- case GDK_comma:
+ case GDK_KEY_comma:
gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook),
gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv),
curconv - 1);
return TRUE;
break;
- case GDK_period:
+ case GDK_KEY_period:
gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook),
gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv),
(curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook)));
return TRUE;
break;
- case GDK_F6:
+ case GDK_KEY_F6:
if (gtkconv_cycle_focus(gtkconv, event->state & GDK_SHIFT_MASK ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD))
return TRUE;
break;
@@ -1986,13 +1993,13 @@ conv_keypress_common(PidginConversation *gtkconv, GdkEventKey *event)
else
{
switch (event->keyval) {
- case GDK_F2:
+ case GDK_KEY_F2:
if (gtk_widget_is_focus(GTK_WIDGET(win->notebook))) {
infopane_entry_activate(gtkconv);
return TRUE;
}
break;
- case GDK_F6:
+ case GDK_KEY_F6:
if (gtkconv_cycle_focus(gtkconv, event->state & GDK_SHIFT_MASK ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD))
return TRUE;
break;
@@ -2016,7 +2023,7 @@ entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data)
/* If CTRL was held down... */
if (event->state & GDK_CONTROL_MASK) {
switch (event->keyval) {
- case GDK_Up:
+ case GDK_KEY_Up:
if (!gtkconv->send_history)
break;
@@ -2067,7 +2074,7 @@ entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data)
return TRUE;
break;
- case GDK_Down:
+ case GDK_KEY_Down:
if (!gtkconv->send_history)
break;
@@ -2120,20 +2127,20 @@ entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data)
/* If neither CTRL nor ALT were held down... */
else {
switch (event->keyval) {
- case GDK_Tab:
- case GDK_KP_Tab:
- case GDK_ISO_Left_Tab:
+ case GDK_KEY_Tab:
+ case GDK_KEY_KP_Tab:
+ case GDK_KEY_ISO_Left_Tab:
if (gtkconv->entry != entry)
break;
return tab_complete(conv);
break;
- case GDK_Page_Up:
+ case GDK_KEY_Page_Up:
gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml));
return TRUE;
break;
- case GDK_Page_Down:
+ case GDK_KEY_Page_Down:
gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml));
return TRUE;
break;
@@ -2177,24 +2184,24 @@ refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
/* If we have a valid key for the conversation display, then exit */
if ((event->state & GDK_CONTROL_MASK) ||
- (event->keyval == GDK_F6) ||
- (event->keyval == GDK_F10) ||
- (event->keyval == GDK_Shift_L) ||
- (event->keyval == GDK_Shift_R) ||
- (event->keyval == GDK_Control_L) ||
- (event->keyval == GDK_Control_R) ||
- (event->keyval == GDK_Escape) ||
- (event->keyval == GDK_Up) ||
- (event->keyval == GDK_Down) ||
- (event->keyval == GDK_Left) ||
- (event->keyval == GDK_Right) ||
- (event->keyval == GDK_Page_Up) ||
- (event->keyval == GDK_Page_Down) ||
- (event->keyval == GDK_Home) ||
- (event->keyval == GDK_End) ||
- (event->keyval == GDK_Tab) ||
- (event->keyval == GDK_KP_Tab) ||
- (event->keyval == GDK_ISO_Left_Tab))
+ (event->keyval == GDK_KEY_F6) ||
+ (event->keyval == GDK_KEY_F10) ||
+ (event->keyval == GDK_KEY_Shift_L) ||
+ (event->keyval == GDK_KEY_Shift_R) ||
+ (event->keyval == GDK_KEY_Control_L) ||
+ (event->keyval == GDK_KEY_Control_R) ||
+ (event->keyval == GDK_KEY_Escape) ||
+ (event->keyval == GDK_KEY_Up) ||
+ (event->keyval == GDK_KEY_Down) ||
+ (event->keyval == GDK_KEY_Left) ||
+ (event->keyval == GDK_KEY_Right) ||
+ (event->keyval == GDK_KEY_Page_Up) ||
+ (event->keyval == GDK_KEY_Page_Down) ||
+ (event->keyval == GDK_KEY_Home) ||
+ (event->keyval == GDK_KEY_End) ||
+ (event->keyval == GDK_KEY_Tab) ||
+ (event->keyval == GDK_KEY_KP_Tab) ||
+ (event->keyval == GDK_KEY_ISO_Left_Tab))
{
if (event->type == GDK_KEY_PRESS)
return conv_keypress_common(gtkconv, event);
@@ -2662,7 +2669,7 @@ redraw_icon(gpointer data)
}
static void
-start_anim(GtkObject *obj, PidginConversation *gtkconv)
+start_anim(GtkWidget *widget, PidginConversation *gtkconv)
{
int delay;
@@ -2835,7 +2842,7 @@ icon_menu_save_cb(GtkWidget *widget, PidginConversation *gtkconv)
}
static void
-stop_anim(GtkObject *obj, PidginConversation *gtkconv)
+stop_anim(GtkWidget *widget, PidginConversation *gtkconv)
{
if (gtkconv->u.im->icon_timer != 0)
g_source_remove(gtkconv->u.im->icon_timer);
@@ -2857,7 +2864,7 @@ toggle_icon_animate_cb(GtkWidget *w, PidginConversation *gtkconv)
}
static gboolean
-icon_menu(GtkObject *obj, GdkEventButton *e, PidginConversation *gtkconv)
+icon_menu(GtkWidget *widget, GdkEventButton *e, PidginConversation *gtkconv)
{
static GtkWidget *menu = NULL;
PurpleConversation *conv;
@@ -4658,13 +4665,22 @@ static gboolean resize_imhtml_cb(PidginConversation *gtkconv)
GdkRectangle oneline;
int height, diff;
int pad_top, pad_inside, pad_bottom;
- int total_height = (gtkconv->imhtml->allocation.height + gtkconv->entry->allocation.height);
- int max_height = total_height / 2;
+ int total_height;
+ int max_height;
int min_lines = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines");
int min_height;
gboolean interior_focus;
int focus_width;
-
+ GtkAllocation imhtml_allocation;
+ GtkAllocation entry_allocation;
+ GtkAllocation lower_hbox_allocation;
+
+ gtk_widget_get_allocation(gtkconv->imhtml, &imhtml_allocation);
+ gtk_widget_get_allocation(gtkconv->entry, &entry_allocation);
+ gtk_widget_get_allocation(gtkconv->lower_hbox, &lower_hbox_allocation);
+ total_height = imhtml_allocation.height + entry_allocation.height;
+ max_height = total_height / 2;
+
pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(gtkconv->entry));
pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(gtkconv->entry));
pad_inside = gtk_text_view_get_pixels_inside_wrap(GTK_TEXT_VIEW(gtkconv->entry));
@@ -4697,12 +4713,12 @@ static gboolean resize_imhtml_cb(PidginConversation *gtkconv)
if (!interior_focus)
height += 2 * focus_width;
- diff = height - gtkconv->entry->allocation.height;
+ diff = height - entry_allocation.height;
if (ABS(diff) < oneline.height / 2)
return FALSE;
gtk_widget_set_size_request(gtkconv->lower_hbox, -1,
- diff + gtkconv->lower_hbox->allocation.height);
+ diff + lower_hbox_allocation.height);
return FALSE;
}
@@ -4749,7 +4765,7 @@ setup_chat_topic(PidginConversation *gtkconv, GtkWidget *vbox)
if(prpl_info->set_chat_topic == NULL) {
gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE);
} else {
- g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate",
+ g_signal_connect(GTK_WIDGET(gtkchat->topic_text), "activate",
G_CALLBACK(topic_callback), gtkconv);
}
@@ -4924,7 +4940,7 @@ pidgin_conv_end_quickfind(PidginConversation *gtkconv)
gtk_widget_modify_base(gtkconv->quickfind.entry, GTK_STATE_NORMAL, NULL);
gtk_imhtml_search_clear(GTK_IMHTML(gtkconv->imhtml));
- gtk_widget_hide_all(gtkconv->quickfind.container);
+ gtk_widget_hide(gtkconv->quickfind.container);
gtk_widget_grab_focus(gtkconv->entry);
return TRUE;
@@ -4934,8 +4950,8 @@ static gboolean
quickfind_process_input(GtkWidget *entry, GdkEventKey *event, PidginConversation *gtkconv)
{
switch (event->keyval) {
- case GDK_Return:
- case GDK_KP_Enter:
+ case GDK_KEY_Return:
+ case GDK_KEY_KP_Enter:
if (gtk_imhtml_search_find(GTK_IMHTML(gtkconv->imhtml), gtk_entry_get_text(GTK_ENTRY(entry)))) {
gtk_widget_modify_base(gtkconv->quickfind.entry, GTK_STATE_NORMAL, NULL);
} else {
@@ -4946,7 +4962,7 @@ quickfind_process_input(GtkWidget *entry, GdkEventKey *event, PidginConversation
gtk_widget_modify_base(gtkconv->quickfind.entry, GTK_STATE_NORMAL, &col);
}
break;
- case GDK_Escape:
+ case GDK_KEY_Escape:
pidgin_conv_end_quickfind(gtkconv);
break;
default:
@@ -5189,8 +5205,10 @@ conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y,
PurpleAccount *convaccount = purple_conversation_get_account(conv);
PurpleConnection *gc = purple_account_get_connection(convaccount);
PurplePluginProtocolInfo *prpl_info = gc ? PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl) : NULL;
-
- if (sd->target == gdk_atom_intern("PURPLE_BLIST_NODE", FALSE))
+ GdkAtom target = gtk_selection_data_get_target(sd);
+ const guchar *data = gtk_selection_data_get_data(sd);
+
+ if (target == gdk_atom_intern("PURPLE_BLIST_NODE", FALSE))
{
PurpleBlistNode *n = NULL;
PurpleBuddy *b;
@@ -5198,7 +5216,7 @@ conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y,
PurpleAccount *buddyaccount;
const char *buddyname;
- n = *(PurpleBlistNode **)sd->data;
+ n = *(PurpleBlistNode **) data;
if (PURPLE_BLIST_NODE_IS_CONTACT(n))
b = purple_contact_get_priority_buddy((PurpleContact*)n);
@@ -5246,16 +5264,17 @@ conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y,
pidgin_conv_window_switch_gtkconv(win, gtkconv);
}
- gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t);
+ gtk_drag_finish(dc, TRUE,
+ gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE, t);
}
- else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE))
+ else if (target == gdk_atom_intern("application/x-im-contact", FALSE))
{
char *protocol = NULL;
char *username = NULL;
PurpleAccount *account;
PidginConversation *gtkconv;
- if (pidgin_parse_x_im_contact((const char *)sd->data, FALSE, &account,
+ if (pidgin_parse_x_im_contact((const char *) data, FALSE, &account,
&protocol, &username, NULL))
{
if (account == NULL)
@@ -5286,12 +5305,14 @@ conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y,
g_free(username);
g_free(protocol);
- gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t);
+ gtk_drag_finish(dc, TRUE,
+ gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE, t);
}
- else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) {
+ else if (target == gdk_atom_intern("text/uri-list", FALSE)) {
if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
pidgin_dnd_file_manage(sd, convaccount, purple_conversation_get_name(conv));
- gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t);
+ gtk_drag_finish(dc, TRUE,
+ gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE, t);
}
else
gtk_drag_finish(dc, FALSE, FALSE, t);
@@ -5697,21 +5718,28 @@ static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml,
GdkEventButton *btn_event = (GdkEventButton*) event;
PurpleConversation *conv = data;
char *buddyname;
+ gchar *name;
+ g_object_get(G_OBJECT(tag), "name", &name, NULL);
+
/* strlen("BUDDY " or "HILIT ") == 6 */
- g_return_val_if_fail((tag->name != NULL)
- && (strlen(tag->name) > 6), FALSE);
+ g_return_val_if_fail((name != NULL) && (strlen(name) > 6), FALSE);
- buddyname = (tag->name) + 6;
+ buddyname = name + 6;
+
if (btn_event->button == 1 &&
event->type == GDK_2BUTTON_PRESS) {
chat_do_im(PIDGIN_CONVERSATION(conv), buddyname);
+ g_free(name);
+
return TRUE;
} else if (btn_event->button == 2
&& event->type == GDK_2BUTTON_PRESS) {
chat_do_info(PIDGIN_CONVERSATION(conv), buddyname);
+ g_free(name);
+
return TRUE;
} else if (btn_event->button == 3
&& event->type == GDK_BUTTON_PRESS) {
@@ -5733,10 +5761,14 @@ static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml,
btn_event->button,
btn_event->time);
+ g_free(name);
+
/* Don't propagate the event any further */
return TRUE;
}
}
+
+ g_free(name);
}
return FALSE;
@@ -6863,7 +6895,7 @@ pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields)
if (title != markup)
g_free(markup);
- if (!GTK_WIDGET_REALIZED(gtkconv->tab_label))
+ if (!gtk_widget_get_realized(gtkconv->tab_label))
gtk_widget_realize(gtkconv->tab_label);
accessibility_obj = gtk_widget_get_accessible(gtkconv->tab_cont);
@@ -7238,11 +7270,14 @@ pidgin_conv_xy_to_right_infopane(PidginWindow *win, int x, int y)
{
gint pane_x, pane_y, x_rel;
PidginConversation *gtkconv;
+ GtkAllocation allocation;
- gdk_window_get_origin(win->notebook->window, &pane_x, &pane_y);
+ gtk_widget_get_allocation(gtkconv->infopane, &allocation);
+ gdk_window_get_origin(gtk_widget_get_window(win->notebook),
+ &pane_x, &pane_y);
x_rel = x - pane_x;
gtkconv = pidgin_conv_window_get_active_gtkconv(win);
- return (x_rel > gtkconv->infopane->allocation.x + gtkconv->infopane->allocation.width / 2);
+ return (x_rel > allocation.x + allocation.width / 2);
}
int
@@ -7260,7 +7295,7 @@ pidgin_conv_get_tab_at_xy(PidginWindow *win, int x, int y, gboolean *to_right)
notebook = GTK_NOTEBOOK(win->notebook);
- gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y);
+ gdk_window_get_origin(gtk_widget_get_window(win->notebook), &nb_x, &nb_y);
x_rel = x - nb_x;
y_rel = y - nb_y;
@@ -7270,30 +7305,32 @@ pidgin_conv_get_tab_at_xy(PidginWindow *win, int x, int y, gboolean *to_right)
count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook));
for (i = 0; i < count; i++) {
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(tab, &allocation);
page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i);
tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page);
/* Make sure the tab is not hidden beyond an arrow */
- if (!GTK_WIDGET_DRAWABLE(tab) && gtk_notebook_get_show_tabs(notebook))
+ if (!gtk_widget_is_drawable(tab) && gtk_notebook_get_show_tabs(notebook))
continue;
if (horiz) {
- if (x_rel >= tab->allocation.x - PIDGIN_HIG_BOX_SPACE &&
- x_rel <= tab->allocation.x + tab->allocation.width + PIDGIN_HIG_BOX_SPACE) {
+ if (x_rel >= allocation.x - PIDGIN_HIG_BOX_SPACE &&
+ x_rel <= allocation.x + allocation.width + PIDGIN_HIG_BOX_SPACE) {
page_num = i;
- if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2)
+ if (to_right && x_rel >= allocation.x + allocation.width/2)
*to_right = TRUE;
break;
}
} else {
- if (y_rel >= tab->allocation.y - PIDGIN_HIG_BOX_SPACE &&
- y_rel <= tab->allocation.y + tab->allocation.height + PIDGIN_HIG_BOX_SPACE) {
+ if (y_rel >= allocation.y - PIDGIN_HIG_BOX_SPACE &&
+ y_rel <= allocation.y + allocation.height + PIDGIN_HIG_BOX_SPACE) {
page_num = i;
- if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2)
+ if (to_right && y_rel >= allocation.y + allocation.height/2)
*to_right = TRUE;
break;
@@ -8383,11 +8420,15 @@ build_warn_close_dialog(PidginWindow *gtkwin)
gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog),
6);
gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE);
- gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog),
- FALSE);
+ /* TODO: figure out how to set no separator in GTK+ 3.0 */
+ /*
+ gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog),
+ FALSE);
+ */
+
/* Setup the outside spacing. */
- vbox = GTK_DIALOG(warn_close_dialog)->vbox;
+ vbox = gtk_dialog_get_content_area(GTK_DIALOG(warn_close_dialog));
gtk_box_set_spacing(GTK_BOX(vbox), 12);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 6);
@@ -8541,7 +8582,7 @@ notebook_init_grab(PidginWindow *gtkwin, GtkWidget *widget)
always be true after a button press. */
if (!gdk_pointer_is_grabbed())
#endif
- gdk_pointer_grab(gtkwin->notebook->window, FALSE,
+ gdk_pointer_grab(gtk_widget_get_window(gtkwin->notebook), FALSE,
GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
NULL, cursor, GDK_CURRENT_TIME);
}
@@ -8661,19 +8702,22 @@ infopane_press_cb(GtkWidget *widget, GdkEventButton *e, PidginConversation *gtkc
if (e->button == 1) {
int nb_x, nb_y;
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(gtkconv->infopane_hbox, &allocation);
+
if (gtkconv->win->in_drag)
return TRUE;
gtkconv->win->in_predrag = TRUE;
gtkconv->win->drag_tab = gtk_notebook_page_num(GTK_NOTEBOOK(gtkconv->win->notebook), gtkconv->tab_cont);
- gdk_window_get_origin(gtkconv->infopane_hbox->window, &nb_x, &nb_y);
+ gdk_window_get_origin(gtk_widget_get_window(gtkconv->infopane_hbox), &nb_x, &nb_y);
- gtkconv->win->drag_min_x = gtkconv->infopane_hbox->allocation.x + nb_x;
- gtkconv->win->drag_min_y = gtkconv->infopane_hbox->allocation.y + nb_y;
- gtkconv->win->drag_max_x = gtkconv->infopane_hbox->allocation.width + gtkconv->win->drag_min_x;
- gtkconv->win->drag_max_y = gtkconv->infopane_hbox->allocation.height + gtkconv->win->drag_min_y;
+ gtkconv->win->drag_min_x = allocation.x + nb_x;
+ gtkconv->win->drag_min_y = allocation.y + nb_y;
+ gtkconv->win->drag_max_x = allocation.width + gtkconv->win->drag_min_x;
+ gtkconv->win->drag_max_y = allocation.height + gtkconv->win->drag_min_y;
gtkconv->win->drag_motion_signal = g_signal_connect(G_OBJECT(gtkconv->win->notebook), "motion_notify_event",
G_CALLBACK(notebook_motion_cb), gtkconv->win);
@@ -8716,6 +8760,7 @@ notebook_press_cb(GtkWidget *widget, GdkEventButton *e, PidginWindow *win)
int tab_clicked;
GtkWidget *page;
GtkWidget *tab;
+ GtkAllocation allocation;
if (e->button == 2 && e->type == GDK_BUTTON_PRESS) {
PidginConversation *gtkconv;
@@ -8753,7 +8798,7 @@ notebook_press_cb(GtkWidget *widget, GdkEventButton *e, PidginWindow *win)
* Get the relative position of the press event, with regards to
* the position of the notebook.
*/
- gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y);
+ gdk_window_get_origin(gtk_widget_get_window(win->notebook), &nb_x, &nb_y);
/* Reset the min/max x/y */
win->drag_min_x = 0;
@@ -8765,10 +8810,12 @@ notebook_press_cb(GtkWidget *widget, GdkEventButton *e, PidginWindow *win)
page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked);
tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page);
- win->drag_min_x = tab->allocation.x + nb_x;
- win->drag_min_y = tab->allocation.y + nb_y;
- win->drag_max_x = tab->allocation.width + win->drag_min_x;
- win->drag_max_y = tab->allocation.height + win->drag_min_y;
+ gtk_widget_get_allocation(tab, &allocation);
+
+ win->drag_min_x = allocation.x + nb_x;
+ win->drag_min_y = allocation.y + nb_y;
+ win->drag_max_x = allocation.width + win->drag_min_x;
+ win->drag_max_y = allocation.height + win->drag_min_y;
/* Make sure the click occurred in the tab. */
if (e->x_root < win->drag_min_x ||
@@ -9005,12 +9052,15 @@ static void close_tab_cb(GtkWidget *w, GObject *menu)
close_conv_cb(NULL, gtkconv);
}
+/* TODO: I don't know if this doable in GTK+ 3.0 */
+#if 0
static gboolean
right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, PidginWindow *win)
{
- GtkWidget *item, *menu;
+ GtkWidget *item;
PidginConversation *gtkconv;
-
+ GtkWidget *menu = gtk_notebook_get_menu
+
if (event->type != GDK_BUTTON_PRESS || event->button != 3)
return FALSE;
@@ -9056,6 +9106,7 @@ right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, PidginWindow *
return FALSE;
}
+#endif
static void
remove_edit_entry(PidginConversation *gtkconv, GtkWidget *entry)
@@ -9077,7 +9128,7 @@ alias_focus_cb(GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
static gboolean
alias_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
{
- if (event->keyval == GDK_Escape) {
+ if (event->keyval == GDK_KEY_Escape) {
remove_edit_entry(user_data, widget);
return TRUE;
}
@@ -9122,7 +9173,7 @@ infopane_entry_activate(PidginConversation *gtkconv)
PurpleConversation *conv = gtkconv->active_conv;
const char *text = NULL;
- if (!GTK_WIDGET_VISIBLE(gtkconv->infopane)) {
+ if (!gtk_widget_get_visible(gtkconv->infopane)) {
/* There's already an entry for alias. Let's not create another one. */
return FALSE;
}
@@ -9284,14 +9335,14 @@ plugin_changed_cb(PurplePlugin *p, gpointer data)
static gboolean gtk_conv_configure_cb(GtkWidget *w, GdkEventConfigure *event, gpointer data) {
int x, y;
- if (GTK_WIDGET_VISIBLE(w))
+ if (gtk_widget_get_visible(w))
gtk_window_get_position(GTK_WINDOW(w), &x, &y);
else
return FALSE; /* carry on normally */
/* Workaround for GTK+ bug # 169811 - "configure_event" is fired
* when the window is being maximized */
- if (gdk_window_get_state(w->window) & GDK_WINDOW_STATE_MAXIMIZED)
+ if (gdk_window_get_state(gtk_widget_get_window(w)) & GDK_WINDOW_STATE_MAXIMIZED)
return FALSE;
/* don't save off-screen positioning */
@@ -9319,7 +9370,7 @@ pidgin_conv_set_position_size(PidginWindow *win, int conv_x, int conv_y,
/* if the window exists, is hidden, we're saving positions, and the
* position is sane... */
if (win && win->window &&
- !GTK_WIDGET_VISIBLE(win->window) && conv_width != 0) {
+ !gtk_widget_get_visible(win->window) && conv_width != 0) {
#ifdef _WIN32 /* only override window manager placement on Windows */
/* ...check position is on screen... */
@@ -9404,9 +9455,13 @@ pidgin_conv_window_new()
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE);
gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), TRUE);
+ /* TODO: figure out how to add custom stuff to the right-click menu in
+ GtkNotebook in GTK+ 3.0 */
+ /*
g_signal_connect(G_OBJECT(win->notebook), "button-press-event",
G_CALLBACK(right_click_menu_cb), win);
-
+ */
+
gtk_widget_show(win->notebook);
g_signal_connect(G_OBJECT(win->notebook), "switch_page",
@@ -9497,7 +9552,7 @@ pidgin_conv_window_hide(PidginWindow *win)
void
pidgin_conv_window_raise(PidginWindow *win)
{
- gdk_window_raise(GDK_WINDOW(win->window->window));
+ gdk_window_raise(GDK_WINDOW(gtk_widget_get_window(win->window)));
}
void
@@ -9672,7 +9727,7 @@ pidgin_conv_tab_pack(PidginWindow *win, PidginConversation *gtkconv)
g_signal_connect(G_OBJECT(ebox), "enter-notify-event",
G_CALLBACK(gtkconv_tab_set_tip), gtkconv);
- if (gtkconv->tab_label->parent == NULL) {
+ if (gtk_widget_get_parent(gtkconv->tab_label) == NULL) {
/* Pack if it's a new widget */
gtk_box_pack_start(GTK_BOX(gtkconv->tabby), first, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(gtkconv->tabby), gtkconv->tab_label, TRUE, TRUE, 0);
@@ -9693,9 +9748,8 @@ pidgin_conv_tab_pack(PidginWindow *win, PidginConversation *gtkconv)
gtk_notebook_set_tab_label(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, ebox);
}
- gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont,
- !tabs_side && !angle,
- TRUE, GTK_PACK_START);
+ g_object_set(G_OBJECT(win->notebook), "expand", !tabs_side && !angle,
+ "fill", TRUE, NULL);
if (pidgin_conv_window_get_gtkconv_count(win) == 1)
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook),
@@ -9807,7 +9861,7 @@ pidgin_conv_window_get_at_xy(int x, int y)
for (l = pidgin_conv_windows_get_list(); l != NULL; l = l->next) {
win = l->data;
- if (gdkwin == win->window->window)
+ if (gdkwin == gtk_widget_get_window(win->window))
return win;
}
@@ -9929,14 +9983,14 @@ conv_placement_last_created_win_type_configured_cb(GtkWidget *w,
PurpleConversationType type = purple_conversation_get_type(conv->active_conv);
GList *all;
- if (GTK_WIDGET_VISIBLE(w))
+ if (gtk_widget_get_visible(w))
gtk_window_get_position(GTK_WINDOW(w), &x, &y);
else
return FALSE; /* carry on normally */
/* Workaround for GTK+ bug # 169811 - "configure_event" is fired
* when the window is being maximized */
- if (gdk_window_get_state(w->window) & GDK_WINDOW_STATE_MAXIMIZED)
+ if (gdk_window_get_state(gtk_widget_get_window(w)) & GDK_WINDOW_STATE_MAXIMIZED)
return FALSE;
/* don't save off-screen positioning */
diff --git a/pidgin/gtkdebug.c b/pidgin/gtkdebug.c
index 88eff55526..c22765921f 100644
--- a/pidgin/gtkdebug.c
+++ b/pidgin/gtkdebug.c
@@ -128,7 +128,7 @@ debug_window_destroy(GtkWidget *w, GdkEvent *event, void *unused)
static gboolean
configure_cb(GtkWidget *w, GdkEventConfigure *event, DebugWindow *win)
{
- if (GTK_WIDGET_VISIBLE(w)) {
+ if (gtk_widget_get_visible(w)) {
purple_prefs_set_int(PIDGIN_PREFS_ROOT "/debug/width", event->width);
purple_prefs_set_int(PIDGIN_PREFS_ROOT "/debug/height", event->height);
}
@@ -622,8 +622,8 @@ regex_changed_cb(GtkWidget *w, DebugWindow *win) {
static void
regex_key_release_cb(GtkWidget *w, GdkEventKey *e, DebugWindow *win) {
- if(e->keyval == GDK_Return &&
- GTK_WIDGET_IS_SENSITIVE(win->filter) &&
+ if(e->keyval == GDK_KEY_Return &&
+ gtk_widget_is_sensitive(win->filter) &&
!gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter)))
{
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(win->filter), TRUE);
@@ -925,7 +925,7 @@ debug_window_new(void)
gtk_container_add(GTK_CONTAINER(item), gtk_label_new(_("Level ")));
gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
- win->filterlevel = gtk_combo_box_new_text();
+ win->filterlevel = gtk_combo_box_text_new();
item = gtk_tool_item_new();
#if GTK_CHECK_VERSION(2,12,0)
gtk_widget_set_tooltip_text(win->filterlevel, _("Select the debug filter level."));
@@ -935,12 +935,12 @@ debug_window_new(void)
gtk_container_add(GTK_CONTAINER(item), win->filterlevel);
gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
- gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("All"));
- gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Misc"));
- gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Info"));
- gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Warning"));
- gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Error "));
- gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Fatal Error"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(win->filterlevel), _("All"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(win->filterlevel), _("Misc"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(win->filterlevel), _("Info"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(win->filterlevel), _("Warning"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(win->filterlevel), _("Error "));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(win->filterlevel), _("Fatal Error"));
gtk_combo_box_set_active(GTK_COMBO_BOX(win->filterlevel),
purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/filterlevel"));
#ifdef USE_REGEX
diff --git a/pidgin/gtkdialogs.c b/pidgin/gtkdialogs.c
index 98c32d2b1d..f98d863f8a 100644
--- a/pidgin/gtkdialogs.c
+++ b/pidgin/gtkdialogs.c
@@ -452,7 +452,7 @@ pidgin_build_help_dialog(const char *title, const char *role, GString *string)
button = pidgin_dialog_add_button(GTK_DIALOG(win), GTK_STOCK_CLOSE,
G_CALLBACK(destroy_win), win);
- GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default(button, TRUE);
gtk_widget_grab_default(button);
gtk_widget_show_all(win);
@@ -899,12 +899,15 @@ pidgin_dialogs_ee(const char *ee)
gtk_container_set_border_width (GTK_CONTAINER(window), PIDGIN_HIG_BOX_SPACE);
gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
- gtk_dialog_set_has_separator(GTK_DIALOG(window), FALSE);
- gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(window)->vbox), PIDGIN_HIG_BORDER);
- gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(window)->vbox), PIDGIN_HIG_BOX_SPACE);
+ /* TODO: figure out how to set no separator in a dialog in GTK+ 3.0 */
+ /*gtk_dialog_set_has_separator(GTK_DIALOG(window), FALSE);*/
+ gtk_box_set_spacing(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(window))),
+ PIDGIN_HIG_BORDER);
+ gtk_container_set_border_width (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(window))),
+ PIDGIN_HIG_BOX_SPACE);
hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER);
- gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), hbox);
+ gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(window))), hbox);
img = gtk_image_new_from_stock(PIDGIN_STOCK_DIALOG_COOL, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_HUGE));
gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
diff --git a/pidgin/gtkdialogs.h b/pidgin/gtkdialogs.h
index ed87bac54e..3603fb3227 100644
--- a/pidgin/gtkdialogs.h
+++ b/pidgin/gtkdialogs.h
@@ -66,6 +66,6 @@ void pidgin_dialogs_merge_groups(PurpleGroup *, const char *);
gtk_window_set_type_hint(GTK_WINDOW(x), GDK_WINDOW_TYPE_HINT_DIALOG)
#endif
-#define PIDGIN_WINDOW_ICONIFIED(x) (gdk_window_get_state(GTK_WIDGET(x)->window) & GDK_WINDOW_STATE_ICONIFIED)
+#define PIDGIN_WINDOW_ICONIFIED(x) (gdk_window_get_state(gtk_widget_get_window(GTK_WIDGET(x))) & GDK_WINDOW_STATE_ICONIFIED)
#endif /* _PIDGINDIALOGS_H_ */
diff --git a/pidgin/gtkdnd-hints.c b/pidgin/gtkdnd-hints.c
index faed31c511..7304ac6eda 100644
--- a/pidgin/gtkdnd-hints.c
+++ b/pidgin/gtkdnd-hints.c
@@ -57,28 +57,34 @@ static HintWindowInfo hint_windows[] = {
static GtkWidget *
dnd_hints_init_window(const gchar *fname)
{
+ /* TODO: this is likely very broken right now, I think this needs to be
+ Cairo-ified */
GdkPixbuf *pixbuf;
- GdkPixmap *pixmap;
- GdkBitmap *bitmap;
+ /*GdkPixmap *pixmap;*/
+ /*GdkBitmap *bitmap;*/
GtkWidget *pix;
GtkWidget *win;
pixbuf = gdk_pixbuf_new_from_file(fname, NULL);
g_return_val_if_fail(pixbuf, NULL);
+ /*
gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, &bitmap, 128);
g_object_unref(G_OBJECT(pixbuf));
-
- gtk_widget_push_colormap(gdk_rgb_get_colormap());
+ */
+
+ /*gtk_widget_push_colormap(gdk_rgb_get_colormap());*/
win = gtk_window_new(GTK_WINDOW_POPUP);
- pix = gtk_image_new_from_pixmap(pixmap, bitmap);
+ pix = gtk_image_new_from_pixbuf(pixbuf);
gtk_container_add(GTK_CONTAINER(win), pix);
- gtk_widget_shape_combine_mask(win, bitmap, 0, 0);
- gtk_widget_pop_colormap();
+ /*gtk_widget_shape_combine_mask(win, bitmap, 0, 0);
+ gtk_widget_pop_colormap();*/
+ /*
g_object_unref(G_OBJECT(pixmap));
g_object_unref(G_OBJECT(bitmap));
-
+ */
+
gtk_widget_show_all(pix);
return win;
@@ -88,17 +94,22 @@ static void
get_widget_coords(GtkWidget *w, gint *x1, gint *y1, gint *x2, gint *y2)
{
gint ox, oy, width, height;
-
- if (w->parent && w->parent->window == w->window)
+ GtkWidget *parent = gtk_widget_get_parent(w);
+
+ if (parent && gtk_widget_get_window(parent) == gtk_widget_get_window(w))
{
- get_widget_coords(w->parent, &ox, &oy, NULL, NULL);
- height = w->allocation.height;
- width = w->allocation.width;
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation(w, &allocation);
+ get_widget_coords(parent, &ox, &oy, NULL, NULL);
+ height = allocation.height;
+ width = allocation.width;
}
else
{
- gdk_window_get_origin(w->window, &ox, &oy);
- gdk_drawable_get_size(w->window, &width, &height);
+ gdk_window_get_origin(gtk_widget_get_window(w), &ox, &oy);
+ width = gdk_window_get_width(gtk_widget_get_window(w));
+ height = gdk_window_get_height(gtk_widget_get_window(w));
}
if (x1) *x1 = ox;
@@ -171,10 +182,13 @@ dnd_hints_show_relative(DndHintWindowId id, GtkWidget *widget,
{
gint x1, x2, y1, y2;
gint x = 0, y = 0;
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation(widget, &allocation);
get_widget_coords(widget, &x1, &y1, &x2, &y2);
- x1 += widget->allocation.x; x2 += widget->allocation.x;
- y1 += widget->allocation.y; y2 += widget->allocation.y;
+ x1 += allocation.x; x2 += allocation.x;
+ y1 += allocation.y; y2 += allocation.y;
switch (horiz)
{
diff --git a/pidgin/gtkdocklet-gtk.c b/pidgin/gtkdocklet-gtk.c
index ad3c290017..1b9ed3c8f6 100644
--- a/pidgin/gtkdocklet-gtk.c
+++ b/pidgin/gtkdocklet-gtk.c
@@ -51,7 +51,10 @@ static void
docklet_gtk_status_update_icon(PurpleStatusPrimitive status, gboolean connecting, gboolean pending)
{
const gchar *icon_name = NULL;
+ gboolean blinking;
+ g_object_get(G_OBJECT(docklet), "blinking", &blinking, NULL);
+
switch (status) {
case PURPLE_STATUS_OFFLINE:
icon_name = PIDGIN_STOCK_TRAY_OFFLINE;
@@ -83,9 +86,9 @@ docklet_gtk_status_update_icon(PurpleStatusPrimitive status, gboolean connecting
}
if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/blink")) {
- gtk_status_icon_set_blinking(docklet, (pending && !connecting));
- } else if (gtk_status_icon_get_blinking(docklet)) {
- gtk_status_icon_set_blinking(docklet, FALSE);
+ g_object_set(G_OBJECT(docklet), "blinking", pending && !connecting, NULL);
+ } else if (blinking) {
+ g_object_set(G_OBJECT(docklet), "blinking", FALSE, NULL);
}
}
@@ -93,9 +96,9 @@ static void
docklet_gtk_status_set_tooltip(gchar *tooltip)
{
if (tooltip) {
- gtk_status_icon_set_tooltip(docklet, tooltip);
+ gtk_status_icon_set_tooltip_text(docklet, tooltip);
} else {
- gtk_status_icon_set_tooltip(docklet, NULL);
+ gtk_status_icon_set_tooltip_text(docklet, NULL);
}
}
diff --git a/pidgin/gtkdocklet.c b/pidgin/gtkdocklet.c
index 3ab5801a75..f56a67cf91 100644
--- a/pidgin/gtkdocklet.c
+++ b/pidgin/gtkdocklet.c
@@ -315,19 +315,21 @@ docklet_show_pref_changed_cb(const char *name, PurplePrefType type,
static void
docklet_toggle_mute(GtkWidget *toggle, void *data)
{
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/sound/mute", GTK_CHECK_MENU_ITEM(toggle)->active);
+ purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/sound/mute",
+ gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(toggle)));
}
static void
docklet_toggle_blink(GtkWidget *toggle, void *data)
{
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/docklet/blink", GTK_CHECK_MENU_ITEM(toggle)->active);
+ purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/docklet/blink",
+ gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(toggle)));
}
static void
docklet_toggle_blist(GtkWidget *toggle, void *data)
{
- purple_blist_set_visible(GTK_CHECK_MENU_ITEM(toggle)->active);
+ purple_blist_set_visible(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(toggle)));
}
#ifdef _WIN32
@@ -593,7 +595,7 @@ docklet_status_submenu(void)
static void
-plugin_act(GtkObject *obj, PurplePluginAction *pam)
+plugin_act(GtkWidget *widget, PurplePluginAction *pam)
{
if (pam && pam->callback)
pam->callback(pam);
diff --git a/pidgin/gtkidle.c b/pidgin/gtkidle.c
index f5cf624b97..51d821f66f 100644
--- a/pidgin/gtkidle.c
+++ b/pidgin/gtkidle.c
@@ -107,14 +107,16 @@ pidgin_get_time_idle(void)
int event_base, error_base;
if (has_extension == -1)
- has_extension = XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base, &error_base);
+ has_extension = XScreenSaverQueryExtension(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
+ &event_base, &error_base);
if (has_extension)
{
if (mit_info == NULL)
mit_info = XScreenSaverAllocInfo();
- XScreenSaverQueryInfo(GDK_DISPLAY(), GDK_ROOT_WINDOW(), mit_info);
+ XScreenSaverQueryInfo(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
+ GDK_ROOT_WINDOW(), mit_info);
return (mit_info->idle) / 1000;
}
else
diff --git a/pidgin/gtkimhtml.c b/pidgin/gtkimhtml.c
index 73acb45007..3aac3e1685 100644
--- a/pidgin/gtkimhtml.c
+++ b/pidgin/gtkimhtml.c
@@ -410,7 +410,7 @@ static void gtk_imhtml_size_allocate(GtkWidget *widget, GtkAllocation *alloc)
/* Don't scroll here if we're in the middle of a smooth scroll */
if (scroll && imhtml->scroll_time == NULL &&
- GTK_WIDGET_REALIZED(imhtml))
+ gtk_widget_get_realized(GTK_WIDGET(imhtml)))
gtk_imhtml_scroll_to_end(imhtml, FALSE);
}
@@ -499,18 +499,22 @@ static gint
gtk_imhtml_tip_paint (GtkIMHtml *imhtml)
{
PangoLayout *layout;
+ cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(imhtml->tip_window));
g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE);
layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip);
- gtk_paint_flat_box (imhtml->tip_window->style, imhtml->tip_window->window,
- GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, imhtml->tip_window,
+ gtk_paint_flat_box (gtk_widget_get_style(imhtml->tip_window),
+ cr,
+ GTK_STATE_NORMAL, GTK_SHADOW_OUT, imhtml->tip_window,
"tooltip", 0, 0, -1, -1);
- gtk_paint_layout (imhtml->tip_window->style, imhtml->tip_window->window, GTK_STATE_NORMAL,
- FALSE, NULL, imhtml->tip_window, NULL, 4, 4, layout);
+ gtk_paint_layout (gtk_widget_get_style(imhtml->tip_window),
+ cr,
+ GTK_STATE_NORMAL, TRUE, imhtml->tip_window, NULL, 4, 4, layout);
+ cairo_destroy(cr);
g_object_unref(layout);
return FALSE;
}
@@ -522,12 +526,15 @@ gtk_imhtml_tip (gpointer data)
PangoFontMetrics *font_metrics;
PangoLayout *layout;
PangoFont *font;
-
+ GtkStyle *style = gtk_widget_get_style(imhtml->tip_window);
+ GtkAllocation allocation;
gint gap, x, y, h, w, scr_w, baseline_skip;
g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE);
- if (!imhtml->tip || !GTK_WIDGET_DRAWABLE (GTK_WIDGET(imhtml))) {
+ gtk_widget_get_allocation(GTK_WIDGET(imhtml), &allocation);
+
+ if (!imhtml->tip || !gtk_widget_is_drawable(GTK_WIDGET(imhtml))) {
imhtml->tip_timer = 0;
return FALSE;
}
@@ -551,11 +558,10 @@ gtk_imhtml_tip (gpointer data)
gtk_widget_ensure_style (imhtml->tip_window);
layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip);
font = pango_context_load_font(pango_layout_get_context(layout),
- imhtml->tip_window->style->font_desc);
+ style->font_desc);
if (font == NULL) {
- char *tmp = pango_font_description_to_string(
- imhtml->tip_window->style->font_desc);
+ char *tmp = pango_font_description_to_string(style->font_desc);
purple_debug(PURPLE_DEBUG_ERROR, "gtk_imhtml_tip",
"pango_context_load_font() couldn't load font: '%s'\n",
@@ -580,8 +586,8 @@ gtk_imhtml_tip (gpointer data)
h = 8 + baseline_skip;
gdk_window_get_pointer (NULL, &x, &y, NULL);
- if (GTK_WIDGET_NO_WINDOW (GTK_WIDGET(imhtml)))
- y += GTK_WIDGET(imhtml)->allocation.y;
+ if ((!gtk_widget_get_has_window(GTK_WIDGET(imhtml))))
+ y += allocation.y;
scr_w = gdk_screen_width();
@@ -621,7 +627,7 @@ gtk_motion_event_notify(GtkWidget *imhtml, GdkEventMotion *event, gpointer data)
oldprelit_tag = GTK_IMHTML(imhtml)->prelit_tag;
- gdk_window_get_pointer(GTK_WIDGET(imhtml)->window, NULL, NULL, NULL);
+ gdk_window_get_pointer(gtk_widget_get_window(GTK_WIDGET(imhtml)), NULL, NULL, NULL);
gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml), GTK_TEXT_WINDOW_WIDGET,
event->x, event->y, &x, &y);
gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, x, y);
@@ -749,6 +755,8 @@ gtk_leave_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data
return FALSE;
}
+/* TODO: I think this can be removed for GTK+ 3.0... */
+#if 0
static gint
gtk_imhtml_expose_event (GtkWidget *widget,
GdkEventExpose *event)
@@ -776,7 +784,8 @@ gtk_imhtml_expose_event (GtkWidget *widget,
gdk_color_parse(GTK_IMHTML(widget)->edit.background, &gcolor);
gdk_cairo_set_source_color(cr, &gcolor);
} else {
- gdk_cairo_set_source_color(cr, &(widget->style->base[GTK_WIDGET_STATE(widget)]));
+ gdk_cairo_set_source_color(cr,
+ &(gtk_widget_get_style(widget)->base[gtk_widget_get_state(widget)]));
}
cairo_rectangle(cr,
@@ -882,6 +891,7 @@ gtk_imhtml_expose_event (GtkWidget *widget,
return FALSE;
}
+#endif
static void paste_unformatted_cb(GtkMenuItem *menu, GtkIMHtml *imhtml)
@@ -1158,11 +1168,12 @@ static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *select
{
char *text;
GtkIMHtml *imhtml = data;
-
+ gint length = gtk_selection_data_get_length(selection_data);
+
if (!gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml)))
return;
- if (imhtml->wbfo || selection_data->length <= 0) {
+ if (imhtml->wbfo || length <= 0) {
gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml);
return;
} else {
@@ -1186,13 +1197,13 @@ static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *select
}
#endif
- text = g_malloc(selection_data->length + 1);
- memcpy(text, selection_data->data, selection_data->length);
+ text = g_malloc(length + 1);
+ memcpy(text, gtk_selection_data_get_data(selection_data), length);
/* Make sure the paste data is null-terminated. Given that
* we're passed length (but assume later that it is
* null-terminated), this seems sensible to me.
*/
- text[selection_data->length] = '\0';
+ text[length] = '\0';
}
#ifdef _WIN32
@@ -1203,10 +1214,10 @@ static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *select
}
#endif
- if (selection_data->length >= 2 &&
+ if (length >= 2 &&
(*(guint16 *)text == 0xfeff || *(guint16 *)text == 0xfffe)) {
/* This is UTF-16 */
- char *utf8 = utf16_to_utf8_with_bom_check(text, selection_data->length);
+ char *utf8 = utf16_to_utf8_with_bom_check(text, length);
g_free(text);
text = utf8;
if (!text) {
@@ -1567,7 +1578,8 @@ static void gtk_imhtml_class_init (GtkIMHtmlClass *klass)
gobject_class->finalize = gtk_imhtml_finalize;
widget_class->drag_motion = gtk_text_view_drag_motion;
- widget_class->expose_event = gtk_imhtml_expose_event;
+ /* TODO: I _think_ this should be removed for GTK+ 3.0 */
+ /*widget_class->expose_event = gtk_imhtml_expose_event;*/
parent_size_allocate = widget_class->size_allocate;
widget_class->size_allocate = gtk_imhtml_size_allocate;
parent_style_set = widget_class->style_set;
@@ -1629,20 +1641,20 @@ static void gtk_imhtml_class_init (GtkIMHtmlClass *klass)
TRUE, G_PARAM_READABLE));
binding_set = gtk_binding_set_by_class (parent_class);
- gtk_binding_entry_add_signal (binding_set, GDK_b, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_BOLD);
- gtk_binding_entry_add_signal (binding_set, GDK_i, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_ITALIC);
- gtk_binding_entry_add_signal (binding_set, GDK_u, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_UNDERLINE);
- gtk_binding_entry_add_signal (binding_set, GDK_plus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW);
- gtk_binding_entry_add_signal (binding_set, GDK_equal, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW);
- gtk_binding_entry_add_signal (binding_set, GDK_minus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_SHRINK);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_b, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_BOLD);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_i, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_ITALIC);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_u, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_UNDERLINE);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_plus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_equal, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_minus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_SHRINK);
binding_set = gtk_binding_set_by_class(klass);
- gtk_binding_entry_add_signal (binding_set, GDK_r, GDK_CONTROL_MASK, "format_function_clear", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_KP_Enter, 0, "message_send", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_Return, 0, "message_send", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_z, GDK_CONTROL_MASK, "undo", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_z, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "redo", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_F14, 0, "undo", 0);
- gtk_binding_entry_add_signal(binding_set, GDK_v, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "paste", 1, G_TYPE_STRING, "text");
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_r, GDK_CONTROL_MASK, "format_function_clear", 0);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, 0, "message_send", 0);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Return, 0, "message_send", 0);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_z, GDK_CONTROL_MASK, "undo", 0);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_z, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "redo", 0);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_F14, 0, "undo", 0);
+ gtk_binding_entry_add_signal(binding_set, GDK_KEY_v, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "paste", 1, G_TYPE_STRING, "text");
}
static void gtk_imhtml_init (GtkIMHtml *imhtml)
@@ -1869,13 +1881,13 @@ gtk_text_view_drag_motion (GtkWidget *widget,
/* can't accept any of the offered targets */
} else {
GtkWidget *source_widget;
- suggested_action = context->suggested_action;
+ suggested_action = gdk_drag_context_get_suggested_action(context);
source_widget = gtk_drag_get_source_widget (context);
if (source_widget == widget) {
/* Default to MOVE, unless the user has
* pressed ctrl or alt to affect available actions
*/
- if ((context->actions & GDK_ACTION_MOVE) != 0)
+ if ((gdk_drag_context_get_actions(context) & GDK_ACTION_MOVE) != 0)
suggested_action = GDK_ACTION_MOVE;
}
}
@@ -1907,20 +1919,21 @@ gtk_imhtml_link_drag_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guin
{
gchar **links;
gchar *link;
- char *text = (char *)sd->data;
+ char *text = (char *) gtk_selection_data_get_data(sd);
GtkTextMark *mark = gtk_text_buffer_get_insert(imhtml->text_buffer);
GtkTextIter iter;
gint i = 0;
+ gint length = gtk_selection_data_get_length(sd);
gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark);
- if(gtk_imhtml_get_editable(imhtml) && sd->data){
+ if(gtk_imhtml_get_editable(imhtml) && text){
switch (info) {
case GTK_IMHTML_DRAG_URL:
/* TODO: Is it really ok to change sd->data...? */
- purple_str_strip_char((char *)sd->data, '\r');
+ purple_str_strip_char(text, '\r');
- links = g_strsplit((char *)sd->data, "\n", 0);
+ links = g_strsplit(text, "\n", 0);
while((link = links[i]) != NULL){
if (gtk_imhtml_is_protocol(link)) {
gchar *label;
@@ -1959,8 +1972,8 @@ gtk_imhtml_link_drag_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guin
* See also the comment on text/html here:
* http://mail.gnome.org/archives/gtk-devel-list/2001-September/msg00114.html
*/
- if (sd->length >= 2 && !g_utf8_validate(text, sd->length - 1, NULL)) {
- utf8 = utf16_to_utf8_with_bom_check(text, sd->length);
+ if (length >= 2 && !g_utf8_validate(text, length - 1, NULL)) {
+ utf8 = utf16_to_utf8_with_bom_check(text, length);
if (!utf8) {
purple_debug_warning("gtkimhtml", "g_convert from UTF-16 failed in drag_rcv_cb\n");
@@ -1989,7 +2002,8 @@ gtk_imhtml_link_drag_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guin
gtk_drag_finish(dc, FALSE, FALSE, t);
return;
}
- gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t);
+ gtk_drag_finish(dc, TRUE,
+ (gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE), t);
} else {
gtk_drag_finish(dc, FALSE, FALSE, t);
}
@@ -2520,8 +2534,8 @@ void gtk_imhtml_append_text_with_images (GtkIMHtml *imhtml,
static gboolean smooth_scroll_cb(gpointer data)
{
GtkIMHtml *imhtml = data;
- GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment;
- gdouble max_val = adj->upper - adj->page_size;
+ GtkAdjustment *adj = gtk_text_view_get_vadjustment(GTK_TEXT_VIEW(imhtml));
+ gdouble max_val = gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj);
gdouble scroll_val = gtk_adjustment_get_value(adj) + ((max_val - gtk_adjustment_get_value(adj)) / 3);
g_return_val_if_fail(imhtml->scroll_time != NULL, FALSE);
@@ -2544,9 +2558,10 @@ static gboolean smooth_scroll_cb(gpointer data)
static gboolean scroll_idle_cb(gpointer data)
{
GtkIMHtml *imhtml = data;
- GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment;
+ GtkAdjustment *adj = gtk_text_view_get_vadjustment(GTK_TEXT_VIEW(imhtml));
if(adj) {
- gtk_adjustment_set_value(adj, adj->upper - adj->page_size);
+ gtk_adjustment_set_value(adj, gtk_adjustment_get_upper(adj) -
+ gtk_adjustment_get_page_size(adj));
}
imhtml->scroll_src = 0;
return FALSE;
@@ -4186,9 +4201,14 @@ static void remove_tag_by_prefix(GtkIMHtml *imhtml, const GtkTextIter *i, const
for (l = tags; l; l = l->next) {
GtkTextTag *tag = l->data;
+ gchar *name;
- if (tag->name && !strncmp(tag->name, prefix, len))
+ g_object_get(G_OBJECT(tag), "name", &name, NULL);
+
+ if (name && !strncmp(name, prefix, len))
gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, i, e);
+
+ g_free(name);
}
g_slist_free(tags);
@@ -4204,10 +4224,15 @@ static void remove_tag_by_prefix(GtkIMHtml *imhtml, const GtkTextIter *i, const
for (l = tags; l; l = l->next) {
GtkTextTag *tag = l->data;
+ gchar *name;
+
+ g_object_get(G_OBJECT(tag), "name", &name, NULL);
- if (tag->name && !strncmp(tag->name, prefix, len))
+ if (name && !strncmp(name, prefix, len))
gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, &iter, e);
- }
+
+ g_free(name);
+ }
g_slist_free(tags);
}
@@ -4327,11 +4352,16 @@ static void delete_cb(GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *en
gtk_text_iter_begins_tag(start, tag) && /* the tag starts with the selection */
(!gtk_text_iter_has_tag(end, tag) || /* the tag ends within the selection */
gtk_text_iter_ends_tag(end, tag))) {
+ gchar *name;
+
+ g_object_get(G_OBJECT(tag), "name", &name, NULL);
gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, start, end);
- if (tag->name &&
- strncmp(tag->name, "LINK ", 5) == 0 && imhtml->edit.link) {
+
+ if (name && strncmp(name, "LINK ", 5) == 0 && imhtml->edit.link) {
gtk_imhtml_toggle_link(imhtml, NULL);
}
+
+ g_free(name);
}
}
g_slist_free(tags);
@@ -4553,27 +4583,32 @@ static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *m
for (l = tags; l != NULL; l = l->next) {
GtkTextTag *tag = GTK_TEXT_TAG(l->data);
+ gchar *name;
- if (tag->name) {
- if (strcmp(tag->name, "BOLD") == 0)
+ g_object_get(G_OBJECT(tag), "name", &name, NULL);
+
+ if (name) {
+ if (strcmp(name, "BOLD") == 0)
imhtml->edit.bold = TRUE;
- else if (strcmp(tag->name, "ITALICS") == 0)
+ else if (strcmp(name, "ITALICS") == 0)
imhtml->edit.italic = TRUE;
- else if (strcmp(tag->name, "UNDERLINE") == 0)
+ else if (strcmp(name, "UNDERLINE") == 0)
imhtml->edit.underline = TRUE;
- else if (strcmp(tag->name, "STRIKE") == 0)
+ else if (strcmp(name, "STRIKE") == 0)
imhtml->edit.strike = TRUE;
- else if (strncmp(tag->name, "FORECOLOR ", 10) == 0)
- imhtml->edit.forecolor = g_strdup(&(tag->name)[10]);
- else if (strncmp(tag->name, "BACKCOLOR ", 10) == 0)
- imhtml->edit.backcolor = g_strdup(&(tag->name)[10]);
- else if (strncmp(tag->name, "FONT FACE ", 10) == 0)
- imhtml->edit.fontface = g_strdup(&(tag->name)[10]);
- else if (strncmp(tag->name, "FONT SIZE ", 10) == 0)
- imhtml->edit.fontsize = strtol(&(tag->name)[10], NULL, 10);
- else if ((strncmp(tag->name, "LINK ", 5) == 0) && !gtk_text_iter_is_end(&iter))
+ else if (strncmp(name, "FORECOLOR ", 10) == 0)
+ imhtml->edit.forecolor = g_strdup(&(name)[10]);
+ else if (strncmp(name, "BACKCOLOR ", 10) == 0)
+ imhtml->edit.backcolor = g_strdup(&(name)[10]);
+ else if (strncmp(name, "FONT FACE ", 10) == 0)
+ imhtml->edit.fontface = g_strdup(&(name)[10]);
+ else if (strncmp(name, "FONT SIZE ", 10) == 0)
+ imhtml->edit.fontsize = strtol(&(name)[10], NULL, 10);
+ else if ((strncmp(name, "LINK ", 5) == 0) && !gtk_text_iter_is_end(&iter))
imhtml->edit.link = tag;
}
+
+ g_free(name);
}
g_slist_free(tags);
@@ -4864,6 +4899,8 @@ void gtk_imhtml_insert_smiley(GtkIMHtml *imhtml, const char *sml, char *smiley)
gtk_text_buffer_end_user_action(imhtml->text_buffer);
}
+/* TODO: I think this can be removed for GTK+ 3.0... */
+#if 0
static gboolean
image_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
{
@@ -4871,9 +4908,10 @@ image_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
return TRUE;
}
+#endif
/* In case the smiley gets removed from the imhtml before it gets removed from the queue */
-static void animated_smiley_destroy_cb(GtkObject *widget, GtkIMHtml *imhtml)
+static void animated_smiley_destroy_cb(GtkWidget *widget, GtkIMHtml *imhtml)
{
GList *l = imhtml->animations->head;
while (l) {
@@ -4966,8 +5004,10 @@ void gtk_imhtml_insert_smiley_at_iter(GtkIMHtml *imhtml, const char *sml, char *
* images, and ensures that they are handled by the image
* itself, without propagating to the textview and causing
* a complete refresh */
+ /* TODO: I think this should be removed for GTK+ 3.0?
g_signal_connect(G_OBJECT(icon), "expose-event", G_CALLBACK(image_expose), NULL);
-
+ */
+
gtk_widget_show(icon);
if (ebox)
gtk_container_add(GTK_CONTAINER(ebox), icon);
@@ -5068,23 +5108,30 @@ void gtk_imhtml_insert_image_at_iter(GtkIMHtml *imhtml, int id, GtkTextIter *ite
static const gchar *tag_to_html_start(GtkTextTag *tag)
{
- const gchar *name;
static gchar buf[1024];
+ gchar *name;
- name = tag->name;
+ g_object_get(G_OBJECT(tag), "name", &name, NULL);
g_return_val_if_fail(name != NULL, "");
if (strcmp(name, "BOLD") == 0) {
+ g_free(name);
return "";
} else if (strcmp(name, "ITALICS") == 0) {
+ g_free(name);
return "";
} else if (strcmp(name, "UNDERLINE") == 0) {
- return "";
+ g_free(name);
+ return "";
} else if (strcmp(name, "STRIKE") == 0) {
- return "
";
+ g_free(name);
+ return "";
} else if (strncmp(name, "LINK ", 5) == 0) {
char *tmp = g_object_get_data(G_OBJECT(tag), "link_url");
- if (tmp) {
+
+ g_free(name);
+
+ if (tmp) {
g_snprintf(buf, sizeof(buf), "", tmp);
buf[sizeof(buf)-1] = '\0';
return buf;
@@ -5093,19 +5140,30 @@ static const gchar *tag_to_html_start(GtkTextTag *tag)
}
} else if (strncmp(name, "FORECOLOR ", 10) == 0) {
g_snprintf(buf, sizeof(buf), "", &name[10]);
- return buf;
+
+ g_free(name);
+
+ return buf;
} else if (strncmp(name, "BACKCOLOR ", 10) == 0) {
g_snprintf(buf, sizeof(buf), "", &name[10]);
- return buf;
+ g_free(name);
+
+ return buf;
} else if (strncmp(name, "BACKGROUND ", 10) == 0) {
g_snprintf(buf, sizeof(buf), "", &name[11]);
- return buf;
+ g_free(name);
+
+ return buf;
} else if (strncmp(name, "FONT FACE ", 10) == 0) {
g_snprintf(buf, sizeof(buf), "", &name[10]);
- return buf;
+ g_free(name);
+
+ return buf;
} else if (strncmp(name, "FONT SIZE ", 10) == 0) {
g_snprintf(buf, sizeof(buf), "", &name[10]);
- return buf;
+ g_free(name);
+
+ return buf;
} else {
char *str = buf;
gboolean isset;
@@ -5167,38 +5225,49 @@ static const gchar *tag_to_html_start(GtkTextTag *tag)
}
g_snprintf(str, sizeof(buf) - (str - buf), "'>");
-
+ g_free(name);
+
return (empty ? "" : buf);
}
}
static const gchar *tag_to_html_end(GtkTextTag *tag)
{
- const gchar *name;
+ gchar *name;
- name = tag->name;
+ g_object_get(G_OBJECT(tag), "name", &name, NULL);
g_return_val_if_fail(name != NULL, "");
if (strcmp(name, "BOLD") == 0) {
+ g_free(name);
return "";
} else if (strcmp(name, "ITALICS") == 0) {
- return "";
+ g_free(name);
+ return "";
} else if (strcmp(name, "UNDERLINE") == 0) {
- return "";
+ g_free(name);
+ return "";
} else if (strcmp(name, "STRIKE") == 0) {
- return "";
+ g_free(name);
+ return "";
} else if (strncmp(name, "LINK ", 5) == 0) {
- return "";
+ g_free(name);
+ return "";
} else if (strncmp(name, "FORECOLOR ", 10) == 0) {
- return "";
+ g_free(name);
+ return "";
} else if (strncmp(name, "BACKCOLOR ", 10) == 0) {
- return "";
+ g_free(name);
+ return "";
} else if (strncmp(name, "BACKGROUND ", 10) == 0) {
- return "";
+ g_free(name);
+ return "
" : "",
*body ? body : "",
@@ -643,7 +647,8 @@ signing_on_cb(PurpleConnection *gc)
if (!console)
return;
- gtk_combo_box_append_text(GTK_COMBO_BOX(console->dropdown), purple_account_get_username(gc->account));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(console->dropdown),
+ purple_account_get_username(gc->account));
console->accounts = g_list_append(console->accounts, gc);
console->count++;
@@ -674,7 +679,7 @@ signed_off_cb(PurpleConnection *gc)
if (l == NULL)
return;
- gtk_combo_box_remove_text(GTK_COMBO_BOX(console->dropdown), i);
+ gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(console->dropdown), i);
console->accounts = g_list_remove(console->accounts, gc);
console->count--;
@@ -716,7 +721,7 @@ plugin_unload(PurplePlugin *plugin)
}
static void
-console_destroy(GtkObject *window, gpointer nul)
+console_destroy(GtkWidget *window, gpointer nul)
{
g_list_free(console->accounts);
g_free(console);
@@ -731,8 +736,9 @@ dropdown_changed_cb(GtkComboBox *widget, gpointer nul)
if (!console)
return;
- account = purple_accounts_find(gtk_combo_box_get_active_text(GTK_COMBO_BOX(console->dropdown)),
- "prpl-jabber");
+ account =
+ purple_accounts_find(gtk_combo_box_text_get_active_text(
+ GTK_COMBO_BOX_TEXT(console->dropdown)), "prpl-jabber");
if (!account || !account->gc)
return;
@@ -768,13 +774,13 @@ create_console(PurplePluginAction *action)
label = gtk_label_new(_("Account: "));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_box_pack_start(GTK_BOX(console->hbox), label, FALSE, FALSE, 0);
- console->dropdown = gtk_combo_box_new_text();
+ console->dropdown = gtk_combo_box_text_new();
for (connections = purple_connections_get_all(); connections; connections = connections->next) {
PurpleConnection *gc = connections->data;
if (!strcmp(purple_account_get_protocol_id(purple_connection_get_account(gc)), "prpl-jabber")) {
console->count++;
console->accounts = g_list_append(console->accounts, gc);
- gtk_combo_box_append_text(GTK_COMBO_BOX(console->dropdown),
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(console->dropdown),
purple_account_get_username(purple_connection_get_account(gc)));
if (!console->gc)
console->gc = gc;
--
cgit v1.2.1
From 00486005894ae3beea7506405682ee631627fce0 Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Sun, 28 Nov 2010 20:36:20 +0000
Subject: GtkDocklet doesn't have a blinking property anymore, so remove this
option...
---
pidgin/gtkdocklet-gtk.c | 9 ---------
pidgin/gtkdocklet.c | 18 ------------------
2 files changed, 27 deletions(-)
diff --git a/pidgin/gtkdocklet-gtk.c b/pidgin/gtkdocklet-gtk.c
index 1b9ed3c8f6..5885763db7 100644
--- a/pidgin/gtkdocklet-gtk.c
+++ b/pidgin/gtkdocklet-gtk.c
@@ -51,9 +51,6 @@ static void
docklet_gtk_status_update_icon(PurpleStatusPrimitive status, gboolean connecting, gboolean pending)
{
const gchar *icon_name = NULL;
- gboolean blinking;
-
- g_object_get(G_OBJECT(docklet), "blinking", &blinking, NULL);
switch (status) {
case PURPLE_STATUS_OFFLINE:
@@ -84,12 +81,6 @@ docklet_gtk_status_update_icon(PurpleStatusPrimitive status, gboolean connecting
if (icon_name) {
gtk_status_icon_set_from_icon_name(docklet, icon_name);
}
-
- if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/blink")) {
- g_object_set(G_OBJECT(docklet), "blinking", pending && !connecting, NULL);
- } else if (blinking) {
- g_object_set(G_OBJECT(docklet), "blinking", FALSE, NULL);
- }
}
static void
diff --git a/pidgin/gtkdocklet.c b/pidgin/gtkdocklet.c
index f56a67cf91..48f6c02242 100644
--- a/pidgin/gtkdocklet.c
+++ b/pidgin/gtkdocklet.c
@@ -210,12 +210,6 @@ docklet_update_status(void)
connecting = newconnecting;
pidgin_docklet_update_icon();
-
- /* and schedule the blinker function if messages are pending */
- if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/blink")
- && pending && !connecting && docklet_blinking_timer == 0) {
- docklet_blinking_timer = g_timeout_add(500, docklet_blink_icon, NULL);
- }
}
return FALSE; /* for when we're called by the glib idle handler */
@@ -319,13 +313,6 @@ docklet_toggle_mute(GtkWidget *toggle, void *data)
gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(toggle)));
}
-static void
-docklet_toggle_blink(GtkWidget *toggle, void *data)
-{
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/docklet/blink",
- gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(toggle)));
-}
-
static void
docklet_toggle_blist(GtkWidget *toggle, void *data)
{
@@ -736,11 +723,6 @@ docklet_menu(void)
g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_mute), NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
- menuitem = gtk_check_menu_item_new_with_mnemonic(_("_Blink on New Message"));
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/blink"));
- g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_blink), NULL);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
-
pidgin_separator(menu);
/* add plugin actions */
--
cgit v1.2.1
From a4539a6582d6a0c25b8774a67897fb6181e105e6 Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Sun, 28 Nov 2010 20:48:38 +0000
Subject: replace 'expose_event' with 'draw'
---
pidgin/gtkblist.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index 0bc841f154..968e323491 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -6120,7 +6120,7 @@ static void pidgin_blist_show(PurpleBuddyList *list)
G_CALLBACK(headline_style_set),
NULL);
g_signal_connect (gtkblist->headline_hbox,
- "expose_event",
+ "draw",
G_CALLBACK (paint_headline_hbox),
NULL);
gtk_widget_set_name(gtkblist->headline_hbox, "gtk-tooltips");
--
cgit v1.2.1
From c4a88e1d3b74908f7ec40d011b0543685c65fb92 Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Sun, 28 Nov 2010 20:54:02 +0000
Subject: change property expanded to is-expanded
---
pidgin/gtkcellrendererexpander.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pidgin/gtkcellrendererexpander.c b/pidgin/gtkcellrendererexpander.c
index 9a46ab87cc..55336f2fa5 100644
--- a/pidgin/gtkcellrendererexpander.c
+++ b/pidgin/gtkcellrendererexpander.c
@@ -250,7 +250,7 @@ static void pidgin_cell_renderer_expander_render(GtkCellRenderer *cell,
GtkAllocation allocation;
gtk_cell_renderer_get_padding(cell, &xpad, &ypad);
- g_object_get(G_OBJECT(cell), "expanded", &is_expanded, NULL);
+ g_object_get(G_OBJECT(cell), "is-expanded", &is_expanded, NULL);
if (!cellexpander->is_expander)
return;
--
cgit v1.2.1
From 3e468ab9a81117d258448636205c785d7a2ac6a6 Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Sun, 28 Nov 2010 21:00:42 +0000
Subject: avoid illegal gobject cast here
---
pidgin/gtkcellrendererexpander.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pidgin/gtkcellrendererexpander.c b/pidgin/gtkcellrendererexpander.c
index 55336f2fa5..4d96a0ac65 100644
--- a/pidgin/gtkcellrendererexpander.c
+++ b/pidgin/gtkcellrendererexpander.c
@@ -258,7 +258,7 @@ static void pidgin_cell_renderer_expander_render(GtkCellRenderer *cell,
width = cell_area->width;
height = cell_area->height;
- if (!gtk_widget_get_sensitive(GTK_WIDGET(cell)))
+ if (!gtk_widget_get_sensitive(widget))
state = GTK_STATE_INSENSITIVE;
else if (flags & GTK_CELL_RENDERER_PRELIT)
state = GTK_STATE_PRELIGHT;
--
cgit v1.2.1
From b6dccdf9f11cc5a32fb1dde06580e3402f630daf Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Sun, 28 Nov 2010 21:48:26 +0000
Subject: make the buddy list tooltips work again
---
pidgin/gtkblist.c | 2 +-
pidgin/pidgintooltip.c | 16 +++++++++-------
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index 968e323491..df79a4f788 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -3028,7 +3028,7 @@ pidgin_blist_paint_tip(GtkWidget *widget, gpointer null)
for(l = gtkblist->tooltipdata; l; l = l->next)
{
struct tooltip_data *td = l->data;
- cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtkblist->tipwindow));
+ cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(gtkblist->tipwindow)));
if (td->avatar && pidgin_gdk_pixbuf_is_opaque(td->avatar))
{
diff --git a/pidgin/pidgintooltip.c b/pidgin/pidgintooltip.c
index fbd3232788..107d23e659 100644
--- a/pidgin/pidgintooltip.c
+++ b/pidgin/pidgintooltip.c
@@ -101,15 +101,17 @@ void pidgin_tooltip_destroy()
}
static gboolean
-pidgin_tooltip_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
+pidgin_tooltip_draw_cb(GtkWidget *widget, cairo_t *cr, gpointer data)
{
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation(widget, &allocation);
+
if (pidgin_tooltip.paint_tooltip) {
- cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
gtk_paint_flat_box(gtk_widget_get_style(widget), cr,
- GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- widget, "tooltip", 0, 0, -1, -1);
+ GTK_STATE_NORMAL, GTK_SHADOW_OUT,
+ widget, "tooltip", 0, 0, allocation.width, allocation.height);
pidgin_tooltip.paint_tooltip(widget, data);
- cairo_destroy(cr);
}
return FALSE;
}
@@ -182,8 +184,8 @@ setup_tooltip_window_position(gpointer data, int w, int h)
gtk_window_move(GTK_WINDOW(tipwindow), x, y);
gtk_widget_show(tipwindow);
- g_signal_connect(G_OBJECT(tipwindow), "expose_event",
- G_CALLBACK(pidgin_tooltip_expose_event), data);
+ g_signal_connect(G_OBJECT(tipwindow), "draw",
+ G_CALLBACK(pidgin_tooltip_draw_cb), data);
/* Hide the tooltip when the widget is destroyed */
sig = g_signal_connect(G_OBJECT(pidgin_tooltip.widget), "destroy", G_CALLBACK(pidgin_tooltip_destroy), NULL);
--
cgit v1.2.1
From 7f9daaefdf0b479862c7d8d9d428c4ecc9c56daf Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Sun, 28 Nov 2010 22:52:10 +0000
Subject: it's now possible to start conversations without glib fatal
warnings...
---
pidgin/gtkconv.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
index f574159d81..21516e71be 100644
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -3579,6 +3579,10 @@ setup_menubar(PidginWindow *win)
gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/ConversationMenu/SendFile");
+ g_object_set_data(G_OBJECT(win->window), "get_attention",
+ gtk_ui_manager_get_action(win->menu.ui,
+ "/Conversation/ConversationMenu/GetAttention"));
+
win->menu.add_pounce =
gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/ConversationMenu/AddBuddyPounce");
@@ -6612,7 +6616,7 @@ gray_stuff_out(PidginConversation *gtkconv)
/* Deal with menu items */
gtk_action_set_visible(win->menu.view_log, TRUE);
gtk_action_set_visible(win->menu.send_file, TRUE);
- gtk_action_set_visible(g_object_get_data(G_OBJECT(win->window), "get_attention"), TRUE);
+ gtk_action_set_visible(GTK_ACTION(g_object_get_data(G_OBJECT(win->window), "get_attention")), TRUE);
gtk_action_set_visible(win->menu.add_pounce, TRUE);
gtk_action_set_visible(win->menu.get_info, TRUE);
gtk_action_set_visible(win->menu.invite, FALSE);
@@ -9748,8 +9752,7 @@ pidgin_conv_tab_pack(PidginWindow *win, PidginConversation *gtkconv)
gtk_notebook_set_tab_label(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, ebox);
}
- g_object_set(G_OBJECT(win->notebook), "expand", !tabs_side && !angle,
- "fill", TRUE, NULL);
+ g_object_set(G_OBJECT(win->notebook), "expand", !tabs_side && !angle, NULL);
if (pidgin_conv_window_get_gtkconv_count(win) == 1)
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook),
--
cgit v1.2.1
From fc7369d7c816c82b190dad23f3284e616537d47d Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Mon, 29 Nov 2010 07:30:49 +0000
Subject: GtkDialog doesn't have a 'has-separator' property anymore
---
pidgin/gtkutils.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
index 9e303acda2..0349e32b1c 100644
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -180,7 +180,6 @@ pidgin_create_dialog(const char *title, guint border_width, const char *role, gb
wnd = GTK_WINDOW(gtk_dialog_new());
pidgin_window_init(wnd, title, border_width, role, resizable);
- g_object_set(G_OBJECT(wnd), "has-separator", FALSE, NULL);
return GTK_WIDGET(wnd);
}
--
cgit v1.2.1
From fff6996ea015726d6a00a338362cf57144ff1cc1 Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Mon, 29 Nov 2010 08:05:42 +0000
Subject: don't crash when switching tabs
---
pidgin/gtkconv.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
index 21516e71be..1fc0fbfbaa 100644
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -4675,15 +4675,15 @@ static gboolean resize_imhtml_cb(PidginConversation *gtkconv)
int min_height;
gboolean interior_focus;
int focus_width;
- GtkAllocation imhtml_allocation;
- GtkAllocation entry_allocation;
- GtkAllocation lower_hbox_allocation;
+ GtkAllocation imhtml_allocation;
+ GtkAllocation entry_allocation;
+ GtkAllocation lower_hbox_allocation;
- gtk_widget_get_allocation(gtkconv->imhtml, &imhtml_allocation);
- gtk_widget_get_allocation(gtkconv->entry, &entry_allocation);
- gtk_widget_get_allocation(gtkconv->lower_hbox, &lower_hbox_allocation);
- total_height = imhtml_allocation.height + entry_allocation.height;
- max_height = total_height / 2;
+ gtk_widget_get_allocation(gtkconv->imhtml, &imhtml_allocation);
+ gtk_widget_get_allocation(gtkconv->entry, &entry_allocation);
+ gtk_widget_get_allocation(gtkconv->lower_hbox, &lower_hbox_allocation);
+ total_height = imhtml_allocation.height + entry_allocation.height;
+ max_height = total_height / 2;
pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(gtkconv->entry));
pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(gtkconv->entry));
@@ -4721,6 +4721,9 @@ static gboolean resize_imhtml_cb(PidginConversation *gtkconv)
if (ABS(diff) < oneline.height / 2)
return FALSE;
+ purple_debug_info("pidgin", "resizing to %d, %d lines\n",
+ lower_hbox_allocation.height, min_lines);
+
gtk_widget_set_size_request(gtkconv->lower_hbox, -1,
diff + lower_hbox_allocation.height);
@@ -7309,11 +7312,11 @@ pidgin_conv_get_tab_at_xy(PidginWindow *win, int x, int y, gboolean *to_right)
count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook));
for (i = 0; i < count; i++) {
- GtkAllocation allocation;
+ GtkAllocation allocation;
- gtk_widget_get_allocation(tab, &allocation);
page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i);
tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page);
+ gtk_widget_get_allocation(tab, &allocation);
/* Make sure the tab is not hidden beyond an arrow */
if (!gtk_widget_is_drawable(tab) && gtk_notebook_get_show_tabs(notebook))
--
cgit v1.2.1
From 03761e765515decc4439b8bcd1f0fe2fc0d34dde Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Mon, 29 Nov 2010 09:23:05 +0000
Subject: I think draw should replace expose_event here, but the status
selector is still not seen...
---
pidgin/gtkconv.c | 4 ++--
pidgin/gtkstatusbox.c | 25 ++++++++++++-------------
2 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
index 1fc0fbfbaa..e1c88be52d 100644
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -4721,8 +4721,8 @@ static gboolean resize_imhtml_cb(PidginConversation *gtkconv)
if (ABS(diff) < oneline.height / 2)
return FALSE;
- purple_debug_info("pidgin", "resizing to %d, %d lines\n",
- lower_hbox_allocation.height, min_lines);
+ purple_debug_info("pidgin", "resizing to %d, %d lines, diff %d\n",
+ diff + lower_hbox_allocation.height, min_lines, diff);
gtk_widget_set_size_request(gtkconv->lower_hbox, -1,
diff + lower_hbox_allocation.height);
diff --git a/pidgin/gtkstatusbox.c b/pidgin/gtkstatusbox.c
index e1fc6d94be..b919886fa5 100644
--- a/pidgin/gtkstatusbox.c
+++ b/pidgin/gtkstatusbox.c
@@ -84,7 +84,7 @@ static void pidgin_status_box_regenerate(PidginStatusBox *status_box, gboolean s
static void pidgin_status_box_changed(PidginStatusBox *box);
/*static void pidgin_status_box_size_request (GtkWidget *widget, GtkRequisition *requisition);*/
static void pidgin_status_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
-/*static gboolean pidgin_status_box_expose_event (GtkWidget *widget, GdkEventExpose *event);*/
+static gboolean pidgin_status_box_draw (GtkWidget *widget, cairo_t *cr);
static void pidgin_status_box_redisplay_buddy_icon(PidginStatusBox *status_box);
static void pidgin_status_box_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data);
static void pidgin_status_box_popup(PidginStatusBox *box);
@@ -619,8 +619,7 @@ pidgin_status_box_class_init (PidginStatusBoxClass *klass)
/* this seems to be removed in GTK+ 3...*/
/*widget_class->size_request = pidgin_status_box_size_request;*/
widget_class->size_allocate = pidgin_status_box_size_allocate;
- /* this seems to be removed in GTK+ 3...*/
- /*widget_class->expose_event = pidgin_status_box_expose_event;*/
+ widget_class->draw = pidgin_status_box_draw;
container_class->child_type = pidgin_status_box_child_type;
container_class->forall = pidgin_status_box_forall;
@@ -1748,7 +1747,7 @@ pidgin_status_box_init (PidginStatusBox *status_box)
GtkWidget *toplevel;
GtkTreeSelection *sel;
- gtk_widget_set_has_window(GTK_WIDGET(status_box), FALSE);
+ gtk_widget_set_has_window(GTK_WIDGET(status_box), FALSE);
status_box->imhtml_visible = FALSE;
status_box->network_available = purple_network_is_available();
status_box->connecting = FALSE;
@@ -2045,23 +2044,23 @@ pidgin_status_box_size_allocate(GtkWidget *widget,
gtk_widget_set_allocation(GTK_WIDGET(status_box), allocation);
}
-/* TODO: don't think this is nessesary in GTK+ 3 */
-#if 0
static gboolean
-pidgin_status_box_expose_event(GtkWidget *widget,
- GdkEventExpose *event)
+pidgin_status_box_draw(GtkWidget *widget, cairo_t *cr)
{
PidginStatusBox *status_box = PIDGIN_STATUS_BOX(widget);
- gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->vbox, event);
- gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->toggle_button, event);
+ gtk_widget_draw(status_box->vbox, cr);
+ gtk_widget_draw(status_box->toggle_button, cr);
+
if (status_box->icon_box && status_box->icon_opaque) {
- gtk_paint_box(widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL,
- status_box->icon_box, "button", status_box->icon_box->allocation.x-1, status_box->icon_box->allocation.y-1,
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation(status_box->icon_box, &allocation);
+ gtk_paint_box(gtk_widget_get_style(widget), cr, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
+ status_box->icon_box, "button", allocation.x-1, allocation.y-1,
34, 34);
}
return FALSE;
}
-#endif
static void
pidgin_status_box_forall(GtkContainer *container,
--
cgit v1.2.1
From 44027f3e9accfba0d4a0457f51af06e6eac95798 Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Mon, 29 Nov 2010 13:09:01 +0000
Subject: the status box is now visible (and usable). autoexpanding for the
in-line status editor is not quite working right...
---
pidgin/gtkstatusbox.c | 68 ++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 51 insertions(+), 17 deletions(-)
diff --git a/pidgin/gtkstatusbox.c b/pidgin/gtkstatusbox.c
index b919886fa5..3217b6963a 100644
--- a/pidgin/gtkstatusbox.c
+++ b/pidgin/gtkstatusbox.c
@@ -82,7 +82,8 @@ static void pidgin_status_box_refresh(PidginStatusBox *status_box);
static void status_menu_refresh_iter(PidginStatusBox *status_box, gboolean status_changed);
static void pidgin_status_box_regenerate(PidginStatusBox *status_box, gboolean status_changed);
static void pidgin_status_box_changed(PidginStatusBox *box);
-/*static void pidgin_status_box_size_request (GtkWidget *widget, GtkRequisition *requisition);*/
+static void pidgin_status_box_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height, gint *natural_height);
static void pidgin_status_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
static gboolean pidgin_status_box_draw (GtkWidget *widget, cairo_t *cr);
static void pidgin_status_box_redisplay_buddy_icon(PidginStatusBox *status_box);
@@ -616,8 +617,7 @@ pidgin_status_box_class_init (PidginStatusBoxClass *klass)
parent_class = g_type_class_peek_parent(klass);
widget_class = (GtkWidgetClass*)klass;
- /* this seems to be removed in GTK+ 3...*/
- /*widget_class->size_request = pidgin_status_box_size_request;*/
+ widget_class->get_preferred_height = pidgin_status_box_get_preferred_height;
widget_class->size_allocate = pidgin_status_box_size_allocate;
widget_class->draw = pidgin_status_box_draw;
@@ -1931,30 +1931,62 @@ pidgin_status_box_init (PidginStatusBox *status_box)
}
-/* TODO: is this needed in GTK+ 3? */
#if 0
static void
-pidgin_status_box_size_request(GtkWidget *widget,
- GtkRequisition *requisition)
+pidgin_status_box_get_preferred_size(GtkWidget *widget,
+ GtkRequisition *minimum_size, GtkRequisition *natural_size)
{
- GtkRequisition box_req;
+ GtkRequisition box_min_req;
+ GtkRequisition box_nat_req;
gint border_width = gtk_container_get_border_width(GTK_CONTAINER (widget));
- gtk_widget_size_request(PIDGIN_STATUS_BOX(widget)->toggle_button, requisition);
+ gtk_widget_get_preferred_size(PIDGIN_STATUS_BOX(widget)->toggle_button,
+ minimum_size, natural_size);
/* Make this icon the same size as other buddy icons in the list; unless it already wants to be bigger */
- requisition->height = MAX(requisition->height, 34);
- requisition->height += border_width * 2;
-
+ minimum_size->height = MAX(minimum_size->height, 34);
+ minimum_size->height += border_width * 2;
+ natural_size->height = MAX(minium_size->height, 34);
+ natural_size->height += border_width * 2;
+
/* If the gtkimhtml is visible, then add some additional padding */
- gtk_widget_size_request(PIDGIN_STATUS_BOX(widget)->vbox, &box_req);
- if (box_req.height > 1)
- requisition->height += box_req.height + border_width * 2;
+ gtk_widget_get_preferred_size(PIDGIN_STATUS_BOX(widget)->vbox, &box_min_req, &box_nat_req);
+
+ if (box_min_req.height > 1)
+ minimum_size->height += box_min_req.height + border_width * 2;
- requisition->width = 1;
+ if (box_nat_req.height > 1)
+ natural_size->height += box_nat_req.height + border_width * 2;
+
+ minimum_size->width = 1;
+ natural_size->width = 1;
}
#endif
+static void
+pidgin_status_box_get_preferred_height(GtkWidget *widget, gint *minimum_height,
+ gint *natural_height)
+{
+ gint box_min_height, box_nat_height;
+ gint border_width = gtk_container_get_border_width(GTK_CONTAINER (widget));
+
+ gtk_widget_get_preferred_height(PIDGIN_STATUS_BOX(widget)->toggle_button,
+ minimum_height, natural_height);
+
+ *minimum_height = MAX(*minimum_height, 34) + border_width * 2;
+ *natural_height = MAX(*natural_height, 34) + border_width * 2;
+
+ /* If the gtkimhtml is visible, then add some additional padding */
+ gtk_widget_get_preferred_height(PIDGIN_STATUS_BOX(widget)->vbox,
+ &box_min_height, &box_nat_height);
+
+ if (box_min_height > 1)
+ *minimum_height += box_min_height + border_width * 2;
+
+ if (box_nat_height > 1)
+ *natural_height += box_nat_height + border_width * 2;
+}
+
/* From gnome-panel */
static void
do_colorshift (GdkPixbuf *dest, GdkPixbuf *src, int shift)
@@ -2000,7 +2032,7 @@ pidgin_status_box_size_allocate(GtkWidget *widget,
GtkAllocation *allocation)
{
PidginStatusBox *status_box = PIDGIN_STATUS_BOX(widget);
- GtkRequisition req = {0,0};
+ GtkRequisition req = {0,40};
GtkAllocation parent_alc, box_alc, icon_alc;
gint border_width = gtk_container_get_border_width(GTK_CONTAINER (widget));
@@ -2041,7 +2073,9 @@ pidgin_status_box_size_allocate(GtkWidget *widget,
gtk_widget_size_allocate(status_box->icon_box, &icon_alc);
}
gtk_widget_size_allocate(status_box->toggle_button, &parent_alc);
- gtk_widget_set_allocation(GTK_WIDGET(status_box), allocation);
+ gtk_widget_set_allocation(GTK_WIDGET(status_box), allocation);
+ purple_debug_info("pidgin", "statusbox allocation: width = %d, height = %d\n",
+ allocation->width, allocation->height);
}
static gboolean
--
cgit v1.2.1
From f4244e58048ab180d0b4674b0cb453c0d3225f12 Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Mon, 29 Nov 2010 15:48:29 +0000
Subject: remove unused code
---
pidgin/gtkstatusbox.c | 32 --------------------------------
1 file changed, 32 deletions(-)
diff --git a/pidgin/gtkstatusbox.c b/pidgin/gtkstatusbox.c
index 3217b6963a..cca5374e5d 100644
--- a/pidgin/gtkstatusbox.c
+++ b/pidgin/gtkstatusbox.c
@@ -1931,38 +1931,6 @@ pidgin_status_box_init (PidginStatusBox *status_box)
}
-#if 0
-static void
-pidgin_status_box_get_preferred_size(GtkWidget *widget,
- GtkRequisition *minimum_size, GtkRequisition *natural_size)
-{
- GtkRequisition box_min_req;
- GtkRequisition box_nat_req;
- gint border_width = gtk_container_get_border_width(GTK_CONTAINER (widget));
-
- gtk_widget_get_preferred_size(PIDGIN_STATUS_BOX(widget)->toggle_button,
- minimum_size, natural_size);
-
- /* Make this icon the same size as other buddy icons in the list; unless it already wants to be bigger */
- minimum_size->height = MAX(minimum_size->height, 34);
- minimum_size->height += border_width * 2;
- natural_size->height = MAX(minium_size->height, 34);
- natural_size->height += border_width * 2;
-
- /* If the gtkimhtml is visible, then add some additional padding */
- gtk_widget_get_preferred_size(PIDGIN_STATUS_BOX(widget)->vbox, &box_min_req, &box_nat_req);
-
- if (box_min_req.height > 1)
- minimum_size->height += box_min_req.height + border_width * 2;
-
- if (box_nat_req.height > 1)
- natural_size->height += box_nat_req.height + border_width * 2;
-
- minimum_size->width = 1;
- natural_size->width = 1;
-}
-#endif
-
static void
pidgin_status_box_get_preferred_height(GtkWidget *widget, gint *minimum_height,
gint *natural_height)
--
cgit v1.2.1
From fce7473fdb3ed86572828870af4bab737d409256 Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Mon, 29 Nov 2010 22:14:00 +0000
Subject: fix indentation and remove some unused code
---
pidgin/gtkblist.c | 73 +++++++++++++++++++------------------------------------
1 file changed, 25 insertions(+), 48 deletions(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index df79a4f788..119ac20dd8 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -3028,7 +3028,7 @@ pidgin_blist_paint_tip(GtkWidget *widget, gpointer null)
for(l = gtkblist->tooltipdata; l; l = l->next)
{
struct tooltip_data *td = l->data;
- cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(gtkblist->tipwindow)));
+ cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(gtkblist->tipwindow)));
if (td->avatar && pidgin_gdk_pixbuf_is_opaque(td->avatar))
{
@@ -3036,7 +3036,7 @@ pidgin_blist_paint_tip(GtkWidget *widget, gpointer null)
gtk_paint_flat_box(style, cr, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
gtkblist->tipwindow, "tooltip",
TOOLTIP_BORDER -1, current_height -1, td->avatar_width +2,
- td->avatar_height + 2);
+ td->avatar_height + 2);
else
gtk_paint_flat_box(style, cr, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
gtkblist->tipwindow, "tooltip",
@@ -3046,55 +3046,32 @@ pidgin_blist_paint_tip(GtkWidget *widget, gpointer null)
if (td->status_icon) {
if (dir == GTK_TEXT_DIR_RTL) {
- gdk_cairo_set_source_pixbuf(cr, td->status_icon,
- max_width - TOOLTIP_BORDER - status_size, current_height);
- cairo_paint(cr);
- /*
- gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, td->status_icon,
- 0, 0, max_width - TOOLTIP_BORDER - status_size, current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
- */
- } else {
- gdk_cairo_set_source_pixbuf(cr, td->status_icon, TOOLTIP_BORDER, current_height);
- cairo_paint(cr);
- /*
- gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, td->status_icon,
- 0, 0, TOOLTIP_BORDER, current_height, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0);
- */
- }
- }
-
- if(td->avatar) {
+ gdk_cairo_set_source_pixbuf(cr, td->status_icon,
+ max_width - TOOLTIP_BORDER - status_size, current_height);
+ cairo_paint(cr);
+ } else {
+ gdk_cairo_set_source_pixbuf(cr, td->status_icon, TOOLTIP_BORDER, current_height);
+ cairo_paint(cr);
+ }
+ }
+
+ if (td->avatar) {
if (dir == GTK_TEXT_DIR_RTL) {
- gdk_cairo_set_source_pixbuf(cr, td->avatar, TOOLTIP_BORDER, current_height);
- cairo_paint(cr);
- /*
- gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL,
- td->avatar, 0, 0, TOOLTIP_BORDER, current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
- */
- } else {
- gdk_cairo_set_source_pixbuf(cr, td->avatar,
- max_width - (td->avatar_width + TOOLTIP_BORDER), current_height);
- cairo_paint(cr);
- /*
- gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL,
- td->avatar, 0, 0, max_width - (td->avatar_width + TOOLTIP_BORDER),
- current_height, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0);
- */
- }
+ gdk_cairo_set_source_pixbuf(cr, td->avatar, TOOLTIP_BORDER,
+ current_height);
+ cairo_paint(cr);
+ } else {
+ gdk_cairo_set_source_pixbuf(cr, td->avatar,
+ max_width - (td->avatar_width + TOOLTIP_BORDER), current_height);
+ cairo_paint(cr);
+ }
}
if (!td->avatar_is_prpl_icon && td->prpl_icon) {
- gdk_cairo_set_source_pixbuf(cr, td->prpl_icon, prpl_col,
- current_height + ((td->name_height / 2) - (PRPL_SIZE / 2)));
- cairo_paint(cr);
- /*
- gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, td->prpl_icon,
- 0, 0,
- prpl_col,
- current_height + ((td->name_height / 2) - (PRPL_SIZE / 2)),
- -1 , -1, GDK_RGB_DITHER_NONE, 0, 0);
- */
- }
+ gdk_cairo_set_source_pixbuf(cr, td->prpl_icon, prpl_col,
+ current_height + ((td->name_height / 2) - (PRPL_SIZE / 2)));
+ cairo_paint(cr);
+ }
if (td->name_layout) {
if (dir == GTK_TEXT_DIR_RTL) {
@@ -3123,7 +3100,7 @@ pidgin_blist_paint_tip(GtkWidget *widget, gpointer null)
}
}
- cairo_destroy(cr);
+ cairo_destroy(cr);
current_height += MAX(td->name_height + td->height, td->avatar_height) + td->padding;
}
return FALSE;
--
cgit v1.2.1
From 1205ec6cdb2a127279ca9f0f8d3dcaf622afb66e Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Tue, 30 Nov 2010 09:03:34 +0000
Subject: fixed some indentation
---
pidgin/gtkimhtml.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/pidgin/gtkimhtml.c b/pidgin/gtkimhtml.c
index 3aac3e1685..8ed982282f 100644
--- a/pidgin/gtkimhtml.c
+++ b/pidgin/gtkimhtml.c
@@ -499,22 +499,20 @@ static gint
gtk_imhtml_tip_paint (GtkIMHtml *imhtml)
{
PangoLayout *layout;
- cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(imhtml->tip_window));
+ cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(imhtml->tip_window));
g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE);
layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip);
- gtk_paint_flat_box (gtk_widget_get_style(imhtml->tip_window),
- cr,
- GTK_STATE_NORMAL, GTK_SHADOW_OUT, imhtml->tip_window,
- "tooltip", 0, 0, -1, -1);
+ gtk_paint_flat_box (gtk_widget_get_style(imhtml->tip_window), cr,
+ GTK_STATE_NORMAL, GTK_SHADOW_OUT, imhtml->tip_window, "tooltip",
+ 0, 0, -1, -1);
- gtk_paint_layout (gtk_widget_get_style(imhtml->tip_window),
- cr,
- GTK_STATE_NORMAL, TRUE, imhtml->tip_window, NULL, 4, 4, layout);
+ gtk_paint_layout (gtk_widget_get_style(imhtml->tip_window), cr,
+ GTK_STATE_NORMAL, TRUE, imhtml->tip_window, NULL, 4, 4, layout);
- cairo_destroy(cr);
+ cairo_destroy(cr);
g_object_unref(layout);
return FALSE;
}
@@ -526,13 +524,13 @@ gtk_imhtml_tip (gpointer data)
PangoFontMetrics *font_metrics;
PangoLayout *layout;
PangoFont *font;
- GtkStyle *style = gtk_widget_get_style(imhtml->tip_window);
- GtkAllocation allocation;
+ GtkStyle *style = gtk_widget_get_style(imhtml->tip_window);
+ GtkAllocation allocation;
gint gap, x, y, h, w, scr_w, baseline_skip;
g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE);
- gtk_widget_get_allocation(GTK_WIDGET(imhtml), &allocation);
+ gtk_widget_get_allocation(GTK_WIDGET(imhtml), &allocation);
if (!imhtml->tip || !gtk_widget_is_drawable(GTK_WIDGET(imhtml))) {
imhtml->tip_timer = 0;
--
cgit v1.2.1
From 931fb8b5cca7d23a9925e0c2b13a2adbd9790d64 Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Wed, 1 Dec 2010 09:41:56 +0000
Subject: don't restrain the size of the 'welcome to pidgin' widget, as this
makes the blist un-resizable to a smaller width, as far as I can tell stuff
works as it should still...
---
pidgin/gtkblist.c | 1 -
pidgin/gtkstatusbox.c | 8 ++++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index 119ac20dd8..dfa7b3c084 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -6067,7 +6067,6 @@ static void pidgin_blist_show(PurpleBuddyList *list)
pretty = pidgin_make_pretty_arrows(tmp);
g_free(tmp);
label = gtk_label_new(NULL);
- gtk_widget_set_size_request(label, purple_prefs_get_int(PIDGIN_PREFS_ROOT "/blist/width") - 12, -1);
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.2);
gtk_label_set_markup(GTK_LABEL(label), pretty);
diff --git a/pidgin/gtkstatusbox.c b/pidgin/gtkstatusbox.c
index cca5374e5d..9e8c229853 100644
--- a/pidgin/gtkstatusbox.c
+++ b/pidgin/gtkstatusbox.c
@@ -1883,7 +1883,7 @@ pidgin_status_box_init (PidginStatusBox *status_box)
gtk_widget_set_parent(status_box->toggle_button, GTK_WIDGET(status_box));
gtk_box_pack_start(GTK_BOX(status_box->vbox), status_box->sw, TRUE, TRUE, 0);
-
+
g_signal_connect(G_OBJECT(status_box), "scroll_event", G_CALLBACK(combo_box_scroll_event_cb), NULL);
g_signal_connect(G_OBJECT(status_box->imhtml), "scroll_event",
G_CALLBACK(imhtml_scroll_event_cb), status_box->imhtml);
@@ -2570,7 +2570,11 @@ static void update_size(PidginStatusBox *status_box)
if (!interior_focus)
height += 2 * focus_width;
- gtk_widget_set_size_request(status_box->vbox, -1, height + PIDGIN_HIG_BOX_SPACE);
+ int mh, nh;
+ gtk_widget_get_preferred_height(status_box->vbox, &mh, &nh);
+ purple_debug_info("pidgin", "statusbox, set_size_request: %d %d\n", mh, nh);
+
+ gtk_widget_set_size_request(status_box->imhtml, -1, height + PIDGIN_HIG_BOX_SPACE);
}
static void remove_typing_cb(PidginStatusBox *status_box)
--
cgit v1.2.1
From 1e0e120307d1b2ddd56a84f3a9adda56fd558ca5 Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Wed, 1 Dec 2010 10:44:54 +0000
Subject: this wasn't really mean to be commited...
---
pidgin/gtkstatusbox.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/pidgin/gtkstatusbox.c b/pidgin/gtkstatusbox.c
index 9e8c229853..cca5374e5d 100644
--- a/pidgin/gtkstatusbox.c
+++ b/pidgin/gtkstatusbox.c
@@ -1883,7 +1883,7 @@ pidgin_status_box_init (PidginStatusBox *status_box)
gtk_widget_set_parent(status_box->toggle_button, GTK_WIDGET(status_box));
gtk_box_pack_start(GTK_BOX(status_box->vbox), status_box->sw, TRUE, TRUE, 0);
-
+
g_signal_connect(G_OBJECT(status_box), "scroll_event", G_CALLBACK(combo_box_scroll_event_cb), NULL);
g_signal_connect(G_OBJECT(status_box->imhtml), "scroll_event",
G_CALLBACK(imhtml_scroll_event_cb), status_box->imhtml);
@@ -2570,11 +2570,7 @@ static void update_size(PidginStatusBox *status_box)
if (!interior_focus)
height += 2 * focus_width;
- int mh, nh;
- gtk_widget_get_preferred_height(status_box->vbox, &mh, &nh);
- purple_debug_info("pidgin", "statusbox, set_size_request: %d %d\n", mh, nh);
-
- gtk_widget_set_size_request(status_box->imhtml, -1, height + PIDGIN_HIG_BOX_SPACE);
+ gtk_widget_set_size_request(status_box->vbox, -1, height + PIDGIN_HIG_BOX_SPACE);
}
static void remove_typing_cb(PidginStatusBox *status_box)
--
cgit v1.2.1
From 2be1718207c66ddb4cf64270dab15c9d7ecd4f4a Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Thu, 2 Dec 2010 12:11:26 +0000
Subject: don't use GDK_DRAWABLE
---
pidgin/gtkblist.c | 34 +++++++++++++++++-----------------
pidgin/gtkimhtml.c | 2 +-
pidgin/gtkplugin.c | 2 +-
pidgin/gtkroomlist.c | 2 +-
pidgin/gtkwhiteboard.c | 17 ++++++++---------
5 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index dfa7b3c084..9fde16299c 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -3028,7 +3028,7 @@ pidgin_blist_paint_tip(GtkWidget *widget, gpointer null)
for(l = gtkblist->tooltipdata; l; l = l->next)
{
struct tooltip_data *td = l->data;
- cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(gtkblist->tipwindow)));
+ cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(gtkblist->tipwindow));
if (td->avatar && pidgin_gdk_pixbuf_is_opaque(td->avatar))
{
@@ -3254,8 +3254,8 @@ static gboolean pidgin_blist_expand_timeout(GtkWidget *tv)
pidgin_blist_expand_contact_cb(NULL, node);
gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, >kblist->contact_rect);
- gtkblist->contact_rect.width =
- gdk_window_get_width(GDK_DRAWABLE(gtk_widget_get_window(tv)));
+ gtkblist->contact_rect.width =
+ gdk_window_get_width(gtk_widget_get_window(tv));
gtkblist->mouseover_contact = node;
gtk_tree_path_down (path);
while (gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &i, path)) {
@@ -5641,22 +5641,22 @@ paint_headline_hbox (GtkWidget *widget,
GdkEventExpose *event,
gpointer user_data)
{
- cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(widget));
- GtkAllocation allocation;
+ cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget));
+ GtkAllocation allocation;
- gtk_widget_get_allocation(widget, &allocation);
+ gtk_widget_get_allocation(widget, &allocation);
gtk_paint_flat_box (gtk_widget_get_style(widget),
- cr,
- GTK_STATE_NORMAL,
- GTK_SHADOW_OUT,
- widget,
- "tooltip",
- allocation.x + 1,
- allocation.y + 1,
- allocation.width - 2,
- allocation.height - 2);
- cairo_destroy(cr);
-
+ cr,
+ GTK_STATE_NORMAL,
+ GTK_SHADOW_OUT,
+ widget,
+ "tooltip",
+ allocation.x + 1,
+ allocation.y + 1,
+ allocation.width - 2,
+ allocation.height - 2);
+ cairo_destroy(cr);
+
return FALSE;
}
diff --git a/pidgin/gtkimhtml.c b/pidgin/gtkimhtml.c
index 8ed982282f..0e040106ec 100644
--- a/pidgin/gtkimhtml.c
+++ b/pidgin/gtkimhtml.c
@@ -499,7 +499,7 @@ static gint
gtk_imhtml_tip_paint (GtkIMHtml *imhtml)
{
PangoLayout *layout;
- cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(imhtml->tip_window));
+ cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(imhtml->tip_window));
g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE);
diff --git a/pidgin/gtkplugin.c b/pidgin/gtkplugin.c
index ff82805fcd..0da7bdec55 100644
--- a/pidgin/gtkplugin.c
+++ b/pidgin/gtkplugin.c
@@ -562,7 +562,7 @@ static gboolean
pidgin_plugins_paint_tooltip(GtkWidget *tipwindow, gpointer data)
{
PangoLayout *layout = g_object_get_data(G_OBJECT(tipwindow), "tooltip-plugin");
- cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(tipwindow)));
+ cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(tipwindow));
gtk_paint_layout(gtk_widget_get_style(tipwindow), cr, GTK_STATE_NORMAL, FALSE,
tipwindow, "tooltip",
6, 6, layout);
diff --git a/pidgin/gtkroomlist.c b/pidgin/gtkroomlist.c
index 8ae843c95e..18d6d4a495 100644
--- a/pidgin/gtkroomlist.c
+++ b/pidgin/gtkroomlist.c
@@ -360,7 +360,7 @@ pidgin_roomlist_paint_tooltip(GtkWidget *widget, gpointer user_data)
int max_text_width;
GtkTextDirection dir = gtk_widget_get_direction(GTK_WIDGET(grl->tree));
cairo_t *cr =
- gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(grl->tipwindow)));
+ gdk_cairo_create(gtk_widget_get_window(grl->tipwindow));
style = gtk_widget_get_style(grl->tipwindow);
diff --git a/pidgin/gtkwhiteboard.c b/pidgin/gtkwhiteboard.c
index 75fbb9daa5..16185625d0 100644
--- a/pidgin/gtkwhiteboard.c
+++ b/pidgin/gtkwhiteboard.c
@@ -358,8 +358,8 @@ static gboolean pidgin_whiteboard_configure_event(GtkWidget *widget, GdkEventCon
PidginWhiteboard *gtkwb = (PidginWhiteboard*)data;
GdkPixbuf *pixbuf = gtkwb->pixbuf;
cairo_t *cr;
- GdkWindow *window = gtk_widget_get_window(widget);
- GtkAllocation allocation;
+ GdkWindow *window = gtk_widget_get_window(widget);
+ GtkAllocation allocation;
if (pixbuf) {
cr = g_object_get_data(G_OBJECT(pixbuf), "cairo-context");
@@ -368,16 +368,15 @@ static gboolean pidgin_whiteboard_configure_event(GtkWidget *widget, GdkEventCon
g_object_unref(pixbuf);
}
- gtk_widget_get_allocation(widget, &allocation);
+ gtk_widget_get_allocation(widget, &allocation);
- pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
- FALSE,
- gdk_visual_get_depth(GDK_VISUAL(window)),
- allocation.width, allocation.height);
+ pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
+ FALSE, gdk_visual_get_depth(GDK_VISUAL(window)),
+ allocation.width, allocation.height);
gtkwb->pixbuf = pixbuf;
- cr = gdk_cairo_create(GDK_DRAWABLE(pixbuf));
+ cr = gdk_cairo_create(gtk_widget_get_window(widget));
g_object_set_data(G_OBJECT(pixbuf), "cairo-context", cr);
gdk_cairo_set_source_color(cr, >k_widget_get_style(widget)->white);
cairo_rectangle(cr,
@@ -394,7 +393,7 @@ static gboolean pidgin_whiteboard_expose_event(GtkWidget *widget, GdkEventExpose
GdkPixbuf *pixbuf = gtkwb->pixbuf;
cairo_t *cr;
- cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
+ cr = gdk_cairo_create(gtk_widget_get_window(widget));
gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
cairo_rectangle(cr,
event->area.x, event->area.y,
--
cgit v1.2.1
From 58deee9ef0dee2249e31ed1d23b757cc25a7876a Mon Sep 17 00:00:00 2001
From: Marcus Lundblad
Date: Fri, 3 Dec 2010 23:03:58 +0000
Subject: updates to work with the latest GTK+
---
configure.ac | 2 +-
pidgin/gtkblist.c | 2 +-
pidgin/gtkmedia.c | 4 ++--
pidgin/plugins/disco/gtkdisco.c | 2 +-
pidgin/plugins/gestures/stroke-draw.c | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
index 35a720dc4a..1610bb40cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -416,7 +416,7 @@ else
fi
if test "x$enable_gtkui" = "xyes" ; then
- PKG_CHECK_MODULES(GTK, [gtk+-3.0 >= 2.91.5], , [
+ PKG_CHECK_MODULES(GTK, [gtk+-3.0 >= 2.91.6], , [
AC_MSG_RESULT(no)
AC_MSG_ERROR([
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index 9fde16299c..b729476eae 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -6149,7 +6149,7 @@ static void pidgin_blist_show(PurpleBuddyList *list)
gtk_widget_show(gtkblist->treeview);
gtk_widget_set_name(gtkblist->treeview, "pidgin_blist_treeview");
-
+
g_signal_connect(gtkblist->treeview,
"style-set",
G_CALLBACK(treeview_style_set), list);
diff --git a/pidgin/gtkmedia.c b/pidgin/gtkmedia.c
index bf4f24e32f..7d2f4e224c 100644
--- a/pidgin/gtkmedia.c
+++ b/pidgin/gtkmedia.c
@@ -442,9 +442,9 @@ realize_cb_cb(PidginMediaRealizeData *data)
window_id = GDK_WINDOW_HWND(priv->remote_video->window);
#elif defined(HAVE_X11)
if (data->participant == NULL)
- window_id = GDK_WINDOW_XWINDOW(gtk_widget_get_window(priv->local_video));
+ window_id = gdk_x11_window_get_xid(gtk_widget_get_window(priv->local_video));
else
- window_id = GDK_WINDOW_XWINDOW(gtk_widget_get_window(priv->remote_video));
+ window_id = gdk_x11_window_get_xid(gtk_widget_get_window(priv->remote_video));
#else
# error "Unsupported windowing system"
#endif
diff --git a/pidgin/plugins/disco/gtkdisco.c b/pidgin/plugins/disco/gtkdisco.c
index 73bc9d98b4..572230040d 100644
--- a/pidgin/plugins/disco/gtkdisco.c
+++ b/pidgin/plugins/disco/gtkdisco.c
@@ -429,7 +429,7 @@ static gboolean account_filter_func(PurpleAccount *account)
static gboolean
disco_paint_tooltip(GtkWidget *tipwindow, gpointer data)
{
- cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(tipwindow));
+ cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(tipwindow));
PangoLayout *layout = g_object_get_data(G_OBJECT(tipwindow), "tooltip-plugin");
gtk_paint_layout(gtk_widget_get_style(tipwindow),
cr,
diff --git a/pidgin/plugins/gestures/stroke-draw.c b/pidgin/plugins/gestures/stroke-draw.c
index c9de72acf7..ff729264f6 100644
--- a/pidgin/plugins/gestures/stroke-draw.c
+++ b/pidgin/plugins/gestures/stroke-draw.c
@@ -339,7 +339,7 @@ gstroke_invisible_window_init (GtkWidget *widget)
unsigned int border_width;
XSizeHints hints;
Display *disp = GDK_WINDOW_XDISPLAY(gtk_widget_get_window(widget));
- Window wind = GDK_WINDOW_XWINDOW (gtk_widget_get_window(widget));
+ Window wind = gdk_x11_window_get_xid(gtk_widget_get_window(widget));
int screen = DefaultScreen (disp);
if (!gstroke_draw_strokes())
--
cgit v1.2.1
From f400d303c2dc52fc9e675af2cef40b8969fb1595 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade
Date: Sun, 5 Dec 2010 08:14:52 +0000
Subject: Fix some indenting.
---
pidgin/gtkimhtml.c | 162 ++++++++++++++++++++++++++---------------------------
1 file changed, 81 insertions(+), 81 deletions(-)
diff --git a/pidgin/gtkimhtml.c b/pidgin/gtkimhtml.c
index ff11ff52eb..a0e0381d32 100644
--- a/pidgin/gtkimhtml.c
+++ b/pidgin/gtkimhtml.c
@@ -510,7 +510,7 @@ gtk_imhtml_tip_paint (GtkIMHtml *imhtml)
0, 0, -1, -1);
gtk_paint_layout (gtk_widget_get_style(imhtml->tip_window), cr,
- GTK_STATE_NORMAL, TRUE, imhtml->tip_window, NULL, 4, 4, layout);
+ GTK_STATE_NORMAL, TRUE, imhtml->tip_window, NULL, 4, 4, layout);
cairo_destroy(cr);
g_object_unref(layout);
@@ -524,14 +524,14 @@ gtk_imhtml_tip (gpointer data)
PangoFontMetrics *font_metrics;
PangoLayout *layout;
PangoFont *font;
- GtkStyle *style = gtk_widget_get_style(imhtml->tip_window);
- GtkAllocation allocation;
+ GtkStyle *style = gtk_widget_get_style(imhtml->tip_window);
+ GtkAllocation allocation;
gint gap, x, y, h, w, scr_w, baseline_skip;
g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE);
- gtk_widget_get_allocation(GTK_WIDGET(imhtml), &allocation);
-
+ gtk_widget_get_allocation(GTK_WIDGET(imhtml), &allocation);
+
if (!imhtml->tip || !gtk_widget_is_drawable(GTK_WIDGET(imhtml))) {
imhtml->tip_timer = 0;
return FALSE;
@@ -556,7 +556,7 @@ gtk_imhtml_tip (gpointer data)
gtk_widget_ensure_style (imhtml->tip_window);
layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip);
font = pango_context_load_font(pango_layout_get_context(layout),
- style->font_desc);
+ style->font_desc);
if (font == NULL) {
char *tmp = pango_font_description_to_string(style->font_desc);
@@ -753,7 +753,7 @@ gtk_leave_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data
return FALSE;
}
-/* TODO: I think this can be removed for GTK+ 3.0... */
+/* TODO: I think this can be removed for GTK+ 3.0... */
#if 0
static gint
gtk_imhtml_expose_event (GtkWidget *widget,
@@ -783,7 +783,7 @@ gtk_imhtml_expose_event (GtkWidget *widget,
gdk_cairo_set_source_color(cr, &gcolor);
} else {
gdk_cairo_set_source_color(cr,
- &(gtk_widget_get_style(widget)->base[gtk_widget_get_state(widget)]));
+ &(gtk_widget_get_style(widget)->base[gtk_widget_get_state(widget)]));
}
cairo_rectangle(cr,
@@ -1166,8 +1166,8 @@ static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *select
{
char *text;
GtkIMHtml *imhtml = data;
- gint length = gtk_selection_data_get_length(selection_data);
-
+ gint length = gtk_selection_data_get_length(selection_data);
+
if (!gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml)))
return;
@@ -1576,7 +1576,7 @@ static void gtk_imhtml_class_init (GtkIMHtmlClass *klass)
gobject_class->finalize = gtk_imhtml_finalize;
widget_class->drag_motion = gtk_text_view_drag_motion;
- /* TODO: I _think_ this should be removed for GTK+ 3.0 */
+ /* TODO: I _think_ this should be removed for GTK+ 3.0 */
/*widget_class->expose_event = gtk_imhtml_expose_event;*/
parent_size_allocate = widget_class->size_allocate;
widget_class->size_allocate = gtk_imhtml_size_allocate;
@@ -1921,18 +1921,18 @@ gtk_imhtml_link_drag_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guin
GtkTextMark *mark = gtk_text_buffer_get_insert(imhtml->text_buffer);
GtkTextIter iter;
gint i = 0;
- gint length = gtk_selection_data_get_length(sd);
+ gint length = gtk_selection_data_get_length(sd);
gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark);
- if(gtk_imhtml_get_editable(imhtml) && text){
+ if (gtk_imhtml_get_editable(imhtml) && text) {
switch (info) {
case GTK_IMHTML_DRAG_URL:
/* TODO: Is it really ok to change sd->data...? */
purple_str_strip_char(text, '\r');
links = g_strsplit(text, "\n", 0);
- while((link = links[i]) != NULL){
+ while ((link = links[i]) != NULL) {
if (gtk_imhtml_is_protocol(link)) {
gchar *label;
@@ -2001,7 +2001,7 @@ gtk_imhtml_link_drag_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guin
return;
}
gtk_drag_finish(dc, TRUE,
- (gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE), t);
+ gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE, t);
} else {
gtk_drag_finish(dc, FALSE, FALSE, t);
}
@@ -2557,9 +2557,9 @@ static gboolean scroll_idle_cb(gpointer data)
{
GtkIMHtml *imhtml = data;
GtkAdjustment *adj = gtk_text_view_get_vadjustment(GTK_TEXT_VIEW(imhtml));
- if(adj) {
+ if (adj) {
gtk_adjustment_set_value(adj, gtk_adjustment_get_upper(adj) -
- gtk_adjustment_get_page_size(adj));
+ gtk_adjustment_get_page_size(adj));
}
imhtml->scroll_src = 0;
return FALSE;
@@ -3842,7 +3842,7 @@ static void
gtk_imhtml_custom_smiley_save(GtkWidget *w, GtkIMHtmlImageSave *save)
{
GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image;
-
+
/* Create an add dialog */
PidginSmiley *editor = pidgin_smiley_edit(NULL, NULL);
pidgin_smiley_editor_set_shortcut(editor, image->filename);
@@ -4199,14 +4199,14 @@ static void remove_tag_by_prefix(GtkIMHtml *imhtml, const GtkTextIter *i, const
for (l = tags; l; l = l->next) {
GtkTextTag *tag = l->data;
- gchar *name;
+ gchar *name = NULL;
+
+ g_object_get(G_OBJECT(tag), "name", &name, NULL);
- g_object_get(G_OBJECT(tag), "name", &name, NULL);
-
if (name && !strncmp(name, prefix, len))
gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, i, e);
- g_free(name);
+ g_free(name);
}
g_slist_free(tags);
@@ -4222,14 +4222,14 @@ static void remove_tag_by_prefix(GtkIMHtml *imhtml, const GtkTextIter *i, const
for (l = tags; l; l = l->next) {
GtkTextTag *tag = l->data;
- gchar *name;
+ gchar *name = NULL;
- g_object_get(G_OBJECT(tag), "name", &name, NULL);
+ g_object_get(G_OBJECT(tag), "name", &name, NULL);
if (name && !strncmp(name, prefix, len))
gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, &iter, e);
- g_free(name);
+ g_free(name);
}
g_slist_free(tags);
@@ -4350,16 +4350,16 @@ static void delete_cb(GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *en
gtk_text_iter_begins_tag(start, tag) && /* the tag starts with the selection */
(!gtk_text_iter_has_tag(end, tag) || /* the tag ends within the selection */
gtk_text_iter_ends_tag(end, tag))) {
- gchar *name;
+ gchar *name = NULL;
- g_object_get(G_OBJECT(tag), "name", &name, NULL);
+ g_object_get(G_OBJECT(tag), "name", &name, NULL);
gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, start, end);
- if (name && strncmp(name, "LINK ", 5) == 0 && imhtml->edit.link) {
+ if (name && strncmp(name, "LINK ", 5) == 0 && imhtml->edit.link) {
gtk_imhtml_toggle_link(imhtml, NULL);
}
- g_free(name);
+ g_free(name);
}
}
g_slist_free(tags);
@@ -4581,10 +4581,10 @@ static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *m
for (l = tags; l != NULL; l = l->next) {
GtkTextTag *tag = GTK_TEXT_TAG(l->data);
- gchar *name;
+ gchar *name = NULL;
+
+ g_object_get(G_OBJECT(tag), "name", &name, NULL);
- g_object_get(G_OBJECT(tag), "name", &name, NULL);
-
if (name) {
if (strcmp(name, "BOLD") == 0)
imhtml->edit.bold = TRUE;
@@ -4606,7 +4606,7 @@ static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *m
imhtml->edit.link = tag;
}
- g_free(name);
+ g_free(name);
}
g_slist_free(tags);
@@ -5004,10 +5004,10 @@ void gtk_imhtml_insert_smiley_at_iter(GtkIMHtml *imhtml, const char *sml, char *
* images, and ensures that they are handled by the image
* itself, without propagating to the textview and causing
* a complete refresh */
- /* TODO: I think this should be removed for GTK+ 3.0?
+ /* TODO: I think this should be removed for GTK+ 3.0?
g_signal_connect(G_OBJECT(icon), "expose-event", G_CALLBACK(image_expose), NULL);
- */
-
+ */
+
gtk_widget_show(icon);
if (ebox)
gtk_container_add(GTK_CONTAINER(ebox), icon);
@@ -5109,29 +5109,29 @@ void gtk_imhtml_insert_image_at_iter(GtkIMHtml *imhtml, int id, GtkTextIter *ite
static const gchar *tag_to_html_start(GtkTextTag *tag)
{
static gchar buf[1024];
- gchar *name;
+ gchar *name = NULL;
- g_object_get(G_OBJECT(tag), "name", &name, NULL);
g_return_val_if_fail(name != NULL, "");
+ g_object_get(G_OBJECT(tag), "name", &name, NULL);
if (strcmp(name, "BOLD") == 0) {
- g_free(name);
+ g_free(name);
return "";
} else if (strcmp(name, "ITALICS") == 0) {
- g_free(name);
+ g_free(name);
return "";
} else if (strcmp(name, "UNDERLINE") == 0) {
- g_free(name);
- return "";
+ g_free(name);
+ return "";
} else if (strcmp(name, "STRIKE") == 0) {
- g_free(name);
- return "";
+ g_free(name);
+ return "";
} else if (strncmp(name, "LINK ", 5) == 0) {
char *tmp = g_object_get_data(G_OBJECT(tag), "link_url");
- g_free(name);
-
- if (tmp) {
+ g_free(name);
+
+ if (tmp) {
g_snprintf(buf, sizeof(buf), "", tmp);
buf[sizeof(buf)-1] = '\0';
return buf;
@@ -5141,29 +5141,29 @@ static const gchar *tag_to_html_start(GtkTextTag *tag)
} else if (strncmp(name, "FORECOLOR ", 10) == 0) {
g_snprintf(buf, sizeof(buf), "", &name[10]);
- g_free(name);
+ g_free(name);
- return buf;
+ return buf;
} else if (strncmp(name, "BACKCOLOR ", 10) == 0) {
g_snprintf(buf, sizeof(buf), "", &name[10]);
- g_free(name);
-
- return buf;
+ g_free(name);
+
+ return buf;
} else if (strncmp(name, "BACKGROUND ", 10) == 0) {
g_snprintf(buf, sizeof(buf), "", &name[11]);
- g_free(name);
+ g_free(name);
- return buf;
+ return buf;
} else if (strncmp(name, "FONT FACE ", 10) == 0) {
g_snprintf(buf, sizeof(buf), "", &name[10]);
- g_free(name);
+ g_free(name);
- return buf;
+ return buf;
} else if (strncmp(name, "FONT SIZE ", 10) == 0) {
g_snprintf(buf, sizeof(buf), "", &name[10]);
- g_free(name);
+ g_free(name);
- return buf;
+ return buf;
} else {
char *str = buf;
gboolean isset;
@@ -5225,8 +5225,8 @@ static const gchar *tag_to_html_start(GtkTextTag *tag)
}
g_snprintf(str, sizeof(buf) - (str - buf), "'>");
- g_free(name);
-
+ g_free(name);
+
return (empty ? "" : buf);
}
}
@@ -5235,39 +5235,39 @@ static const gchar *tag_to_html_end(GtkTextTag *tag)
{
gchar *name;
- g_object_get(G_OBJECT(tag), "name", &name, NULL);
g_return_val_if_fail(name != NULL, "");
+ g_object_get(G_OBJECT(tag), "name", &name, NULL);
if (strcmp(name, "BOLD") == 0) {
- g_free(name);
+ g_free(name);
return "";
} else if (strcmp(name, "ITALICS") == 0) {
- g_free(name);
- return "";
+ g_free(name);
+ return "";
} else if (strcmp(name, "UNDERLINE") == 0) {
- g_free(name);
- return "";
+ g_free(name);
+ return "";
} else if (strcmp(name, "STRIKE") == 0) {
- g_free(name);
- return "";
+ g_free(name);
+ return "";
} else if (strncmp(name, "LINK ", 5) == 0) {
- g_free(name);
- return "";
+ g_free(name);
+ return "";
} else if (strncmp(name, "FORECOLOR ", 10) == 0) {
- g_free(name);
- return "";
+ g_free(name);
+ return "";
} else if (strncmp(name, "BACKCOLOR ", 10) == 0) {
- g_free(name);
- return "";
+ g_free(name);
+ return "";
} else if (strncmp(name, "BACKGROUND ", 10) == 0) {
- g_free(name);
- return "";
+ g_free(name);
+ return "