# HG changeset patch # User Sadrul Habib Chowdhury # Date 1155860358 0 # Node ID 06a2658aa96e5f75ac10c373690cfb9973e99ebb # Parent d38d8716426c53564d0de1ff862f4b849706bbde [gaim-migrate @ 16822] Patch #1541742 ("Add boolean property \"iconsel\" for Statusbox"): "This adds a boolean property "iconsel" for statusbox. Setting the property to TRUE shows the icon-selector, setting it to FALSE removes it. It would allow plugins like mystatusbox to better control the statusboxes, especially the per-account ones." committer: Tailor Script diff -r d38d8716426c -r 06a2658aa96e src/gtkstatusbox.c --- a/src/gtkstatusbox.c Fri Aug 18 00:15:25 2006 +0000 +++ b/src/gtkstatusbox.c Fri Aug 18 00:19:18 2006 +0000 @@ -115,7 +115,8 @@ enum { PROP_0, - PROP_ACCOUNT + PROP_ACCOUNT, + PROP_ICON_SEL, }; GtkComboBoxClass *parent_class = NULL; @@ -163,6 +164,9 @@ case PROP_ACCOUNT: g_value_set_pointer(value, statusbox->account); break; + case PROP_ICON_SEL: + g_value_set_boolean(value, statusbox->icon_box != NULL); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, psec); break; @@ -253,6 +257,9 @@ static void setup_icon_box(GtkGaimStatusBox *status_box) { + if (status_box->icon_box != NULL) + return; + if (status_box->account && !gaim_account_get_ui_bool(status_box->account, GAIM_GTK_UI, "use-global-buddyicon", TRUE)) { @@ -280,12 +287,54 @@ } static void +destroy_icon_box(GtkGaimStatusBox *statusbox) +{ + if (statusbox->icon_box == NULL) + return; + + gtk_widget_destroy(statusbox->icon_box); + gdk_cursor_unref(statusbox->hand_cursor); + gdk_cursor_unref(statusbox->arrow_cursor); + + g_object_unref(G_OBJECT(statusbox->buddy_icon)); + g_object_unref(G_OBJECT(statusbox->buddy_icon_hover)); + + if (statusbox->buddy_icon_sel) + gtk_widget_destroy(statusbox->buddy_icon_sel); + + g_free(statusbox->buddy_icon_path); + + statusbox->icon_box = NULL; + statusbox->buddy_icon_path = NULL; + statusbox->buddy_icon = NULL; + statusbox->buddy_icon_hover = NULL; + statusbox->hand_cursor = NULL; + statusbox->arrow_cursor = NULL; +} + +static void gtk_gaim_status_box_set_property(GObject *object, guint param_id, const GValue *value, GParamSpec *pspec) { GtkGaimStatusBox *statusbox = GTK_GAIM_STATUS_BOX(object); switch (param_id) { + case PROP_ICON_SEL: + if (g_value_get_boolean(value)) { + if (statusbox->account) { + GaimPlugin *plug = gaim_plugins_find_with_id(gaim_account_get_protocol_id(statusbox->account)); + if (plug) { + GaimPluginProtocolInfo *prplinfo = GAIM_PLUGIN_PROTOCOL_INFO(plug); + if (prplinfo && prplinfo->icon_spec.format != NULL) + setup_icon_box(statusbox); + } + } else { + setup_icon_box(statusbox); + } + } else { + destroy_icon_box(statusbox); + } + break; case PROP_ACCOUNT: statusbox->account = g_value_get_pointer(value); @@ -296,16 +345,9 @@ } if (statusbox->account) { - GaimPlugin *plug = gaim_plugins_find_with_id(gaim_account_get_protocol_id(statusbox->account)); - GaimPluginProtocolInfo *prplinfo = GAIM_PLUGIN_PROTOCOL_INFO(plug); - if (prplinfo && prplinfo->icon_spec.format != NULL) { - setup_icon_box(statusbox); - } statusbox->status_changed_signal = gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", statusbox, GAIM_CALLBACK(account_status_changed_cb), statusbox); - } else { - setup_icon_box(statusbox); } gtk_gaim_status_box_regenerate(statusbox); @@ -365,6 +407,7 @@ combo_box_forall = container_class->forall; container_class->forall = gtk_gaim_status_box_forall; + container_class->remove = NULL; object_class = (GObjectClass *)klass; @@ -381,6 +424,15 @@ G_PARAM_READWRITE ) ); + g_object_class_install_property(object_class, + PROP_ICON_SEL, + g_param_spec_boolean("iconsel", + "Icon Selector", + "Whether the icon selector should be displayed or not.", + FALSE, + G_PARAM_READWRITE + ) + ); } /** @@ -1005,6 +1057,7 @@ gaim_account_set_buddy_icon(box->account, icon); g_free(icon); gaim_account_set_ui_bool(box->account, GAIM_GTK_UI, "use-global-buddyicon", FALSE); + gaim_account_set_ui_string(box->account, GAIM_GTK_UI, "non-global-buddyicon", icon); } } } else { @@ -1251,7 +1304,8 @@ GtkGaimStatusBox *status_box = GTK_GAIM_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_container_propagate_expose(GTK_CONTAINER(widget), status_box->icon_box, event); + if (status_box->icon_box) + gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->icon_box, event); return FALSE; } @@ -1278,13 +1332,15 @@ GtkWidget * gtk_gaim_status_box_new() { - return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, "account", NULL, NULL); + return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, "account", NULL, + "iconsel", TRUE, NULL); } GtkWidget * gtk_gaim_status_box_new_with_account(GaimAccount *account) { - return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, "account", account, NULL); + return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, "account", account, + "iconsel", TRUE, NULL); } /**