Mercurial > pidgin
changeset 15827:eec0d0202ffd
merge of '9d227438376255715d0d778ce0a57734aed4c99a'
and 'ebb919dd47f8edc3b1b82fdbc2d2a7764bc9ab6f'
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 06:35:51 +0000 |
parents | f59cfcce68a8 (current diff) 84b0f9b23ede (diff) |
children | 2edbd4fede72 |
files | pidgin/gaimcombobox.c pidgin/gaimcombobox.h pidgin/gaimstock.c pidgin/gaimstock.h |
diffstat | 44 files changed, 4717 insertions(+), 4717 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/Makefile.am Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/Makefile.am Mon Mar 19 06:35:51 2007 +0000 @@ -69,8 +69,8 @@ pidgin_SOURCES = \ eggtrayicon.c \ - gaimcombobox.c \ - gaimstock.c \ + pidgincombobox.c \ + pidginstock.c \ gtkaccount.c \ gtkblist.c \ gtkcelllayout.c \ @@ -123,7 +123,7 @@ gtkcellviewmenuitem.h \ gtkcellview.h \ gtkcellviewmenuitem.h \ - gaimcombobox.h \ + pidgincombobox.h \ gtkconn.h \ gtkconv.h \ gtkconvwin.h \ @@ -154,7 +154,7 @@ gtksound.h \ gtksourceiter.h \ gtkstatusbox.h \ - gaimstock.h \ + pidginstock.h \ gtkthemes.h \ gtkutils.h \ gtkwhiteboard.h \
--- a/pidgin/gaimcombobox.c Mon Mar 19 06:34:51 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3749 +0,0 @@ -/* gaimcombobox.c - * Copyright (C) 2002, 2003 Kristian Rietveld <kris@gtk.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* -#include <config.h> -*/ -#include <gtk/gtkversion.h> -#if !GTK_CHECK_VERSION(2,6,0) -#include "gaimcombobox.h" - -#if !GTK_CHECK_VERSION(2,4,0) -#include <gtk/gtkarrow.h> -#include <gtk/gtkbindings.h> -#include "gtkcelllayout.h" -#include <gtk/gtkcellrenderertext.h> -#include "gtkcellview.h" -#include "gtkcellviewmenuitem.h" -#include <gtk/gtkeventbox.h> -#include <gtk/gtkframe.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtkliststore.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkmenu.h> -#include <gtk/gtktogglebutton.h> -#include <gtk/gtktreeselection.h> -/* -#include <gtk/gtktreeprivate.h> -*/ -#include <gtk/gtkvseparator.h> -#include <gtk/gtkwindow.h> -#include <gtk/gtkversion.h> - -#include <gdk/gdkkeysyms.h> - -#include <gobject/gvaluecollector.h> - -#include <string.h> -#include <stdarg.h> - -#define P_(x) (x) - -/* WELCOME, to THE house of evil code */ - -typedef struct _ComboCellInfo ComboCellInfo; -struct _ComboCellInfo -{ - GtkCellRenderer *cell; - GSList *attributes; - - GtkCellLayoutDataFunc func; - gpointer func_data; - GDestroyNotify destroy; - - guint expand : 1; - guint pack : 1; -}; - -struct _GtkComboBoxPrivate -{ - GtkTreeModel *model; - - gint col_column; - gint row_column; - - gint wrap_width; - - gint active_item; - - GtkWidget *tree_view; - GtkTreeViewColumn *column; - - GtkWidget *cell_view; - GtkWidget *cell_view_frame; - - GtkWidget *button; - GtkWidget *box; - GtkWidget *arrow; - GtkWidget *separator; - - GtkWidget *popup_widget; - GtkWidget *popup_window; - GtkWidget *popup_frame; - - guint inserted_id; - guint deleted_id; - guint reordered_id; - guint changed_id; - - gint width; - GSList *cells; - - guint popup_in_progress : 1; - guint destroying : 1; -}; - -/* While debugging this evil code, I have learned that - * there are actually 4 modes to this widget, which can - * be characterized as follows - * - * 1) menu mode, no child added - * - * tree_view -> NULL - * cell_view -> GtkCellView, regular child - * cell_view_frame -> NULL - * button -> GtkToggleButton set_parent to combo - * box -> child of button - * arrow -> child of box - * separator -> child of box - * popup_widget -> GtkMenu - * popup_window -> NULL - * popup_frame -> NULL - * - * 2) menu mode, child added - * - * tree_view -> NULL - * cell_view -> NULL - * cell_view_frame -> NULL - * button -> GtkToggleButton set_parent to combo - * box -> NULL - * arrow -> GtkArrow, child of button - * separator -> NULL - * popup_widget -> GtkMenu - * popup_window -> NULL - * popup_frame -> NULL - * - * 3) list mode, no child added - * - * tree_view -> GtkTreeView, child of popup_frame - * cell_view -> GtkCellView, regular child - * cell_view_frame -> GtkFrame, set parent to combo - * button -> GtkToggleButton, set_parent to combo - * box -> NULL - * arrow -> GtkArrow, child of button - * separator -> NULL - * popup_widget -> tree_view - * popup_window -> GtkWindow - * popup_frame -> GtkFrame, child of popup_window - * - * 4) list mode, child added - * - * tree_view -> GtkTreeView, child of popup_frame - * cell_view -> NULL - * cell_view_frame -> NULL - * button -> GtkToggleButton, set_parent to combo - * box -> NULL - * arrow -> GtkArrow, child of button - * separator -> NULL - * popup_widget -> tree_view - * popup_window -> GtkWindow - * popup_frame -> GtkFrame, child of popup_window - * - */ - -enum { - CHANGED, - LAST_SIGNAL -}; - -enum { - PROP_0, - PROP_MODEL, - PROP_WRAP_WIDTH, - PROP_ROW_SPAN_COLUMN, - PROP_COLUMN_SPAN_COLUMN, - PROP_ACTIVE -}; - -static GtkBinClass *parent_class = NULL; -static guint combo_box_signals[LAST_SIGNAL] = {0,}; - -#define BONUS_PADDING 4 - - -/* common */ -static void gtk_combo_box_class_init (GtkComboBoxClass *klass); -static void gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface); -static void gtk_combo_box_init (GtkComboBox *combo_box); -static void gtk_combo_box_finalize (GObject *object); -static void gtk_combo_box_destroy (GtkObject *object); - -static void gtk_combo_box_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *spec); -static void gtk_combo_box_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *spec); - -static void gtk_combo_box_state_changed (GtkWidget *widget, - GtkStateType previous); -static void gtk_combo_box_style_set (GtkWidget *widget, - GtkStyle *previous); -static void gtk_combo_box_button_toggled (GtkWidget *widget, - gpointer data); -static void gtk_combo_box_add (GtkContainer *container, - GtkWidget *widget); -static void gtk_combo_box_remove (GtkContainer *container, - GtkWidget *widget); - -static ComboCellInfo *gtk_combo_box_get_cell_info (GtkComboBox *combo_box, - GtkCellRenderer *cell); - -static void gtk_combo_box_menu_show (GtkWidget *menu, - gpointer user_data); -static void gtk_combo_box_menu_hide (GtkWidget *menu, - gpointer user_data); - -static void gtk_combo_box_set_popup_widget (GtkComboBox *combo_box, - GtkWidget *popup); -#if GTK_CHECK_VERSION(2,2,0) -static void gtk_combo_box_menu_position_below (GtkMenu *menu, - gint *x, - gint *y, - gint *push_in, - gpointer user_data); -static void gtk_combo_box_menu_position_over (GtkMenu *menu, - gint *x, - gint *y, - gint *push_in, - gpointer user_data); -static void gtk_combo_box_menu_position (GtkMenu *menu, - gint *x, - gint *y, - gint *push_in, - gpointer user_data); -#endif - -static gint gtk_combo_box_calc_requested_width (GtkComboBox *combo_box, - GtkTreePath *path); -static void gtk_combo_box_remeasure (GtkComboBox *combo_box); - -static void gtk_combo_box_unset_model (GtkComboBox *combo_box); - -static void gtk_combo_box_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void gtk_combo_box_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void gtk_combo_box_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); -static gboolean gtk_combo_box_expose_event (GtkWidget *widget, - GdkEventExpose *event); -static gboolean gtk_combo_box_scroll_event (GtkWidget *widget, - GdkEventScroll *event); -static void gtk_combo_box_set_active_internal (GtkComboBox *combo_box, - gint index); -static gboolean gtk_combo_box_key_press (GtkWidget *widget, - GdkEventKey *event, - gpointer data); - -/* listening to the model */ -static void gtk_combo_box_model_row_inserted (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data); -static void gtk_combo_box_model_row_deleted (GtkTreeModel *model, - GtkTreePath *path, - gpointer user_data); -static void gtk_combo_box_model_rows_reordered (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gint *new_order, - gpointer user_data); -static void gtk_combo_box_model_row_changed (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data); - -/* list */ -static void gtk_combo_box_list_position (GtkComboBox *combo_box, - gint *x, - gint *y, - gint *width, - gint *height); - -static void gtk_combo_box_list_setup (GtkComboBox *combo_box); -static void gtk_combo_box_list_destroy (GtkComboBox *combo_box); - -static void gtk_combo_box_list_remove_grabs (GtkComboBox *combo_box); - -static gboolean gtk_combo_box_list_button_released (GtkWidget *widget, - GdkEventButton *event, - gpointer data); -static gboolean gtk_combo_box_list_key_press (GtkWidget *widget, - GdkEventKey *event, - gpointer data); -static gboolean gtk_combo_box_list_button_pressed (GtkWidget *widget, - GdkEventButton *event, - gpointer data); - -static void gtk_combo_box_list_row_changed (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data); - -/* menu */ -static void gtk_combo_box_menu_setup (GtkComboBox *combo_box, - gboolean add_children); -static void gtk_combo_box_menu_fill (GtkComboBox *combo_box); -static void gtk_combo_box_menu_destroy (GtkComboBox *combo_box); - -static void gtk_combo_box_item_get_size (GtkComboBox *combo_box, - gint index, - gint *cols, - gint *rows); -static void gtk_combo_box_relayout_item (GtkComboBox *combo_box, - gint index); -static void gtk_combo_box_relayout (GtkComboBox *combo_box); - -static gboolean gtk_combo_box_menu_button_press (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data); -static void gtk_combo_box_menu_item_activate (GtkWidget *item, - gpointer user_data); -static void gtk_combo_box_menu_row_inserted (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data); -static void gtk_combo_box_menu_row_deleted (GtkTreeModel *model, - GtkTreePath *path, - gpointer user_data); -static void gtk_combo_box_menu_rows_reordered (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gint *new_order, - gpointer user_data); -static void gtk_combo_box_menu_row_changed (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data); -static gboolean gtk_combo_box_menu_key_press (GtkWidget *widget, - GdkEventKey *event, - gpointer data); - -/* cell layout */ -static void gtk_combo_box_cell_layout_pack_start (GtkCellLayout *layout, - GtkCellRenderer *cell, - gboolean expand); -static void gtk_combo_box_cell_layout_pack_end (GtkCellLayout *layout, - GtkCellRenderer *cell, - gboolean expand); -static void gtk_combo_box_cell_layout_clear (GtkCellLayout *layout); -static void gtk_combo_box_cell_layout_add_attribute (GtkCellLayout *layout, - GtkCellRenderer *cell, - const gchar *attribute, - gint column); -static void gtk_combo_box_cell_layout_set_cell_data_func (GtkCellLayout *layout, - GtkCellRenderer *cell, - GtkCellLayoutDataFunc func, - gpointer func_data, - GDestroyNotify destroy); -static void gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout *layout, - GtkCellRenderer *cell); -static void gtk_combo_box_cell_layout_reorder (GtkCellLayout *layout, - GtkCellRenderer *cell, - gint position); -static gboolean gtk_combo_box_mnemonic_activate (GtkWidget *widget, - gboolean group_cycling); - -static void cell_view_sync_cells (GtkComboBox *combo_box, - GtkCellView *cell_view); - -#if !GTK_CHECK_VERSION(2,4,0) -static void gtk_menu_attach (GtkMenu *menu, - GtkWidget *child, - guint left_attach, - guint right_attach, - guint top_attach, - guint bottom_attach); -#endif - -GType -gtk_combo_box_get_type (void) -{ - static GType combo_box_type = 0; - - if (!combo_box_type) - { - static const GTypeInfo combo_box_info = - { - sizeof (GtkComboBoxClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_combo_box_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkComboBox), - 0, - (GInstanceInitFunc) gtk_combo_box_init - }; - - static const GInterfaceInfo cell_layout_info = - { - (GInterfaceInitFunc) gtk_combo_box_cell_layout_init, - NULL, - NULL - }; - - combo_box_type = g_type_register_static (GTK_TYPE_BIN, - "PidginComboBox", - &combo_box_info, - 0); - - g_type_add_interface_static (combo_box_type, - GTK_TYPE_CELL_LAYOUT, - &cell_layout_info); - } - - return combo_box_type; -} - -/* common */ -static void -gtk_combo_box_class_init (GtkComboBoxClass *klass) -{ - GObjectClass *object_class; - GtkBindingSet *binding_set; - GtkObjectClass *gtk_object_class; - GtkContainerClass *container_class; - GtkWidgetClass *widget_class; - - binding_set = gtk_binding_set_by_class (klass); - - container_class = (GtkContainerClass *)klass; - container_class->forall = gtk_combo_box_forall; - container_class->add = gtk_combo_box_add; - container_class->remove = gtk_combo_box_remove; - - widget_class = (GtkWidgetClass *)klass; - widget_class->size_allocate = gtk_combo_box_size_allocate; - widget_class->size_request = gtk_combo_box_size_request; - widget_class->expose_event = gtk_combo_box_expose_event; - widget_class->scroll_event = gtk_combo_box_scroll_event; - widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate; - widget_class->style_set = gtk_combo_box_style_set; - widget_class->state_changed = gtk_combo_box_state_changed; - - gtk_object_class = (GtkObjectClass *)klass; - gtk_object_class->destroy = gtk_combo_box_destroy; - - object_class = (GObjectClass *)klass; - object_class->finalize = gtk_combo_box_finalize; - object_class->set_property = gtk_combo_box_set_property; - object_class->get_property = gtk_combo_box_get_property; - - parent_class = g_type_class_peek_parent (klass); - - /* signals */ - combo_box_signals[CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GtkComboBoxClass, changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /* properties */ - g_object_class_install_property (object_class, - PROP_MODEL, - g_param_spec_object ("model", - P_("ComboBox model"), - P_("The model for the combo box"), - GTK_TYPE_TREE_MODEL, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_WRAP_WIDTH, - g_param_spec_int ("wrap_width", - P_("Wrap width"), - P_("Wrap width for layouting the items in a grid"), - 0, - G_MAXINT, - 0, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_ROW_SPAN_COLUMN, - g_param_spec_int ("row_span_column", - P_("Row span column"), - P_("TreeModel column containing the row span values"), - 0, - G_MAXINT, - 0, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_COLUMN_SPAN_COLUMN, - g_param_spec_int ("column_span_column", - P_("Column span column"), - - P_("TreeModel column containing the column span values"), - 0, - G_MAXINT, - 0, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_ACTIVE, - g_param_spec_int ("active", - P_("Active item"), - P_("The item which is currently active"), - -1, - G_MAXINT, - -1, - G_PARAM_READWRITE)); - - gtk_widget_class_install_style_property (widget_class, - g_param_spec_boolean ("appears-as-list", - P_("Appears as list"), - P_("Whether combobox dropdowns should look like lists rather than menus"), - FALSE, - G_PARAM_READABLE)); -} - -static void -gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface) -{ - iface->pack_start = gtk_combo_box_cell_layout_pack_start; - iface->pack_end = gtk_combo_box_cell_layout_pack_end; - iface->clear = gtk_combo_box_cell_layout_clear; - iface->add_attribute = gtk_combo_box_cell_layout_add_attribute; - iface->set_cell_data_func = gtk_combo_box_cell_layout_set_cell_data_func; - iface->clear_attributes = gtk_combo_box_cell_layout_clear_attributes; - iface->reorder = gtk_combo_box_cell_layout_reorder; -} - -static void -gtk_combo_box_init (GtkComboBox *combo_box) -{ - combo_box->priv = g_new0(GtkComboBoxPrivate,1); - - combo_box->priv->cell_view = gtk_cell_view_new (); - gtk_widget_set_parent (combo_box->priv->cell_view, GTK_WIDGET (combo_box)); - GTK_BIN (combo_box)->child = combo_box->priv->cell_view; - gtk_widget_show (combo_box->priv->cell_view); - - combo_box->priv->width = 0; - combo_box->priv->wrap_width = 0; - - combo_box->priv->active_item = -1; - combo_box->priv->col_column = -1; - combo_box->priv->row_column = -1; -} - -static void -gtk_combo_box_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (object); - - switch (prop_id) - { - case PROP_MODEL: - gtk_combo_box_set_model (combo_box, g_value_get_object (value)); - break; - - case PROP_WRAP_WIDTH: - gtk_combo_box_set_wrap_width (combo_box, g_value_get_int (value)); - break; - - case PROP_ROW_SPAN_COLUMN: - gtk_combo_box_set_row_span_column (combo_box, g_value_get_int (value)); - break; - - case PROP_COLUMN_SPAN_COLUMN: - gtk_combo_box_set_column_span_column (combo_box, g_value_get_int (value)); - break; - - case PROP_ACTIVE: - gtk_combo_box_set_active (combo_box, g_value_get_int (value)); - break; - - default: - break; - } -} - -static void -gtk_combo_box_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (object); - - switch (prop_id) - { - case PROP_MODEL: - g_value_set_object (value, combo_box->priv->model); - break; - - case PROP_WRAP_WIDTH: - g_value_set_int (value, combo_box->priv->wrap_width); - break; - - case PROP_ROW_SPAN_COLUMN: - g_value_set_int (value, combo_box->priv->row_column); - break; - - case PROP_COLUMN_SPAN_COLUMN: - g_value_set_int (value, combo_box->priv->col_column); - break; - - case PROP_ACTIVE: - g_value_set_int (value, gtk_combo_box_get_active (combo_box)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gtk_combo_box_state_changed (GtkWidget *widget, - GtkStateType previous) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (widget); - - if (GTK_WIDGET_REALIZED (widget)) - { - if (combo_box->priv->tree_view && combo_box->priv->cell_view) - gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view), - &widget->style->base[GTK_WIDGET_STATE (widget)]); - } - - gtk_widget_queue_draw (widget); -} - -static void -gtk_combo_box_check_appearance (GtkComboBox *combo_box) -{ - gboolean appears_as_list; - - /* if wrap_width > 0, then we are in grid-mode and forced to use - * unix style - */ - if (combo_box->priv->wrap_width) - appears_as_list = FALSE; - else - gtk_widget_style_get (GTK_WIDGET (combo_box), - "appears-as-list", &appears_as_list, - NULL); - - if (appears_as_list) - { - /* Destroy all the menu mode widgets, if they exist. */ - if (GTK_IS_MENU (combo_box->priv->popup_widget)) - gtk_combo_box_menu_destroy (combo_box); - - /* Create the list mode widgets, if they don't already exist. */ - if (!GTK_IS_TREE_VIEW (combo_box->priv->tree_view)) - gtk_combo_box_list_setup (combo_box); - } - else - { - /* Destroy all the list mode widgets, if they exist. */ - if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view)) - gtk_combo_box_list_destroy (combo_box); - - /* Create the menu mode widgets, if they don't already exist. */ - if (!GTK_IS_MENU (combo_box->priv->popup_widget)) - gtk_combo_box_menu_setup (combo_box, TRUE); - } -} - -static void -gtk_combo_box_style_set (GtkWidget *widget, - GtkStyle *previous) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (widget); - - gtk_combo_box_check_appearance (combo_box); - - if (combo_box->priv->tree_view && combo_box->priv->cell_view) - gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view), - &widget->style->base[GTK_WIDGET_STATE (widget)]); -} - -static void -gtk_combo_box_button_toggled (GtkWidget *widget, - gpointer data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (data); - - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) - { - if (!combo_box->priv->popup_in_progress) - gtk_combo_box_popup (combo_box); - } - else - gtk_combo_box_popdown (combo_box); -} - -static void -gtk_combo_box_add (GtkContainer *container, - GtkWidget *widget) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (container); - - if (combo_box->priv->cell_view && combo_box->priv->cell_view->parent) - { - gtk_widget_unparent (combo_box->priv->cell_view); - GTK_BIN (container)->child = NULL; - gtk_widget_queue_resize (GTK_WIDGET (container)); - } - - gtk_widget_set_parent (widget, GTK_WIDGET (container)); - GTK_BIN (container)->child = widget; - - if (combo_box->priv->cell_view && - widget != combo_box->priv->cell_view) - { - /* since the cell_view was unparented, it's gone now */ - combo_box->priv->cell_view = NULL; - - if (!combo_box->priv->tree_view && combo_box->priv->separator) - { - gtk_container_remove (GTK_CONTAINER (combo_box->priv->separator->parent), - combo_box->priv->separator); - combo_box->priv->separator = NULL; - - gtk_widget_queue_resize (GTK_WIDGET (container)); - } - else if (combo_box->priv->cell_view_frame) - { - gtk_widget_unparent (combo_box->priv->cell_view_frame); - combo_box->priv->cell_view_frame = NULL; - } - } -} - -static void -gtk_combo_box_remove (GtkContainer *container, - GtkWidget *widget) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (container); - gboolean appears_as_list; - - gtk_widget_unparent (widget); - GTK_BIN (container)->child = NULL; - - if (combo_box->priv->destroying) - return; - - gtk_widget_queue_resize (GTK_WIDGET (container)); - - if (!combo_box->priv->tree_view) - appears_as_list = FALSE; - else - appears_as_list = TRUE; - - if (appears_as_list) - gtk_combo_box_list_destroy (combo_box); - else if (GTK_IS_MENU (combo_box->priv->popup_widget)) - { - gtk_combo_box_menu_destroy (combo_box); - gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget)); - combo_box->priv->popup_widget = NULL; - } - - if (!combo_box->priv->cell_view) - { - combo_box->priv->cell_view = gtk_cell_view_new (); - gtk_widget_set_parent (combo_box->priv->cell_view, GTK_WIDGET (container)); - GTK_BIN (container)->child = combo_box->priv->cell_view; - - gtk_widget_show (combo_box->priv->cell_view); - gtk_cell_view_set_model (GTK_CELL_VIEW (combo_box->priv->cell_view), - combo_box->priv->model); - cell_view_sync_cells (combo_box, GTK_CELL_VIEW (combo_box->priv->cell_view)); - } - - - if (appears_as_list) - gtk_combo_box_list_setup (combo_box); - else - gtk_combo_box_menu_setup (combo_box, TRUE); - - gtk_combo_box_set_active_internal (combo_box, combo_box->priv->active_item); -} - -static ComboCellInfo * -gtk_combo_box_get_cell_info (GtkComboBox *combo_box, - GtkCellRenderer *cell) -{ - GSList *i; - - for (i = combo_box->priv->cells; i; i = i->next) - { - ComboCellInfo *info = (ComboCellInfo *)i->data; - - if (info && info->cell == cell) - return info; - } - - return NULL; -} - -static void -gtk_combo_box_menu_show (GtkWidget *menu, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button), - TRUE); - combo_box->priv->popup_in_progress = FALSE; -} - -static void -gtk_combo_box_menu_hide (GtkWidget *menu, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button), - FALSE); -} - -static void -gtk_combo_box_detacher (GtkWidget *widget, - GtkMenu *menu) -{ - GtkComboBox *combo_box; - - g_return_if_fail (GTK_IS_COMBO_BOX (widget)); - - combo_box = GTK_COMBO_BOX (widget); - g_return_if_fail (combo_box->priv->popup_widget == (GtkWidget*) menu); - - g_signal_handlers_disconnect_by_func (menu, - gtk_combo_box_menu_show, - combo_box); - g_signal_handlers_disconnect_by_func (menu, - gtk_combo_box_menu_hide, - combo_box); - - combo_box->priv->popup_widget = NULL; -} - -static void -gtk_combo_box_set_popup_widget (GtkComboBox *combo_box, - GtkWidget *popup) -{ - if (GTK_IS_MENU (combo_box->priv->popup_widget)) - { - gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget)); - combo_box->priv->popup_widget = NULL; - } - else if (combo_box->priv->popup_widget) - { - gtk_container_remove (GTK_CONTAINER (combo_box->priv->popup_frame), - combo_box->priv->popup_widget); - g_object_unref (G_OBJECT (combo_box->priv->popup_widget)); - combo_box->priv->popup_widget = NULL; - } - - if (GTK_IS_MENU (popup)) - { - if (combo_box->priv->popup_window) - { - gtk_widget_destroy (combo_box->priv->popup_window); - combo_box->priv->popup_window = NULL; - combo_box->priv->popup_frame = NULL; - } - - combo_box->priv->popup_widget = popup; - - g_signal_connect (popup, "show", - G_CALLBACK (gtk_combo_box_menu_show), combo_box); - g_signal_connect (popup, "hide", - G_CALLBACK (gtk_combo_box_menu_hide), combo_box); - - gtk_menu_attach_to_widget (GTK_MENU (popup), - GTK_WIDGET (combo_box), - gtk_combo_box_detacher); - } - else - { - if (!combo_box->priv->popup_window) - { - combo_box->priv->popup_window = gtk_window_new (GTK_WINDOW_POPUP); - gtk_window_set_resizable (GTK_WINDOW (combo_box->priv->popup_window), FALSE); -#if GTK_CHECK_VERSION(2,2,0) - gtk_window_set_screen (GTK_WINDOW (combo_box->priv->popup_window), - gtk_widget_get_screen (GTK_WIDGET (combo_box))); -#endif - - combo_box->priv->popup_frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (combo_box->priv->popup_frame), - GTK_SHADOW_ETCHED_IN); - gtk_container_add (GTK_CONTAINER (combo_box->priv->popup_window), - combo_box->priv->popup_frame); - - gtk_widget_show (combo_box->priv->popup_frame); - } - - gtk_container_add (GTK_CONTAINER (combo_box->priv->popup_frame), - popup); - gtk_widget_show (popup); - g_object_ref (G_OBJECT (popup)); - combo_box->priv->popup_widget = popup; - } -} - -#if GTK_CHECK_VERSION(2,2,0) -static void -gtk_combo_box_menu_position_below (GtkMenu *menu, - gint *x, - gint *y, - gint *push_in, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - gint sx, sy; - GtkWidget *child; - GtkRequisition req; - GdkScreen *screen; - gint monitor_num; - GdkRectangle monitor; - - /* FIXME: is using the size request here broken? */ - child = GTK_BIN (combo_box)->child; - - gdk_window_get_origin (child->window, &sx, &sy); - - if (GTK_WIDGET_NO_WINDOW (child)) - { - sx += child->allocation.x; - sy += child->allocation.y; - } - - gtk_widget_size_request (GTK_WIDGET (menu), &req); - - if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_LTR) - *x = sx; - else - *x = sx + child->allocation.width - req.width; - *y = sy; - - screen = gtk_widget_get_screen (GTK_WIDGET (combo_box)); - monitor_num = gdk_screen_get_monitor_at_window (screen, - GTK_WIDGET (combo_box)->window); - gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); - - if (*x < monitor.x) - *x = monitor.x; - else if (*x + req.width > monitor.x + monitor.width) - *x = monitor.x + monitor.width - req.width; - - if (monitor.y + monitor.height - *y - child->allocation.height >= req.height) - *y += child->allocation.height; - else if (*y - monitor.y >= req.height) - *y -= req.height; - else if (monitor.y + monitor.height - *y - child->allocation.height > *y - monitor.y) - *y += child->allocation.height; - else - *y -= req.height; - - *push_in = FALSE; -} - -static void -gtk_combo_box_menu_position_over (GtkMenu *menu, - gint *x, - gint *y, - gboolean *push_in, - gpointer user_data) -{ - GtkComboBox *combo_box; - GtkWidget *active; - GtkWidget *child; - GtkWidget *widget; - GtkRequisition requisition; - GList *children; - gint screen_width; - gint menu_xpos; - gint menu_ypos; - gint menu_width; - - g_return_if_fail (GTK_IS_COMBO_BOX (user_data)); - - combo_box = GTK_COMBO_BOX (user_data); - widget = GTK_WIDGET (combo_box); - - gtk_widget_get_child_requisition (GTK_WIDGET (menu), &requisition); - menu_width = requisition.width; - - active = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget)); - gdk_window_get_origin (widget->window, &menu_xpos, &menu_ypos); - - menu_xpos += widget->allocation.x; - menu_ypos += widget->allocation.y + widget->allocation.height / 2 - 2; - - if (active != NULL) - { - gtk_widget_get_child_requisition (active, &requisition); - menu_ypos -= requisition.height / 2; - } - - children = GTK_MENU_SHELL (combo_box->priv->popup_widget)->children; - while (children) - { - child = children->data; - - if (active == child) - break; - - if (GTK_WIDGET_VISIBLE (child)) - { - gtk_widget_get_child_requisition (child, &requisition); - menu_ypos -= requisition.height; - } - - children = children->next; - } - - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - menu_xpos = menu_xpos + widget->allocation.width - menu_width; - - /* Clamp the position on screen */ - screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget)); - - if (menu_xpos < 0) - menu_xpos = 0; - else if ((menu_xpos + menu_width) > screen_width) - menu_xpos -= ((menu_xpos + menu_width) - screen_width); - - *x = menu_xpos; - *y = menu_ypos; - - *push_in = TRUE; -} - -static void -gtk_combo_box_menu_position (GtkMenu *menu, - gint *x, - gint *y, - gint *push_in, - gpointer user_data) -{ - GtkComboBox *combo_box; - GtkWidget *menu_item; - - combo_box = GTK_COMBO_BOX (user_data); - - if (combo_box->priv->wrap_width > 0 || combo_box->priv->cell_view == NULL) - gtk_combo_box_menu_position_below (menu, x, y, push_in, user_data); - else - { - menu_item = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget)); - if (menu_item) - gtk_menu_shell_select_item (GTK_MENU_SHELL (combo_box->priv->popup_widget), - menu_item); - - gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data); - } - -} -#endif /* Gtk 2.2 */ - -static void -gtk_combo_box_list_position (GtkComboBox *combo_box, - gint *x, - gint *y, - gint *width, - gint *height) -{ - GtkWidget *sample; - GtkRequisition popup_req; -#if GTK_CHECK_VERSION(2,2,0) - GdkScreen *screen; - gint monitor_num; - GdkRectangle monitor; -#endif - - sample = GTK_BIN (combo_box)->child; - - *width = sample->allocation.width; - gtk_widget_size_request (combo_box->priv->popup_window, &popup_req); - *height = popup_req.height; - - gdk_window_get_origin (sample->window, x, y); - - if (combo_box->priv->cell_view_frame) - { - *x -= GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + - GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness; - *width += 2 * (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + - GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness); - } - - if (GTK_WIDGET_NO_WINDOW (sample)) - { - *x += sample->allocation.x; - *y += sample->allocation.y; - } - -#if GTK_CHECK_VERSION(2,2,0) - screen = gtk_widget_get_screen (GTK_WIDGET (combo_box)); - monitor_num = gdk_screen_get_monitor_at_window (screen, - GTK_WIDGET (combo_box)->window); - gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); - - if (*x < monitor.x) - *x = monitor.x; - else if (*x + *width > monitor.x + monitor.width) - *x = monitor.x + monitor.width - *width; - - if (*y + sample->allocation.height + *height <= monitor.y + monitor.height) - *y += sample->allocation.height; - else - *y -= *height; -#endif /* Gtk 2.2 */ -} - -/** - * gtk_combo_box_popup: - * @combo_box: a #GtkComboBox - * - * Pops up the menu or dropdown list of @combo_box. - * - * This function is mostly intended for use by accessibility technologies; - * applications should have little use for it. - * - * Since: 2.4 - **/ -void -gtk_combo_box_popup (GtkComboBox *combo_box) -{ - gint x, y, width, height; - - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - - if (GTK_WIDGET_MAPPED (combo_box->priv->popup_widget)) - return; - - if (GTK_IS_MENU (combo_box->priv->popup_widget)) - { - gtk_menu_set_active (GTK_MENU (combo_box->priv->popup_widget), - combo_box->priv->active_item); - - if (combo_box->priv->wrap_width == 0) - { - GtkRequisition requisition; - - width = GTK_WIDGET (combo_box)->allocation.width; - gtk_widget_size_request (combo_box->priv->popup_widget, &requisition); - - gtk_widget_set_size_request (combo_box->priv->popup_widget, - MAX (width, requisition.width), -1); - } - - gtk_menu_popup (GTK_MENU (combo_box->priv->popup_widget), - NULL, NULL, -#if GTK_CHECK_VERSION(2,2,0) - gtk_combo_box_menu_position, -#else - NULL, -#endif - combo_box, 0, 0); - return; - } - - gtk_widget_show_all (combo_box->priv->popup_frame); - gtk_combo_box_list_position (combo_box, &x, &y, &width, &height); - - gtk_widget_set_size_request (combo_box->priv->popup_window, width, -1); - gtk_window_move (GTK_WINDOW (combo_box->priv->popup_window), x, y); - - /* popup */ - gtk_widget_show (combo_box->priv->popup_window); - - gtk_widget_grab_focus (combo_box->priv->popup_window); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button), - TRUE); - - if (!GTK_WIDGET_HAS_FOCUS (combo_box->priv->tree_view)) - { - gdk_keyboard_grab (combo_box->priv->popup_window->window, - FALSE, GDK_CURRENT_TIME); - gtk_widget_grab_focus (combo_box->priv->tree_view); - } - - gtk_grab_add (combo_box->priv->popup_window); - gdk_pointer_grab (combo_box->priv->popup_window->window, TRUE, - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_MASK, - NULL, NULL, GDK_CURRENT_TIME); - - gtk_grab_add (combo_box->priv->tree_view); -} - -/** - * gtk_combo_box_popdown: - * @combo_box: a #GtkComboBox - * - * Hides the menu or dropdown list of @combo_box. - * - * This function is mostly intended for use by accessibility technologies; - * applications should have little use for it. - * - * Since: 2.4 - **/ -void -gtk_combo_box_popdown (GtkComboBox *combo_box) -{ - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - - if (!GTK_WIDGET_REALIZED (GTK_WIDGET (combo_box))) - return; - - if (GTK_IS_MENU (combo_box->priv->popup_widget)) - { - gtk_menu_popdown (GTK_MENU (combo_box->priv->popup_widget)); - return; - } - - gtk_combo_box_list_remove_grabs (combo_box); - gtk_widget_hide_all (combo_box->priv->popup_window); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button), - FALSE); -} - -static gint -gtk_combo_box_calc_requested_width (GtkComboBox *combo_box, - GtkTreePath *path) -{ - gint padding; - GtkRequisition req; - - if (combo_box->priv->cell_view) - gtk_widget_style_get (combo_box->priv->cell_view, - "focus-line-width", &padding, - NULL); - else - padding = 0; - - /* add some pixels for good measure */ - padding += BONUS_PADDING; - - if (combo_box->priv->cell_view) - gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (combo_box->priv->cell_view), - path, &req); - else - req.width = 0; - - return req.width + padding; -} - -static void -gtk_combo_box_remeasure (GtkComboBox *combo_box) -{ - GtkTreeIter iter; - GtkTreePath *path; - gint padding = 0; - - if (!combo_box->priv->model || - !gtk_tree_model_get_iter_first (combo_box->priv->model, &iter)) - return; - - combo_box->priv->width = 0; - -#if GTK_CHECK_VERSION(2,2,0) - path = gtk_tree_path_new_from_indices (0, -1); -#else - path = gtk_tree_path_new_first(); -#endif - - if (combo_box->priv->cell_view) - gtk_widget_style_get (combo_box->priv->cell_view, - "focus-line-width", &padding, - NULL); - else - padding = 0; - - /* add some pixels for good measure */ - padding += BONUS_PADDING; - - do - { - GtkRequisition req; - - if (combo_box->priv->cell_view) - gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (combo_box->priv->cell_view), - path, &req); - else - req.width = 0; - - combo_box->priv->width = MAX (combo_box->priv->width, - req.width + padding); - - gtk_tree_path_next (path); - } - while (gtk_tree_model_iter_next (combo_box->priv->model, &iter)); - - gtk_tree_path_free (path); -} - -static void -gtk_combo_box_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - gint width, height; - GtkRequisition bin_req; - - GtkComboBox *combo_box = GTK_COMBO_BOX (widget); - - /* common */ - gtk_widget_size_request (GTK_BIN (widget)->child, &bin_req); - gtk_combo_box_remeasure (combo_box); - bin_req.width = MAX (bin_req.width, combo_box->priv->width); - - gtk_combo_box_check_appearance (combo_box); - - if (!combo_box->priv->tree_view) - { - /* menu mode */ - - if (combo_box->priv->cell_view) - { - GtkRequisition button_req, sep_req, arrow_req; - gint border_width, xthickness, ythickness; - - gtk_widget_size_request (combo_box->priv->button, &button_req); - border_width = GTK_CONTAINER (combo_box->priv->button)->border_width; - xthickness = combo_box->priv->button->style->xthickness; - ythickness = combo_box->priv->button->style->ythickness; - - bin_req.width = MAX (bin_req.width, combo_box->priv->width); - - gtk_widget_size_request (combo_box->priv->separator, &sep_req); - gtk_widget_size_request (combo_box->priv->arrow, &arrow_req); - - height = MAX (sep_req.height, arrow_req.height); - height = MAX (height, bin_req.height); - - width = bin_req.width + sep_req.width + arrow_req.width; - - height += border_width + 1 + ythickness * 2 + 4; - width += border_width + 1 + xthickness * 2 + 4; - - requisition->width = width; - requisition->height = height; - } - else - { - GtkRequisition but_req; - - gtk_widget_size_request (combo_box->priv->button, &but_req); - - requisition->width = bin_req.width + but_req.width; - requisition->height = MAX (bin_req.height, but_req.height); - } - } - else - { - /* list mode */ - GtkRequisition button_req, frame_req; - - /* sample + frame */ - *requisition = bin_req; - - if (combo_box->priv->cell_view_frame) - { - gtk_widget_size_request (combo_box->priv->cell_view_frame, &frame_req); - requisition->width += 2 * - (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + - GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness); - requisition->height += 2 * - (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + - GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness); - } - - /* the button */ - gtk_widget_size_request (combo_box->priv->button, &button_req); - - requisition->height = MAX (requisition->height, button_req.height); - requisition->width += button_req.width; - } -} - -static void -gtk_combo_box_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (widget); - GtkAllocation child; - GtkRequisition req; - gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL; - - widget->allocation = *allocation; - - gtk_combo_box_check_appearance (combo_box); - - if (!combo_box->priv->tree_view) - { - if (combo_box->priv->cell_view) - { - gint border_width, xthickness, ythickness; - gint width; - - /* menu mode */ - gtk_widget_size_allocate (combo_box->priv->button, allocation); - - /* set some things ready */ - border_width = GTK_CONTAINER (combo_box->priv->button)->border_width; - xthickness = combo_box->priv->button->style->xthickness; - ythickness = combo_box->priv->button->style->ythickness; - - child.x = allocation->x + border_width + 1 + xthickness + 2; - child.y = allocation->y + border_width + 1 + ythickness + 2; - - width = MAX(1, allocation->width - (border_width + 1 + xthickness * 2 + 4)); - - /* handle the children */ - gtk_widget_size_request (combo_box->priv->arrow, &req); - child.width = req.width; - child.height = MAX(1, allocation->height - 2 * (child.y - allocation->y)); - if (!is_rtl) - child.x += width - req.width; - gtk_widget_size_allocate (combo_box->priv->arrow, &child); - if (is_rtl) - child.x += req.width; - gtk_widget_size_request (combo_box->priv->separator, &req); - child.width = req.width; - if (!is_rtl) - child.x -= req.width; - gtk_widget_size_allocate (combo_box->priv->separator, &child); - - if (is_rtl) - { - child.x += req.width; - child.width = MAX(1, allocation->x + allocation->width - - (border_width + 1 + xthickness + 2) - child.x); - } - else - { - child.width = child.x; - child.x = allocation->x + border_width + 1 + xthickness + 2; - child.width = MAX(1, child.width - child.x); - } - - gtk_widget_size_allocate (GTK_BIN (widget)->child, &child); - } - else - { - gtk_widget_size_request (combo_box->priv->button, &req); - if (is_rtl) - child.x = allocation->x; - else - child.x = allocation->x + allocation->width - req.width; - child.y = allocation->y; - child.width = req.width; - child.height = allocation->height; - gtk_widget_size_allocate (combo_box->priv->button, &child); - - if (is_rtl) - child.x = allocation->x + req.width; - else - child.x = allocation->x; - child.y = allocation->y; - child.width = MAX(1, allocation->width - req.width); - gtk_widget_size_allocate (GTK_BIN (widget)->child, &child); - } - } - else - { - /* list mode */ - - /* button */ - gtk_widget_size_request (combo_box->priv->button, &req); - if (is_rtl) - child.x = allocation->x; - else - child.x = allocation->x + allocation->width - req.width; - child.y = allocation->y; - child.width = req.width; - child.height = allocation->height; - gtk_widget_size_allocate (combo_box->priv->button, &child); - - /* frame */ - if (is_rtl) - child.x = allocation->x + req.width; - else - child.x = allocation->x; - child.y = allocation->y; - child.width = MAX (1, allocation->width - req.width); - child.height = allocation->height; - - if (combo_box->priv->cell_view_frame) - { - gtk_widget_size_allocate (combo_box->priv->cell_view_frame, &child); - - /* the sample */ - child.x += - GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + - GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness; - child.y += - GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + - GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness; - child.width -= 2 * ( - GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + - GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness); - child.width = MAX(1,child.width); - child.height -= 2 * ( - GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + - GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness); - child.height = MAX(1,child.height); - } - - gtk_widget_size_allocate (GTK_BIN (combo_box)->child, &child); - } -} - -static void -gtk_combo_box_unset_model (GtkComboBox *combo_box) -{ - if (combo_box->priv->model) - { - g_signal_handler_disconnect (combo_box->priv->model, - combo_box->priv->inserted_id); - g_signal_handler_disconnect (combo_box->priv->model, - combo_box->priv->deleted_id); - g_signal_handler_disconnect (combo_box->priv->model, - combo_box->priv->reordered_id); - g_signal_handler_disconnect (combo_box->priv->model, - combo_box->priv->changed_id); - } - - /* menu mode */ - if (!combo_box->priv->tree_view) - { - if (combo_box->priv->popup_widget) - gtk_container_foreach (GTK_CONTAINER (combo_box->priv->popup_widget), - (GtkCallback)gtk_widget_destroy, NULL); - } - - if (combo_box->priv->model) - { - g_object_unref (G_OBJECT (combo_box->priv->model)); - combo_box->priv->model = NULL; - } - - if (combo_box->priv->cell_view) - gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (combo_box->priv->cell_view), NULL); -} - -static void -gtk_combo_box_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (container); - - if (include_internals) - { - if (combo_box->priv->button) - (* callback) (combo_box->priv->button, callback_data); - if (combo_box->priv->cell_view_frame) - (* callback) (combo_box->priv->cell_view_frame, callback_data); - } - - if (GTK_BIN (container)->child) - (* callback) (GTK_BIN (container)->child, callback_data); -} - -static gboolean -gtk_combo_box_expose_event (GtkWidget *widget, - GdkEventExpose *event) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (widget); - - if (!combo_box->priv->tree_view) - { - gtk_container_propagate_expose (GTK_CONTAINER (widget), - combo_box->priv->button, event); - } - else - { - gtk_container_propagate_expose (GTK_CONTAINER (widget), - combo_box->priv->button, event); - - if (combo_box->priv->cell_view_frame) - gtk_container_propagate_expose (GTK_CONTAINER (widget), - combo_box->priv->cell_view_frame, event); - } - - gtk_container_propagate_expose (GTK_CONTAINER (widget), - GTK_BIN (widget)->child, event); - - return FALSE; -} - -static gboolean -gtk_combo_box_scroll_event (GtkWidget *widget, - GdkEventScroll *event) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (widget); - gint index; - gint items; - - index = gtk_combo_box_get_active (combo_box); - - if (index != -1) - { - items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL); - - if (event->direction == GDK_SCROLL_UP) - index--; - else - index++; - - gtk_combo_box_set_active (combo_box, CLAMP (index, 0, items - 1)); - } - - return TRUE; -} - -/* - * menu style - */ - -static void -cell_view_sync_cells (GtkComboBox *combo_box, - GtkCellView *cell_view) -{ - GSList *k; - - for (k = combo_box->priv->cells; k; k = k->next) - { - GSList *j; - ComboCellInfo *info = (ComboCellInfo *)k->data; - - if (info->pack == GTK_PACK_START) - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cell_view), - info->cell, info->expand); - else if (info->pack == GTK_PACK_END) - gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (cell_view), - info->cell, info->expand); - - gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (cell_view), - info->cell, - info->func, info->func_data, NULL); - - for (j = info->attributes; j; j = j->next->next) - { - gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (cell_view), - info->cell, - j->data, - GPOINTER_TO_INT (j->next->data)); - } - } -} - -static void -gtk_combo_box_menu_setup (GtkComboBox *combo_box, - gboolean add_children) -{ - GtkWidget *menu; - - if (combo_box->priv->cell_view) - { - combo_box->priv->button = gtk_toggle_button_new (); - g_signal_connect (combo_box->priv->button, "toggled", - G_CALLBACK (gtk_combo_box_button_toggled), combo_box); - g_signal_connect_after (combo_box->priv->button, "key_press_event", - G_CALLBACK (gtk_combo_box_key_press), combo_box); - gtk_widget_set_parent (combo_box->priv->button, - GTK_BIN (combo_box)->child->parent); - - combo_box->priv->box = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (combo_box->priv->button), - combo_box->priv->box); - - combo_box->priv->separator = gtk_vseparator_new (); - gtk_container_add (GTK_CONTAINER (combo_box->priv->box), - combo_box->priv->separator); - - combo_box->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); - gtk_container_add (GTK_CONTAINER (combo_box->priv->box), - combo_box->priv->arrow); - - gtk_widget_show_all (combo_box->priv->button); - } - else - { - combo_box->priv->button = gtk_toggle_button_new (); - g_signal_connect (combo_box->priv->button, "toggled", - G_CALLBACK (gtk_combo_box_button_toggled), combo_box); - g_signal_connect_after (combo_box, "key_press_event", - G_CALLBACK (gtk_combo_box_key_press), combo_box); - gtk_widget_set_parent (combo_box->priv->button, - GTK_BIN (combo_box)->child->parent); - - combo_box->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); - gtk_container_add (GTK_CONTAINER (combo_box->priv->button), - combo_box->priv->arrow); - gtk_widget_show_all (combo_box->priv->button); - } - - g_signal_connect (combo_box->priv->button, "button_press_event", - G_CALLBACK (gtk_combo_box_menu_button_press), - combo_box); - - /* create our funky menu */ - menu = gtk_menu_new (); - g_signal_connect (menu, "key_press_event", - G_CALLBACK (gtk_combo_box_menu_key_press), combo_box); - gtk_combo_box_set_popup_widget (combo_box, menu); - - /* add items */ - if (add_children) - gtk_combo_box_menu_fill (combo_box); - -} - -static void -gtk_combo_box_menu_fill (GtkComboBox *combo_box) -{ - gint i, items; - GtkWidget *menu; - GtkWidget *tmp; - - if (!combo_box->priv->model) - return; - - items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL); - menu = combo_box->priv->popup_widget; - - for (i = 0; i < items; i++) - { - GtkTreePath *path; -#if GTK_CHECK_VERSION(2,2,0) - path = gtk_tree_path_new_from_indices (i, -1); -#else - char buf[32]; - g_snprintf(buf, sizeof(buf), "%d", i); - path = gtk_tree_path_new_from_string(buf); -#endif - tmp = gtk_cell_view_menu_item_new_from_model (combo_box->priv->model, - path); - g_signal_connect (tmp, "activate", - G_CALLBACK (gtk_combo_box_menu_item_activate), - combo_box); - - cell_view_sync_cells (combo_box, - GTK_CELL_VIEW (GTK_BIN (tmp)->child)); - - gtk_menu_shell_append (GTK_MENU_SHELL (menu), tmp); - - if (combo_box->priv->wrap_width) - gtk_combo_box_relayout_item (combo_box, i); - - gtk_widget_show (tmp); - - gtk_tree_path_free (path); - } -} - -static void -gtk_combo_box_menu_destroy (GtkComboBox *combo_box) -{ - g_signal_handlers_disconnect_matched (combo_box->priv->button, - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, - gtk_combo_box_menu_button_press, NULL); - - /* unparent will remove our latest ref */ - gtk_widget_unparent (combo_box->priv->button); - - combo_box->priv->box = NULL; - combo_box->priv->button = NULL; - combo_box->priv->arrow = NULL; - combo_box->priv->separator = NULL; - - /* changing the popup window will unref the menu and the children */ -} - -/* - * grid - */ - -static void -gtk_combo_box_item_get_size (GtkComboBox *combo_box, - gint index_, - gint *cols, - gint *rows) -{ - GtkTreeIter iter; - - gtk_tree_model_iter_nth_child (combo_box->priv->model, &iter, NULL, index_); - - if (cols) - { - if (combo_box->priv->col_column == -1) - *cols = 1; - else - gtk_tree_model_get (combo_box->priv->model, &iter, - combo_box->priv->col_column, cols, - -1); - } - - if (rows) - { - if (combo_box->priv->row_column == -1) - *rows = 1; - else - gtk_tree_model_get (combo_box->priv->model, &iter, - combo_box->priv->row_column, rows, - -1); - } -} - -static gboolean -menu_occupied (GtkMenu *menu, - guint left_attach, - guint right_attach, - guint top_attach, - guint bottom_attach) -{ - GList *i; - - g_return_val_if_fail (GTK_IS_MENU (menu), TRUE); - g_return_val_if_fail (left_attach < right_attach, TRUE); - g_return_val_if_fail (top_attach < bottom_attach, TRUE); - - for (i = GTK_MENU_SHELL (menu)->children; i; i = i->next) - { - guint l, r, b, t; - gboolean h_intersect = FALSE; - gboolean v_intersect = FALSE; - - gtk_container_child_get (GTK_CONTAINER (menu), i->data, - "left_attach", &l, - "right_attach", &r, - "bottom_attach", &b, - "top_attach", &t, - NULL); - - /* look if this item intersects with the given coordinates */ - h_intersect = left_attach <= l && l <= right_attach; - h_intersect &= left_attach <= r && r <= right_attach; - - v_intersect = top_attach <= t && t <= bottom_attach; - v_intersect &= top_attach <= b && b <= bottom_attach; - - if (h_intersect && v_intersect) - return TRUE; - } - - return FALSE; -} - -static void -gtk_combo_box_relayout_item (GtkComboBox *combo_box, - gint index) -{ - gint current_col = 0, current_row = 0; - gint rows, cols; - GList *list, *nth; - GtkWidget *item, *last; - GtkWidget *menu; - - menu = combo_box->priv->popup_widget; - if (!GTK_IS_MENU_SHELL (menu)) - return; - - list = gtk_container_get_children (GTK_CONTAINER (menu)); - nth = g_list_nth (list, index); - item = nth->data; - if (nth->prev) - last = nth->prev->data; - else - last = NULL; - g_list_free (list); - - gtk_combo_box_item_get_size (combo_box, index, &cols, &rows); - - if (combo_box->priv->col_column == -1 && - combo_box->priv->row_column == -1 && - last) - { - gtk_container_child_get (GTK_CONTAINER (menu), - last, - "right_attach", ¤t_col, - "top_attach", ¤t_row, - NULL); - if (current_col + cols > combo_box->priv->wrap_width) - { - current_col = 0; - current_row++; - } - } - else - { - /* look for a good spot */ - while (1) - { - if (current_col + cols > combo_box->priv->wrap_width) - { - current_col = 0; - current_row++; - } - - if (!menu_occupied (GTK_MENU (menu), - current_col, current_col + cols, - current_row, current_row + rows)) - break; - - current_col++; - } - } - - /* set attach props */ - gtk_menu_attach (GTK_MENU (menu), item, - current_col, current_col + cols, - current_row, current_row + rows); -} - -static void -gtk_combo_box_relayout (GtkComboBox *combo_box) -{ - GList *list, *j; - GtkWidget *menu; - - menu = combo_box->priv->popup_widget; - - /* do nothing unless we are in menu style and realized */ - if (combo_box->priv->tree_view || !GTK_IS_MENU_SHELL (menu)) - return; - - /* get rid of all children */ - list = gtk_container_get_children (GTK_CONTAINER (menu)); - - for (j = g_list_last (list); j; j = j->prev) - gtk_container_remove (GTK_CONTAINER (menu), j->data); - - g_list_free (list); - - /* and relayout */ - gtk_combo_box_menu_fill (combo_box); -} - -/* callbacks */ -static gboolean -gtk_combo_box_menu_button_press (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - - if (! GTK_IS_MENU (combo_box->priv->popup_widget)) - return FALSE; - - if (event->type == GDK_BUTTON_PRESS && event->button == 1) - { - combo_box->priv->popup_in_progress = TRUE; - - gtk_menu_set_active (GTK_MENU (combo_box->priv->popup_widget), - combo_box->priv->active_item); - - if (combo_box->priv->wrap_width == 0) - { - GtkRequisition requisition; - gint width; - - width = GTK_WIDGET (combo_box)->allocation.width; - gtk_widget_size_request (combo_box->priv->popup_widget, &requisition); - - gtk_widget_set_size_request (combo_box->priv->popup_widget, - MAX (width, requisition.width), -1); - } - - gtk_menu_popup (GTK_MENU (combo_box->priv->popup_widget), - NULL, NULL, -#if GTK_CHECK_VERSION(2,2,0) - gtk_combo_box_menu_position, -#else - NULL, -#endif - combo_box, event->button, event->time); - - return TRUE; - } - - return FALSE; -} - -static void -gtk_combo_box_menu_item_activate (GtkWidget *item, - gpointer user_data) -{ - gint index; - GtkWidget *menu; - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - - menu = combo_box->priv->popup_widget; - g_return_if_fail (GTK_IS_MENU (menu)); - - index = g_list_index (GTK_MENU_SHELL (menu)->children, item); - - gtk_combo_box_set_active (combo_box, index); -} - -static void -gtk_combo_box_model_row_inserted (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - gint index = gtk_tree_path_get_indices (path)[0]; - - if (combo_box->priv->active_item >= index) - combo_box->priv->active_item++; - - if (!combo_box->priv->tree_view) - gtk_combo_box_menu_row_inserted (model, path, iter, user_data); -} - -static void -gtk_combo_box_model_row_deleted (GtkTreeModel *model, - GtkTreePath *path, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - gint index = gtk_tree_path_get_indices (path)[0]; - - if (!combo_box->priv->tree_view) - gtk_combo_box_menu_row_deleted (model, path, user_data); - - if (index == combo_box->priv->active_item) - { - gint items = gtk_tree_model_iter_n_children (model, NULL); - - if (items == 0) - gtk_combo_box_set_active_internal (combo_box, -1); - else if (index == items) - gtk_combo_box_set_active_internal (combo_box, index - 1); - else - gtk_combo_box_set_active_internal (combo_box, index); - } - else if (combo_box->priv->active_item > index) - combo_box->priv->active_item--; -} - -static void -gtk_combo_box_model_rows_reordered (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gint *new_order, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - gint items = gtk_tree_model_iter_n_children (model, NULL); - gint i; - - for (i = 0; i < items; i++) - if (new_order[i] == combo_box->priv->active_item) - { - combo_box->priv->active_item = i; - break; - } - - if (!combo_box->priv->tree_view) - gtk_combo_box_menu_rows_reordered (model, path, iter, new_order, user_data); -} - -static void -gtk_combo_box_model_row_changed (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - gint index = gtk_tree_path_get_indices (path)[0]; - - if (index == combo_box->priv->active_item && - combo_box->priv->cell_view) - gtk_widget_queue_resize (GTK_WIDGET (combo_box->priv->cell_view)); - - if (combo_box->priv->tree_view) - gtk_combo_box_list_row_changed (model, path, iter, user_data); - else - gtk_combo_box_menu_row_changed (model, path, iter, user_data); -} - - -static void -gtk_combo_box_menu_row_inserted (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data) -{ - GtkWidget *menu; - GtkWidget *item; - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - - if (!combo_box->priv->popup_widget) - return; - - menu = combo_box->priv->popup_widget; - g_return_if_fail (GTK_IS_MENU (menu)); - - item = gtk_cell_view_menu_item_new_from_model (model, path); - g_signal_connect (item, "activate", - G_CALLBACK (gtk_combo_box_menu_item_activate), - combo_box); - - cell_view_sync_cells (combo_box, GTK_CELL_VIEW (GTK_BIN (item)->child)); - - gtk_menu_shell_insert (GTK_MENU_SHELL (menu), item, - gtk_tree_path_get_indices (path)[0]); - gtk_widget_show (item); -} - -static void -gtk_combo_box_menu_row_deleted (GtkTreeModel *model, - GtkTreePath *path, - gpointer user_data) -{ - gint index; - GtkWidget *menu; - GtkWidget *item; - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - - if (!combo_box->priv->popup_widget) - return; - - index = gtk_tree_path_get_indices (path)[0]; - - menu = combo_box->priv->popup_widget; - g_return_if_fail (GTK_IS_MENU (menu)); - - item = g_list_nth_data (GTK_MENU_SHELL (menu)->children, index); - g_return_if_fail (GTK_IS_MENU_ITEM (item)); - - gtk_container_remove (GTK_CONTAINER (menu), item); -} - -static void -gtk_combo_box_menu_rows_reordered (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gint *new_order, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - - gtk_combo_box_relayout (combo_box); -} - -static void -gtk_combo_box_menu_row_changed (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - gint width; - - if (!combo_box->priv->popup_widget) - return; - - if (combo_box->priv->wrap_width) - gtk_combo_box_relayout_item (combo_box, - gtk_tree_path_get_indices (path)[0]); - - width = gtk_combo_box_calc_requested_width (combo_box, path); - - if (width > combo_box->priv->width) - { - if (combo_box->priv->cell_view) - { - gtk_widget_set_size_request (combo_box->priv->cell_view, width, -1); - gtk_widget_queue_resize (combo_box->priv->cell_view); - } - combo_box->priv->width = width; - } -} - -/* - * list style - */ - -static void -gtk_combo_box_list_setup (GtkComboBox *combo_box) -{ - GSList *i; - GtkTreeSelection *sel; - - combo_box->priv->button = gtk_toggle_button_new (); - gtk_widget_set_parent (combo_box->priv->button, - GTK_BIN (combo_box)->child->parent); - g_signal_connect (combo_box->priv->button, "button_press_event", - G_CALLBACK (gtk_combo_box_list_button_pressed), combo_box); - g_signal_connect (combo_box->priv->button, "toggled", - G_CALLBACK (gtk_combo_box_button_toggled), combo_box); - g_signal_connect_after (combo_box, "key_press_event", - G_CALLBACK (gtk_combo_box_key_press), combo_box); - - combo_box->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); - gtk_container_add (GTK_CONTAINER (combo_box->priv->button), - combo_box->priv->arrow); - combo_box->priv->separator = NULL; - gtk_widget_show_all (combo_box->priv->button); - - if (combo_box->priv->cell_view) - { - combo_box->priv->cell_view_frame = gtk_frame_new (NULL); - gtk_widget_set_parent (combo_box->priv->cell_view_frame, - GTK_BIN (combo_box)->child->parent); - gtk_frame_set_shadow_type (GTK_FRAME (combo_box->priv->cell_view_frame), - GTK_SHADOW_IN); - - gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view), - >K_WIDGET (combo_box)->style->base[GTK_WIDGET_STATE (combo_box)]); - - combo_box->priv->box = gtk_event_box_new (); - /* - gtk_event_box_set_visible_window (GTK_EVENT_BOX (combo_box->priv->box), - FALSE); - */ - - gtk_container_add (GTK_CONTAINER (combo_box->priv->cell_view_frame), - combo_box->priv->box); - - gtk_widget_show_all (combo_box->priv->cell_view_frame); - - g_signal_connect (combo_box->priv->box, "button_press_event", - G_CALLBACK (gtk_combo_box_list_button_pressed), - combo_box); - } - - combo_box->priv->tree_view = gtk_tree_view_new (); - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view)); - gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (combo_box->priv->tree_view), - FALSE); - /* - _gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (combo_box->priv->tree_view), - TRUE); - */ - if (combo_box->priv->model) - gtk_tree_view_set_model (GTK_TREE_VIEW (combo_box->priv->tree_view), - combo_box->priv->model); - - g_signal_connect (combo_box->priv->tree_view, "button_press_event", - G_CALLBACK (gtk_combo_box_list_button_pressed), - combo_box); - g_signal_connect (combo_box->priv->tree_view, "button_release_event", - G_CALLBACK (gtk_combo_box_list_button_released), - combo_box); - g_signal_connect (combo_box->priv->tree_view, "key_press_event", - G_CALLBACK (gtk_combo_box_list_key_press), - combo_box); - - combo_box->priv->column = gtk_tree_view_column_new (); - gtk_tree_view_append_column (GTK_TREE_VIEW (combo_box->priv->tree_view), - combo_box->priv->column); - - /* sync up */ - for (i = combo_box->priv->cells; i; i = i->next) - { - GSList *j; - ComboCellInfo *info = (ComboCellInfo *)i->data; - - if (info->pack == GTK_PACK_START) - gtk_tree_view_column_pack_start (combo_box->priv->column, - info->cell, info->expand); - else if (info->pack == GTK_PACK_END) - gtk_tree_view_column_pack_end (combo_box->priv->column, - info->cell, info->expand); - - for (j = info->attributes; j; j = j->next->next) - { - gtk_tree_view_column_add_attribute (combo_box->priv->column, - info->cell, - j->data, - GPOINTER_TO_INT (j->next->data)); - } - } - - if (combo_box->priv->active_item != -1) - { - GtkTreePath *path; - -#if GTK_CHECK_VERSION(2,2,0) - path = gtk_tree_path_new_from_indices (combo_box->priv->active_item, -1); -#else - char buf[32]; - g_snprintf(buf, sizeof(buf), "%d", combo_box->priv->active_item); - path = gtk_tree_path_new_from_string(buf); -#endif - if (path) - { - gtk_tree_view_set_cursor (GTK_TREE_VIEW (combo_box->priv->tree_view), - path, NULL, FALSE); - gtk_tree_path_free (path); - } - } - - /* set sample/popup widgets */ - gtk_combo_box_set_popup_widget (combo_box, combo_box->priv->tree_view); - - gtk_widget_show (combo_box->priv->tree_view); -} - -static void -gtk_combo_box_list_destroy (GtkComboBox *combo_box) -{ - /* disconnect signals */ - g_signal_handlers_disconnect_matched (combo_box->priv->tree_view, - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, combo_box); - g_signal_handlers_disconnect_matched (combo_box->priv->button, - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, - gtk_combo_box_list_button_pressed, - NULL); - if (combo_box->priv->box) - g_signal_handlers_disconnect_matched (combo_box->priv->box, - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, - gtk_combo_box_list_button_pressed, - NULL); - - /* destroy things (unparent will kill the latest ref from us) - * last unref on button will destroy the arrow - */ - gtk_widget_unparent (combo_box->priv->button); - combo_box->priv->button = NULL; - combo_box->priv->arrow = NULL; - - if (combo_box->priv->cell_view) - { - g_object_set (G_OBJECT (combo_box->priv->cell_view), - "background_set", FALSE, - NULL); - } - - if (combo_box->priv->cell_view_frame) - { - gtk_widget_unparent (combo_box->priv->cell_view_frame); - combo_box->priv->cell_view_frame = NULL; - combo_box->priv->box = NULL; - } - - gtk_widget_destroy (combo_box->priv->tree_view); - - combo_box->priv->tree_view = NULL; - combo_box->priv->popup_widget = NULL; -} - -/* callbacks */ -static void -gtk_combo_box_list_remove_grabs (GtkComboBox *combo_box) -{ - if (combo_box->priv->tree_view && - GTK_WIDGET_HAS_GRAB (combo_box->priv->tree_view)) - { - gtk_grab_remove (combo_box->priv->tree_view); - } - - if (combo_box->priv->popup_window && - GTK_WIDGET_HAS_GRAB (combo_box->priv->popup_window)) - { - gtk_grab_remove (combo_box->priv->popup_window); - gdk_keyboard_ungrab (GDK_CURRENT_TIME); - gdk_pointer_ungrab (GDK_CURRENT_TIME); - } -} - -static gboolean -gtk_combo_box_list_button_pressed (GtkWidget *widget, - GdkEventButton *event, - gpointer data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (data); - - GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event); - - if (ewidget == combo_box->priv->tree_view) - return TRUE; - - if ((ewidget != combo_box->priv->button && ewidget != combo_box->priv->box) || - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (combo_box->priv->button))) - return FALSE; - - gtk_combo_box_popup (combo_box); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button), - TRUE); - - combo_box->priv->popup_in_progress = TRUE; - - return TRUE; -} - -static gboolean -gtk_combo_box_list_button_released (GtkWidget *widget, - GdkEventButton *event, - gpointer data) -{ - gboolean ret; - GtkTreePath *path = NULL; - - GtkComboBox *combo_box = GTK_COMBO_BOX (data); - - gboolean popup_in_progress = FALSE; - - GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event); - - if (combo_box->priv->popup_in_progress) - { - popup_in_progress = TRUE; - combo_box->priv->popup_in_progress = FALSE; - } - - if (ewidget != combo_box->priv->tree_view) - { - if (ewidget == combo_box->priv->button && - !popup_in_progress && - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (combo_box->priv->button))) - { - gtk_combo_box_popdown (combo_box); - return TRUE; - } - - /* released outside treeview */ - if (ewidget != combo_box->priv->button) - { - gtk_combo_box_popdown (combo_box); - - return TRUE; - } - - return FALSE; - } - - /* select something cool */ - ret = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), - event->x, event->y, - &path, - NULL, NULL, NULL); - - if (!ret) - return TRUE; /* clicked outside window? */ - - gtk_combo_box_set_active (combo_box, gtk_tree_path_get_indices (path)[0]); - gtk_combo_box_popdown (combo_box); - - gtk_tree_path_free (path); - - return TRUE; -} - -static gboolean -gtk_combo_box_key_press (GtkWidget *widget, - GdkEventKey *event, - gpointer data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (data); - guint state = event->state & gtk_accelerator_get_default_mod_mask (); - gint items = 0; - gint index = gtk_combo_box_get_active (combo_box); - gint new_index; - - if (combo_box->priv->model) - items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL); - - if ((event->keyval == GDK_Down || event->keyval == GDK_KP_Down) && - state == GDK_MOD1_MASK) - { - gtk_combo_box_popup (combo_box); - - return TRUE; - } - - switch (event->keyval) - { - case GDK_Down: - case GDK_KP_Down: - new_index = index + 1; - break; - case GDK_Up: - case GDK_KP_Up: - new_index = index - 1; - break; - case GDK_Page_Up: - case GDK_KP_Page_Up: - case GDK_Home: - case GDK_KP_Home: - new_index = 0; - break; - case GDK_Page_Down: - case GDK_KP_Page_Down: - case GDK_End: - case GDK_KP_End: - new_index = items - 1; - break; - default: - return FALSE; - } - - if (items > 0) - gtk_combo_box_set_active (combo_box, CLAMP (new_index, 0, items - 1)); - - return TRUE; -} - -static gboolean -gtk_combo_box_menu_key_press (GtkWidget *widget, - GdkEventKey *event, - gpointer data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (data); - guint state = event->state & gtk_accelerator_get_default_mod_mask (); - - if ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) && - state == GDK_MOD1_MASK) - { - gtk_combo_box_popdown (combo_box); - - return TRUE; - } - - return FALSE; -} - -static gboolean -gtk_combo_box_list_key_press (GtkWidget *widget, - GdkEventKey *event, - gpointer data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (data); - guint state = event->state & gtk_accelerator_get_default_mod_mask (); - - if (event->keyval == GDK_Escape || - ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) && - state == GDK_MOD1_MASK)) - { - /* reset active item -- this is incredibly lame and ugly */ - gtk_combo_box_set_active (combo_box, - gtk_combo_box_get_active (combo_box)); - - gtk_combo_box_popdown (combo_box); - - return TRUE; - } - - if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter || - event->keyval == GDK_space || event->keyval == GDK_KP_Space) - { - gboolean ret = FALSE; - GtkTreeIter iter; - GtkTreeModel *model = NULL; - - if (combo_box->priv->model) - { - GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view)); - - ret = gtk_tree_selection_get_selected (sel, &model, &iter); - } - if (ret) - { - GtkTreePath *path; - - path = gtk_tree_model_get_path (model, &iter); - if (path) - { - gtk_combo_box_set_active (combo_box, gtk_tree_path_get_indices (path)[0]); - gtk_tree_path_free (path); - } - } - - gtk_combo_box_popdown (combo_box); - - return TRUE; - } - - return FALSE; -} - -static void -gtk_combo_box_list_row_changed (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (data); - gint width; - - width = gtk_combo_box_calc_requested_width (combo_box, path); - - if (width > combo_box->priv->width) - { - if (combo_box->priv->cell_view) - { - gtk_widget_set_size_request (combo_box->priv->cell_view, width, -1); - gtk_widget_queue_resize (combo_box->priv->cell_view); - } - combo_box->priv->width = width; - } -} - -/* - * GtkCellLayout implementation - */ -static void -gtk_combo_box_cell_layout_pack_start (GtkCellLayout *layout, - GtkCellRenderer *cell, - gboolean expand) -{ - ComboCellInfo *info; - GtkComboBox *combo_box; - GtkWidget *menu; - - g_return_if_fail (GTK_IS_COMBO_BOX (layout)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - - combo_box = GTK_COMBO_BOX (layout); - - g_object_ref (G_OBJECT (cell)); - gtk_object_sink (GTK_OBJECT (cell)); - - info = g_new0 (ComboCellInfo, 1); - info->cell = cell; - info->expand = expand; - info->pack = GTK_PACK_START; - - combo_box->priv->cells = g_slist_append (combo_box->priv->cells, info); - - if (combo_box->priv->cell_view) - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box->priv->cell_view), - cell, expand); - - if (combo_box->priv->column) - gtk_tree_view_column_pack_start (combo_box->priv->column, cell, expand); - - menu = combo_box->priv->popup_widget; - if (GTK_IS_MENU (menu)) - { - GList *i, *list; - - list = gtk_container_get_children (GTK_CONTAINER (menu)); - for (i = list; i; i = i->next) - { - GtkCellView *view; - - if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) - view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); - else - view = GTK_CELL_VIEW (i->data); - - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (view), cell, expand); - } - g_list_free (list); - } -} - -static void -gtk_combo_box_cell_layout_pack_end (GtkCellLayout *layout, - GtkCellRenderer *cell, - gboolean expand) -{ - ComboCellInfo *info; - GtkComboBox *combo_box; - GtkWidget *menu; - - g_return_if_fail (GTK_IS_COMBO_BOX (layout)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - - combo_box = GTK_COMBO_BOX (layout); - - g_object_ref (G_OBJECT (cell)); - gtk_object_sink (GTK_OBJECT (cell)); - - info = g_new0 (ComboCellInfo, 1); - info->cell = cell; - info->expand = expand; - info->pack = GTK_PACK_END; - - combo_box->priv->cells = g_slist_append (combo_box->priv->cells, info); - - if (combo_box->priv->cell_view) - gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (combo_box->priv->cell_view), - cell, expand); - - if (combo_box->priv->column) - gtk_tree_view_column_pack_end (combo_box->priv->column, cell, expand); - - menu = combo_box->priv->popup_widget; - if (GTK_IS_MENU (menu)) - { - GList *i, *list; - - list = gtk_container_get_children (GTK_CONTAINER (menu)); - for (i = list; i; i = i->next) - { - GtkCellView *view; - - if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) - view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); - else - view = GTK_CELL_VIEW (i->data); - - gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (view), cell, expand); - } - g_list_free (list); - } -} - -static void -gtk_combo_box_cell_layout_clear (GtkCellLayout *layout) -{ - GtkWidget *menu; - GtkComboBox *combo_box; - GSList *i; - - g_return_if_fail (GTK_IS_COMBO_BOX (layout)); - - combo_box = GTK_COMBO_BOX (layout); - - if (combo_box->priv->cell_view) - gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_box->priv->cell_view)); - - if (combo_box->priv->column) - gtk_tree_view_column_clear (combo_box->priv->column); - - for (i = combo_box->priv->cells; i; i = i->next) - { - ComboCellInfo *info = (ComboCellInfo *)i->data; - - gtk_combo_box_cell_layout_clear_attributes (layout, info->cell); - g_object_unref (G_OBJECT (info->cell)); - g_free (info); - i->data = NULL; - } - g_slist_free (combo_box->priv->cells); - combo_box->priv->cells = NULL; - - menu = combo_box->priv->popup_widget; - if (GTK_IS_MENU (menu)) - { - GList *i, *list; - - list = gtk_container_get_children (GTK_CONTAINER (menu)); - for (i = list; i; i = i->next) - { - GtkCellView *view; - - if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) - view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); - else - view = GTK_CELL_VIEW (i->data); - - gtk_cell_layout_clear (GTK_CELL_LAYOUT (view)); - } - g_list_free (list); - } -} - -static void -gtk_combo_box_cell_layout_add_attribute (GtkCellLayout *layout, - GtkCellRenderer *cell, - const gchar *attribute, - gint column) -{ - ComboCellInfo *info; - GtkComboBox *combo_box; - GtkWidget *menu; - - g_return_if_fail (GTK_IS_COMBO_BOX (layout)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - - combo_box = GTK_COMBO_BOX (layout); - - info = gtk_combo_box_get_cell_info (combo_box, cell); - - info->attributes = g_slist_prepend (info->attributes, - GINT_TO_POINTER (column)); - info->attributes = g_slist_prepend (info->attributes, - g_strdup (attribute)); - - if (combo_box->priv->cell_view) - gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_box->priv->cell_view), - cell, attribute, column); - - if (combo_box->priv->column) - gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_box->priv->column), - cell, attribute, column); - - menu = combo_box->priv->popup_widget; - if (GTK_IS_MENU (menu)) - { - GList *i, *list; - - list = gtk_container_get_children (GTK_CONTAINER (menu)); - for (i = list; i; i = i->next) - { - GtkCellView *view; - - if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) - view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); - else - view = GTK_CELL_VIEW (i->data); - - gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (view), cell, - attribute, column); - } - g_list_free (list); - } - - gtk_widget_queue_resize (GTK_WIDGET (combo_box)); -} - -static void -gtk_combo_box_cell_layout_set_cell_data_func (GtkCellLayout *layout, - GtkCellRenderer *cell, - GtkCellLayoutDataFunc func, - gpointer func_data, - GDestroyNotify destroy) -{ - ComboCellInfo *info; - GtkComboBox *combo_box; - GtkWidget *menu; - - g_return_if_fail (GTK_IS_COMBO_BOX (layout)); - - combo_box = GTK_COMBO_BOX (layout); - - info = gtk_combo_box_get_cell_info (combo_box, cell); - g_return_if_fail (info != NULL); - - if (info->destroy) - { - GDestroyNotify d = info->destroy; - - info->destroy = NULL; - d (info->func_data); - } - - info->func = func; - info->func_data = func_data; - info->destroy = destroy; - - if (combo_box->priv->cell_view) - gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo_box->priv->cell_view), cell, func, func_data, NULL); - - if (combo_box->priv->column) - gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo_box->priv->column), cell, func, func_data, NULL); - - menu = combo_box->priv->popup_widget; - if (GTK_IS_MENU (menu)) - { - GList *i, *list; - - list = gtk_container_get_children (GTK_CONTAINER (menu)); - for (i = list; i; i = i->next) - { - GtkCellView *view; - - if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) - view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); - else - view = GTK_CELL_VIEW (i->data); - - gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (view), cell, - func, func_data, NULL); - } - g_list_free (list); - } - - gtk_widget_queue_resize (GTK_WIDGET (combo_box)); -} - -static void -gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout *layout, - GtkCellRenderer *cell) -{ - ComboCellInfo *info; - GtkComboBox *combo_box; - GtkWidget *menu; - GSList *list; - - g_return_if_fail (GTK_IS_COMBO_BOX (layout)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - - combo_box = GTK_COMBO_BOX (layout); - - info = gtk_combo_box_get_cell_info (combo_box, cell); - if (info) - { - list = info->attributes; - while (list && list->next) - { - g_free (list->data); - list = list->next->next; - } - g_slist_free (info->attributes); - info->attributes = NULL; - } - - if (combo_box->priv->cell_view) - gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (combo_box->priv->cell_view), cell); - - if (combo_box->priv->column) - gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (combo_box->priv->column), cell); - - menu = combo_box->priv->popup_widget; - if (GTK_IS_MENU (menu)) - { - GList *i, *list; - - list = gtk_container_get_children (GTK_CONTAINER (menu)); - for (i = list; i; i = i->next) - { - GtkCellView *view; - - if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) - view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); - else - view = GTK_CELL_VIEW (i->data); - - gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (view), cell); - } - g_list_free (list); - } - - gtk_widget_queue_resize (GTK_WIDGET (combo_box)); -} - -static void -gtk_combo_box_cell_layout_reorder (GtkCellLayout *layout, - GtkCellRenderer *cell, - gint position) -{ - ComboCellInfo *info; - GtkComboBox *combo_box; - GtkWidget *menu; - GSList *link; - - g_return_if_fail (GTK_IS_COMBO_BOX (layout)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - - combo_box = GTK_COMBO_BOX (layout); - - info = gtk_combo_box_get_cell_info (combo_box, cell); - - g_return_if_fail (info != NULL); - g_return_if_fail (position >= 0); - - link = g_slist_find (combo_box->priv->cells, info); - - g_return_if_fail (link != NULL); - - combo_box->priv->cells = g_slist_remove_link (combo_box->priv->cells, link); - combo_box->priv->cells = g_slist_insert (combo_box->priv->cells, info, - position); - - if (combo_box->priv->cell_view) - gtk_cell_layout_reorder (GTK_CELL_LAYOUT (combo_box->priv->cell_view), - cell, position); - - if (combo_box->priv->column) - gtk_cell_layout_reorder (GTK_CELL_LAYOUT (combo_box->priv->column), - cell, position); - - menu = combo_box->priv->popup_widget; - if (GTK_IS_MENU (menu)) - { - GList *i, *list; - - list = gtk_container_get_children (GTK_CONTAINER (menu)); - for (i = list; i; i = i->next) - { - GtkCellView *view; - - if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) - view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); - else - view = GTK_CELL_VIEW (i->data); - - gtk_cell_layout_reorder (GTK_CELL_LAYOUT (view), cell, position); - } - g_list_free (list); - } - - gtk_widget_queue_draw (GTK_WIDGET (combo_box)); -} - -/* - * public API - */ - -/** - * gtk_combo_box_new: - * - * Creates a new empty #GtkComboBox. - * - * Return value: A new #GtkComboBox. - * - * Since: 2.4 - */ -GtkWidget * -gtk_combo_box_new (void) -{ - return GTK_WIDGET (g_object_new (GTK_TYPE_COMBO_BOX, NULL)); -} - -/** - * gtk_combo_box_new_with_model: - * @model: A #GtkTreeModel. - * - * Creates a new #GtkComboBox with the model initialized to @model. - * - * Return value: A new #GtkComboBox. - * - * Since: 2.4 - */ -GtkWidget * -gtk_combo_box_new_with_model (GtkTreeModel *model) -{ - GtkComboBox *combo_box; - - g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL); - - combo_box = GTK_COMBO_BOX (g_object_new (GTK_TYPE_COMBO_BOX, - "model", model, - NULL)); - - return GTK_WIDGET (combo_box); -} - -/** - * gtk_combo_box_set_wrap_width: - * @combo_box: A #GtkComboBox. - * @width: Preferred number of columns. - * - * Sets the wrap width of @combo_box to be @width. The wrap width is basically - * the preferred number of columns when you want to the popup to be layed out - * in a table. - * - * Since: 2.4 - */ -void -gtk_combo_box_set_wrap_width (GtkComboBox *combo_box, - gint width) -{ - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - g_return_if_fail (width >= 0); - - if (width != combo_box->priv->wrap_width) - { - combo_box->priv->wrap_width = width; - - gtk_combo_box_check_appearance (combo_box); - gtk_combo_box_relayout (combo_box); - - g_object_notify (G_OBJECT (combo_box), "wrap_width"); - } -} - -/** - * gtk_combo_box_set_row_span_column: - * @combo_box: A #GtkComboBox. - * @row_span: A column in the model passed during construction. - * - * Sets the column with row span information for @combo_box to be @row_span. - * The row span column contains integers which indicate how many rows - * an item should span. - * - * Since: 2.4 - */ -void -gtk_combo_box_set_row_span_column (GtkComboBox *combo_box, - gint row_span) -{ - gint col; - - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - - col = gtk_tree_model_get_n_columns (combo_box->priv->model); - g_return_if_fail (row_span >= 0 && row_span < col); - - if (row_span != combo_box->priv->row_column) - { - combo_box->priv->row_column = row_span; - - gtk_combo_box_relayout (combo_box); - - g_object_notify (G_OBJECT (combo_box), "row_span_column"); - } -} - -/** - * gtk_combo_box_set_column_span_column: - * @combo_box: A #GtkComboBox. - * @column_span: A column in the model passed during construction. - * - * Sets the column with column span information for @combo_box to be - * @column_span. The column span column contains integers which indicate - * how many columns an item should span. - * - * Since: 2.4 - */ -void -gtk_combo_box_set_column_span_column (GtkComboBox *combo_box, - gint column_span) -{ - gint col; - - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - - col = gtk_tree_model_get_n_columns (combo_box->priv->model); - g_return_if_fail (column_span >= 0 && column_span < col); - - if (column_span != combo_box->priv->col_column) - { - combo_box->priv->col_column = column_span; - - gtk_combo_box_relayout (combo_box); - - g_object_notify (G_OBJECT (combo_box), "column_span_column"); - } -} - -/** - * gtk_combo_box_get_active: - * @combo_box: A #GtkComboBox. - * - * Returns the index of the currently active item, or -1 if there's no - * active item. - * - * Return value: An integer which is the index of the currently active item, or - * -1 if there's no active item. - * - * Since: 2.4 - */ -gint -gtk_combo_box_get_active (GtkComboBox *combo_box) -{ - g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), 0); - - return combo_box->priv->active_item; -} - -/** - * gtk_combo_box_set_active: - * @combo_box: A #GtkComboBox. - * @index_: An index in the model passed during construction, or -1 to have - * no active item. - * - * Sets the active item of @combo_box to be the item at @index. - * - * Since: 2.4 - */ -void -gtk_combo_box_set_active (GtkComboBox *combo_box, - gint index_) -{ - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - /* -1 means "no item selected" */ - g_return_if_fail (index_ >= -1); - - if (combo_box->priv->active_item == index_) - return; - - gtk_combo_box_set_active_internal (combo_box, index_); -} - -static void -gtk_combo_box_set_active_internal (GtkComboBox *combo_box, - gint index) -{ - GtkTreePath *path; - - combo_box->priv->active_item = index; - - if (index == -1) - { - if (combo_box->priv->tree_view) - gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view))); - else - { - GtkMenu *menu = GTK_MENU (combo_box->priv->popup_widget); - - if (GTK_IS_MENU (menu)) - gtk_menu_set_active (menu, -1); - } - - if (combo_box->priv->cell_view) - gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (combo_box->priv->cell_view), NULL); - } - else - { -#if GTK_CHECK_VERSION(2,2,0) - path = gtk_tree_path_new_from_indices (index, -1); -#else - char buf[32]; - g_snprintf(buf, sizeof(buf), "%d", index); - path = gtk_tree_path_new_from_string(buf); -#endif - - if (combo_box->priv->tree_view) - gtk_tree_view_set_cursor (GTK_TREE_VIEW (combo_box->priv->tree_view), path, NULL, FALSE); - else - { - GtkMenu *menu = GTK_MENU (combo_box->priv->popup_widget); - - if (GTK_IS_MENU (menu)) - gtk_menu_set_active (GTK_MENU (menu), index); - } - - if (combo_box->priv->cell_view) - gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (combo_box->priv->cell_view), path); - - gtk_tree_path_free (path); - } - - g_signal_emit_by_name (combo_box, "changed", NULL, NULL); -} - - -/** - * gtk_combo_box_get_active_iter: - * @combo_box: A #GtkComboBox - * @iter: The uninitialized #GtkTreeIter. - * - * Sets @iter to point to the current active item, if it exists. - * - * Return value: %TRUE, if @iter was set - * - * Since: 2.4 - **/ -gboolean -gtk_combo_box_get_active_iter (GtkComboBox *combo_box, - GtkTreeIter *iter) -{ - GtkTreePath *path; - gint active; - gboolean retval; -#if !GTK_CHECK_VERSION(2,2,0) - char buf[32]; -#endif - - g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE); - - active = gtk_combo_box_get_active (combo_box); - if (active < 0) - return FALSE; - -#if GTK_CHECK_VERSION(2,2,0) - path = gtk_tree_path_new_from_indices (active, -1); -#else - g_snprintf(buf, sizeof(buf), "%d", active); - path = gtk_tree_path_new_from_string(buf); -#endif - retval = gtk_tree_model_get_iter (gtk_combo_box_get_model (combo_box), - iter, path); - gtk_tree_path_free (path); - - return retval; -} - -/** - * gtk_combo_box_set_active_iter: - * @combo_box: A #GtkComboBox - * @iter: The #GtkTreeIter. - * - * Sets the current active item to be the one referenced by @iter. - * @iter must correspond to a path of depth one. - * - * Since: 2.4 - **/ -void -gtk_combo_box_set_active_iter (GtkComboBox *combo_box, - GtkTreeIter *iter) -{ - GtkTreePath *path; - - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - - path = gtk_tree_model_get_path (gtk_combo_box_get_model (combo_box), iter); - g_return_if_fail (path != NULL); - g_return_if_fail (gtk_tree_path_get_depth (path) == 1); - - gtk_combo_box_set_active (combo_box, gtk_tree_path_get_indices (path)[0]); - gtk_tree_path_free (path); -} - -/** - * gtk_combo_box_set_model: - * @combo_box: A #GtkComboBox. - * @model: A #GtkTreeModel. - * - * Sets the model used by @combo_box to be @model. Will unset a previously set - * model (if applicable). If @model is %NULL, then it will unset the model. - * - * Note that this function does not clear the cell renderers, you have to - * call gtk_combo_box_cell_layout_clear() yourself if you need to set up - * different cell renderers for the new model. - * - * Since: 2.4 - */ -void -gtk_combo_box_set_model (GtkComboBox *combo_box, - GtkTreeModel *model) -{ - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - - if (!model) - { - gtk_combo_box_unset_model (combo_box); - return; - } - - g_return_if_fail (GTK_IS_TREE_MODEL (model)); - - if (model == combo_box->priv->model) - return; - - if (combo_box->priv->model) - gtk_combo_box_unset_model (combo_box); - - combo_box->priv->model = model; - g_object_ref (G_OBJECT (combo_box->priv->model)); - - combo_box->priv->inserted_id = - g_signal_connect (combo_box->priv->model, "row_inserted", - G_CALLBACK (gtk_combo_box_model_row_inserted), - combo_box); - combo_box->priv->deleted_id = - g_signal_connect (combo_box->priv->model, "row_deleted", - G_CALLBACK (gtk_combo_box_model_row_deleted), - combo_box); - combo_box->priv->reordered_id = - g_signal_connect (combo_box->priv->model, "rows_reordered", - G_CALLBACK (gtk_combo_box_model_rows_reordered), - combo_box); - combo_box->priv->changed_id = - g_signal_connect (combo_box->priv->model, "row_changed", - G_CALLBACK (gtk_combo_box_model_row_changed), - combo_box); - - if (combo_box->priv->tree_view) - { - /* list mode */ - gtk_tree_view_set_model (GTK_TREE_VIEW (combo_box->priv->tree_view), - combo_box->priv->model); - } - else - { - /* menu mode */ - if (combo_box->priv->popup_widget) - gtk_combo_box_menu_fill (combo_box); - - } - - if (combo_box->priv->cell_view) - gtk_cell_view_set_model (GTK_CELL_VIEW (combo_box->priv->cell_view), - combo_box->priv->model); -} - -/** - * gtk_combo_box_get_model - * @combo_box: A #GtkComboBox. - * - * Returns the #GtkTreeModel which is acting as data source for @combo_box. - * - * Return value: A #GtkTreeModel which was passed during construction. - * - * Since: 2.4 - */ -GtkTreeModel * -gtk_combo_box_get_model (GtkComboBox *combo_box) -{ - g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL); - - return combo_box->priv->model; -} - - -/* convenience API for simple text combos */ - -/** - * gtk_combo_box_new_text: - * - * Convenience function which constructs a new text combo box, which is a - * #GtkComboBox just displaying strings. If you use this function to create - * a text combo box, you should only manipulate its data source with the - * following convenience functions: gtk_combo_box_append_text(), - * gtk_combo_box_insert_text(), gtk_combo_box_prepend_text() and - * gtk_combo_box_remove_text(). - * - * Return value: A new text combo box. - * - * Since: 2.4 - */ -GtkWidget * -gtk_combo_box_new_text (void) -{ - GtkWidget *combo_box; - GtkCellRenderer *cell; - GtkListStore *store; - - store = gtk_list_store_new (1, G_TYPE_STRING); - combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); - g_object_unref (store); - - cell = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell, - "text", 0, - NULL); - - return combo_box; -} - -/** - * gtk_combo_box_append_text: - * @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text(). - * @text: A string. - * - * Appends @string to the list of strings stored in @combo_box. Note that - * you can only use this function with combo boxes constructed with - * gtk_combo_box_new_text(). - * - * Since: 2.4 - */ -void -gtk_combo_box_append_text (GtkComboBox *combo_box, - const gchar *text) -{ - GtkTreeIter iter; - GtkListStore *store; - - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model)); - g_return_if_fail (text != NULL); - - store = GTK_LIST_STORE (combo_box->priv->model); - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, text, -1); -} - -/** - * gtk_combo_box_insert_text: - * @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text(). - * @position: An index to insert @text. - * @text: A string. - * - * Inserts @string at @position in the list of strings stored in @combo_box. - * Note that you can only use this function with combo boxes constructed - * with gtk_combo_box_new_text(). - * - * Since: 2.4 - */ -void -gtk_combo_box_insert_text (GtkComboBox *combo_box, - gint position, - const gchar *text) -{ - GtkTreeIter iter; - GtkListStore *store; - - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model)); - g_return_if_fail (position >= 0); - g_return_if_fail (text != NULL); - - store = GTK_LIST_STORE (combo_box->priv->model); - - gtk_list_store_insert (store, &iter, position); - gtk_list_store_set (store, &iter, 0, text, -1); -} - -/** - * gtk_combo_box_prepend_text: - * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text(). - * @text: A string. - * - * Prepends @string to the list of strings stored in @combo_box. Note that - * you can only use this function with combo boxes constructed with - * gtk_combo_box_new_text(). - * - * Since: 2.4 - */ -void -gtk_combo_box_prepend_text (GtkComboBox *combo_box, - const gchar *text) -{ - GtkTreeIter iter; - GtkListStore *store; - - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model)); - g_return_if_fail (text != NULL); - - store = GTK_LIST_STORE (combo_box->priv->model); - - gtk_list_store_prepend (store, &iter); - gtk_list_store_set (store, &iter, 0, text, -1); -} - -/** - * gtk_combo_box_remove_text: - * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text(). - * @position: Index of the item to remove. - * - * Removes the string at @position from @combo_box. Note that you can only use - * this function with combo boxes constructed with gtk_combo_box_new_text(). - * - * Since: 2.4 - */ -void -gtk_combo_box_remove_text (GtkComboBox *combo_box, - gint position) -{ - GtkTreeIter iter; - GtkListStore *store; - - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model)); - g_return_if_fail (position >= 0); - - store = GTK_LIST_STORE (combo_box->priv->model); - - if (gtk_tree_model_iter_nth_child (combo_box->priv->model, &iter, - NULL, position)) - gtk_list_store_remove (store, &iter); -} - -static gboolean -gtk_combo_box_mnemonic_activate (GtkWidget *widget, - gboolean group_cycling) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (widget); - - gtk_widget_grab_focus (combo_box->priv->button); - - return TRUE; -} - -static void -gtk_combo_box_destroy (GtkObject *object) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (object); - - gtk_combo_box_popdown (combo_box); - - combo_box->priv->destroying = 1; - - GTK_OBJECT_CLASS (parent_class)->destroy (object); - combo_box->priv->cell_view = NULL; - - combo_box->priv->destroying = 0; -} - -static void -gtk_combo_box_finalize (GObject *object) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (object); - GSList *i; - - if (GTK_IS_MENU (combo_box->priv->popup_widget)) - { - gtk_combo_box_menu_destroy (combo_box); - gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget)); - combo_box->priv->popup_widget = NULL; - } - - if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view)) - gtk_combo_box_list_destroy (combo_box); - - if (combo_box->priv->popup_window) - gtk_widget_destroy (combo_box->priv->popup_window); - - gtk_combo_box_unset_model (combo_box); - - for (i = combo_box->priv->cells; i; i = i->next) - { - ComboCellInfo *info = (ComboCellInfo *)i->data; - GSList *list = info->attributes; - - if (info->destroy) - info->destroy (info->func_data); - - while (list && list->next) - { - g_free (list->data); - list = list->next->next; - } - g_slist_free (info->attributes); - - g_object_unref (G_OBJECT (info->cell)); - g_free (info); - } - g_slist_free (combo_box->priv->cells); - - g_free (combo_box->priv); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - - -/** - * Code below this point has been pulled in from gtkmenu.c in 2.4.14 - * and is needed to provide gtk_menu_attach() - */ - -typedef struct -{ - gint left_attach; - gint right_attach; - gint top_attach; - gint bottom_attach; - gint effective_left_attach; - gint effective_right_attach; - gint effective_top_attach; - gint effective_bottom_attach; -} AttachInfo; - -#define ATTACH_INFO_KEY "gtk-menu-child-attach-info-key" - -static AttachInfo * -get_attach_info (GtkWidget *child) -{ - GObject *object = G_OBJECT (child); - AttachInfo *ai = g_object_get_data (object, ATTACH_INFO_KEY); - - if (!ai) - { - ai = g_new0 (AttachInfo, 1); - g_object_set_data_full (object, ATTACH_INFO_KEY, ai, g_free); - } - - return ai; -} - -/** - * gtk_menu_attach: - * @menu: a #GtkMenu. - * @child: a #GtkMenuItem. - * @left_attach: The column number to attach the left side of the item to. - * @right_attach: The column number to attach the right side of the item to. - * @top_attach: The row number to attach the top of the item to. - * @bottom_attach: The row number to attach the bottom of the item to. - * - * Adds a new #GtkMenuItem to a (table) menu. The number of 'cells' that - * an item will occupy is specified by @left_attach, @right_attach, - * @top_attach and @bottom_attach. These each represent the leftmost, - * rightmost, uppermost and lower column and row numbers of the table. - * (Columns and rows are indexed from zero). - * - * Note that this function is not related to gtk_menu_detach(). - * - * Since: 2.4 - **/ -static void -gtk_menu_attach (GtkMenu *menu, - GtkWidget *child, - guint left_attach, - guint right_attach, - guint top_attach, - guint bottom_attach) -{ - GtkMenuShell *menu_shell; - - g_return_if_fail (GTK_IS_MENU (menu)); - g_return_if_fail (GTK_IS_MENU_ITEM (child)); - g_return_if_fail (child->parent == NULL || - child->parent == GTK_WIDGET (menu)); - g_return_if_fail (left_attach < right_attach); - g_return_if_fail (top_attach < bottom_attach); - - menu_shell = GTK_MENU_SHELL (menu); - - if (!child->parent) - { - AttachInfo *ai = get_attach_info (child); - - ai->left_attach = left_attach; - ai->right_attach = right_attach; - ai->top_attach = top_attach; - ai->bottom_attach = bottom_attach; - - menu_shell->children = g_list_append (menu_shell->children, child); - - gtk_widget_set_parent (child, GTK_WIDGET (menu)); - - /* - menu_queue_resize (menu); - */ - } - else - { - gtk_container_child_set (GTK_CONTAINER (child->parent), child, - "left_attach", left_attach, - "right_attach", right_attach, - "top_attach", top_attach, - "bottom_attach", bottom_attach, - NULL); - } -} -#endif /* Gtk 2.4 */ - -gchar * -gtk_combo_box_get_active_text (GtkComboBox *combo_box) -{ - GtkTreeIter iter; - gchar *text = NULL; - - /* g_return_val_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model), NULL); */ - - if (gtk_combo_box_get_active_iter (combo_box, &iter)) - gtk_tree_model_get (gtk_combo_box_get_model(combo_box), &iter, - 0, &text, -1); - return text; -} - -#endif
--- a/pidgin/gaimcombobox.h Mon Mar 19 06:34:51 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -/* gtkcombobox.h - * Copyright (C) 2002, 2003 Kristian Rietveld <kris@gtk.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __GAIM_COMBO_BOX_H__ -#define __GAIM_COMBO_BOX_H__ - -#ifndef __GTK_COMBO_BOX_H__ -#define __GTK_COMBO_BOX_H__ - -#include <gtk/gtkbin.h> -#include <gtk/gtktreemodel.h> -#include <gtk/gtktreeview.h> - -G_BEGIN_DECLS - -#define GTK_TYPE_COMBO_BOX (gtk_combo_box_get_type ()) -#define GTK_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COMBO_BOX, GtkComboBox)) -#define GTK_COMBO_BOX_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), GTK_TYPE_COMBO_BOX, GtkComboBoxClass)) -#define GTK_IS_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COMBO_BOX)) -#define GTK_IS_COMBO_BOX_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), GTK_TYPE_COMBO_BOX)) -#define GTK_COMBO_BOX_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), GTK_TYPE_COMBO_BOX, GtkComboBoxClass)) - -typedef struct _GtkComboBox GtkComboBox; -typedef struct _GtkComboBoxClass GtkComboBoxClass; -typedef struct _GtkComboBoxPrivate GtkComboBoxPrivate; - -struct _GtkComboBox -{ - GtkBin parent_instance; - - /*< private >*/ - GtkComboBoxPrivate *priv; -}; - -struct _GtkComboBoxClass -{ - GtkBinClass parent_class; - - /* signals */ - void (* changed) (GtkComboBox *combo_box); - - /* Padding for future expansion */ - void (*_gtk_reserved0) (void); - void (*_gtk_reserved1) (void); - void (*_gtk_reserved2) (void); - void (*_gtk_reserved3) (void); -}; - - -/* construction */ -GType gtk_combo_box_get_type (void); -GtkWidget *gtk_combo_box_new (void); -GtkWidget *gtk_combo_box_new_with_model (GtkTreeModel *model); - -/* grids */ -void gtk_combo_box_set_wrap_width (GtkComboBox *combo_box, - gint width); -void gtk_combo_box_set_row_span_column (GtkComboBox *combo_box, - gint row_span); -void gtk_combo_box_set_column_span_column (GtkComboBox *combo_box, - gint column_span); - -/* get/set active item */ -gint gtk_combo_box_get_active (GtkComboBox *combo_box); -void gtk_combo_box_set_active (GtkComboBox *combo_box, - gint index_); -gboolean gtk_combo_box_get_active_iter (GtkComboBox *combo_box, - GtkTreeIter *iter); -void gtk_combo_box_set_active_iter (GtkComboBox *combo_box, - GtkTreeIter *iter); - -/* getters and setters */ -void gtk_combo_box_set_model (GtkComboBox *combo_box, - GtkTreeModel *model); -GtkTreeModel *gtk_combo_box_get_model (GtkComboBox *combo_box); - -/* convenience -- text */ -GtkWidget *gtk_combo_box_new_text (void); -void gtk_combo_box_append_text (GtkComboBox *combo_box, - const gchar *text); -void gtk_combo_box_insert_text (GtkComboBox *combo_box, - gint position, - const gchar *text); -void gtk_combo_box_prepend_text (GtkComboBox *combo_box, - const gchar *text); -void gtk_combo_box_remove_text (GtkComboBox *combo_box, - gint position); -/* programmatic control */ -void gtk_combo_box_popup (GtkComboBox *combo_box); -void gtk_combo_box_popdown (GtkComboBox *combo_box); - -G_END_DECLS - -#endif /* __GTK_COMBO_BOX_H__ */ - -gchar *gtk_combo_box_get_active_text (GtkComboBox *combo_box); - -#endif /* __GAIM_COMBOX_BOX_H__ */
--- a/pidgin/gaimstock.c Mon Mar 19 06:34:51 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,346 +0,0 @@ -/** - * @file gaimstock.c GTK+ Stock resources - * @ingroup gtkui - * - * gaim - * - * Gaim 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 - * 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 "internal.h" -#include "pidgin.h" - -#include "gaimstock.h" - -static struct StockIcon -{ - const char *name; - const char *dir; - const char *filename; - -} const stock_icons[] = -{ - { PIDGIN_STOCK_ABOUT, "buttons", "about_menu.png" }, - { PIDGIN_STOCK_ACTION, NULL, GTK_STOCK_EXECUTE }, -#if GTK_CHECK_VERSION(2,6,0) - { PIDGIN_STOCK_ALIAS, NULL, GTK_STOCK_EDIT }, -#else - { PIDGIN_STOCK_ALIAS, "buttons", "edit.png" }, -#endif - { PIDGIN_STOCK_BLOCK, NULL, GTK_STOCK_STOP }, - { PIDGIN_STOCK_UNBLOCK, NULL, GTK_STOCK_STOP /* XXX: */ }, - { PIDGIN_STOCK_CHAT, NULL, GTK_STOCK_JUMP_TO }, - { PIDGIN_STOCK_CLEAR, NULL, GTK_STOCK_CLEAR }, - { PIDGIN_STOCK_CLOSE_TABS, NULL, GTK_STOCK_CLOSE }, -#if GTK_CHECK_VERSION(2,6,0) - { PIDGIN_STOCK_CONNECT, NULL, GTK_STOCK_CONNECT }, -#else - { PIDGIN_STOCK_CONNECT, "icons", "stock_connect_16.png" }, -#endif - { PIDGIN_STOCK_DEBUG, NULL, GTK_STOCK_PROPERTIES }, - { PIDGIN_STOCK_DOWNLOAD, NULL, GTK_STOCK_GO_DOWN }, -#if GTK_CHECK_VERSION(2,6,0) - { PIDGIN_STOCK_DISCONNECT, NULL, GTK_STOCK_DISCONNECT }, -#else - { PIDGIN_STOCK_DISCONNECT, "icons", "stock_disconnect_16.png" }, -#endif - { PIDGIN_STOCK_FGCOLOR, "buttons", "change-fgcolor-small.png" }, -#if GTK_CHECK_VERSION(2,6,0) - { PIDGIN_STOCK_EDIT, NULL, GTK_STOCK_EDIT }, -#else - { PIDGIN_STOCK_EDIT, "buttons", "edit.png" }, -#endif - { PIDGIN_STOCK_FILE_CANCELED, NULL, GTK_STOCK_CANCEL }, - { PIDGIN_STOCK_FILE_DONE, NULL, GTK_STOCK_APPLY }, - { PIDGIN_STOCK_FILE_TRANSFER, NULL, GTK_STOCK_REVERT_TO_SAVED }, - { PIDGIN_STOCK_IGNORE, NULL, GTK_STOCK_DIALOG_ERROR }, - { PIDGIN_STOCK_INVITE, NULL, GTK_STOCK_JUMP_TO }, - { PIDGIN_STOCK_MODIFY, NULL, GTK_STOCK_PREFERENCES }, -#if GTK_CHECK_VERSION(2,6,0) - { PIDGIN_STOCK_PAUSE, NULL, GTK_STOCK_MEDIA_PAUSE }, -#else - { PIDGIN_STOCK_PAUSE, "buttons", "pause.png" }, -#endif - { PIDGIN_STOCK_POUNCE, NULL, GTK_STOCK_REDO }, - { PIDGIN_STOCK_OPEN_MAIL, NULL, GTK_STOCK_JUMP_TO }, - { PIDGIN_STOCK_SIGN_ON, NULL, GTK_STOCK_EXECUTE }, - { PIDGIN_STOCK_SIGN_OFF, NULL, GTK_STOCK_CLOSE }, - { PIDGIN_STOCK_TYPED, "gaim", "typed.png" }, - { PIDGIN_STOCK_UPLOAD, NULL, GTK_STOCK_GO_UP }, -}; - -static const GtkStockItem stock_items[] = -{ - { PIDGIN_STOCK_ALIAS, N_("_Alias"), 0, 0, NULL }, - { PIDGIN_STOCK_CHAT, N_("_Join"), 0, 0, NULL }, - { PIDGIN_STOCK_CLOSE_TABS, N_("Close _tabs"), 0, 0, NULL }, - { PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW, N_("I_M"), 0, 0, NULL }, - { PIDGIN_STOCK_TOOLBAR_USER_INFO, N_("_Get Info"), 0, 0, NULL }, - { PIDGIN_STOCK_INVITE, N_("_Invite"), 0, 0, NULL }, - { PIDGIN_STOCK_MODIFY, N_("_Modify"), 0, 0, NULL }, - { PIDGIN_STOCK_OPEN_MAIL, N_("_Open Mail"), 0, 0, NULL }, - { PIDGIN_STOCK_PAUSE, N_("_Pause"), 0, 0, NULL }, -}; - -static struct SizedStockIcon { - const char *name; - const char *dir; - const char *filename; - gboolean extra_small; - gboolean small; - gboolean medium; - gboolean large; - gboolean huge; - gboolean rtl; -} const sized_stock_icons [] = { - { PIDGIN_STOCK_STATUS_AVAILABLE, "status", "available.png", TRUE, TRUE, TRUE, TRUE, FALSE, FALSE }, - { PIDGIN_STOCK_STATUS_AVAILABLE_I, "status", "available_i.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_STATUS_AWAY, "status", "away.png", TRUE, TRUE, TRUE, TRUE, FALSE, FALSE }, - { PIDGIN_STOCK_STATUS_AWAY_I, "status", "away_i.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_STATUS_BUSY, "status", "busy.png", TRUE, TRUE, TRUE, TRUE, FALSE, FALSE }, - { PIDGIN_STOCK_STATUS_BUSY_I, "status", "busy_i.png", TRUE, FALSE, FALSE, FALSE, FALSE,FALSE }, - { PIDGIN_STOCK_STATUS_CHAT, "status", "chat.png", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE }, - { PIDGIN_STOCK_STATUS_XA, "status", "extended-away.png", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE }, - { PIDGIN_STOCK_STATUS_XA_I, "status", "extended-away_i.png",TRUE, FALSE, FALSE, FALSE, FALSE, TRUE }, - { PIDGIN_STOCK_STATUS_LOGIN, "status", "log-in.png", TRUE, TRUE, TRUE, TRUE, FALSE, FALSE }, - { PIDGIN_STOCK_STATUS_LOGOUT, "status", "log-out.png", TRUE, TRUE, TRUE, TRUE, FALSE, FALSE }, - { PIDGIN_STOCK_STATUS_OFFLINE, "status", "offline.png", TRUE, TRUE, TRUE, TRUE, FALSE, FALSE }, - { PIDGIN_STOCK_STATUS_PERSON, "status", "person.png", TRUE, TRUE, TRUE, TRUE, FALSE, FALSE }, - { PIDGIN_STOCK_STATUS_MESSAGE, "status", "message-pending.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - - { PIDGIN_STOCK_STATUS_IGNORED, "emblems", "blocked.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_STATUS_FOUNDER, "emblems", "founder.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_STATUS_OPERATOR, "emblems", "operator.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_STATUS_HALFOP, "emblems", "half-operator.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_STATUS_VOICE, "emblems", "voice.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - - { PIDGIN_STOCK_DIALOG_AUTH, "dialogs", "auth.png", TRUE, FALSE, FALSE, FALSE, TRUE, FALSE }, - { PIDGIN_STOCK_DIALOG_COOL, "dialogs", "cool.png", FALSE, FALSE, FALSE, FALSE, TRUE, FALSE }, - { PIDGIN_STOCK_DIALOG_ERROR, "dialogs", "error.png", TRUE, FALSE, FALSE, FALSE, TRUE, FALSE }, - { PIDGIN_STOCK_DIALOG_INFO, "dialogs", "info.png", TRUE, FALSE, FALSE, FALSE, TRUE, FALSE }, - { PIDGIN_STOCK_DIALOG_MAIL, "dialogs", "mail.png", TRUE, FALSE, FALSE, FALSE, TRUE, FALSE }, - { PIDGIN_STOCK_DIALOG_QUESTION, "dialogs", "question.png", TRUE, FALSE, FALSE, FALSE, TRUE, FALSE }, - { PIDGIN_STOCK_DIALOG_WARNING, "dialogs", "warning.png", FALSE, FALSE, FALSE, FALSE, TRUE, FALSE }, - - { PIDGIN_STOCK_ANIMATION_CONNECT0, "animations", "connect0.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_ANIMATION_CONNECT1, "animations", "connect1.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_ANIMATION_CONNECT2, "animations", "connect2.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_ANIMATION_CONNECT3, "animations", "connect3.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_ANIMATION_CONNECT4, "animations", "connect4.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_ANIMATION_CONNECT5, "animations", "connect5.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_ANIMATION_CONNECT6, "animations", "connect6.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_ANIMATION_CONNECT7, "animations", "connect7.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_ANIMATION_CONNECT8, "animations", "connect8.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_ANIMATION_TYPING0, "animations", "typing0.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_ANIMATION_TYPING1, "animations", "typing1.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_ANIMATION_TYPING2, "animations", "typing2.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_ANIMATION_TYPING3, "animations", "typing3.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_ANIMATION_TYPING4, "animations", "typing4.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - - { PIDGIN_STOCK_TOOLBAR_ACCOUNTS, "toolbar", "accounts.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_TOOLBAR_BGCOLOR, "toolbar", "change-bgcolor.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_TOOLBAR_FGCOLOR, "toolbar", "change-fgcolor.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_TOOLBAR_SMILEY, "toolbar", "emote-select.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_TOOLBAR_TEXT_SMALLER, "toolbar", "font-size-down.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_TOOLBAR_TEXT_LARGER, "toolbar", "font-size-up.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE, "toolbar", "insert-image.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_TOOLBAR_INSERT_LINK, "toolbar", "insert-link.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW, "toolbar", "message-new.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_TOOLBAR_PLUGINS, "toolbar", "plugins.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_TOOLBAR_TYPING, "toolbar", "typing.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_TOOLBAR_PENDING, "status", "message-pending.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, - - { PIDGIN_STOCK_TRAY_AVAILABLE, "tray", "tray-online.png", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_TRAY_AWAY, "tray", "tray-away.png", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_TRAY_BUSY, "tray", "tray-busy.png", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_TRAY_XA, "tray", "tray-extended-away.png", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_TRAY_OFFLINE, "tray", "tray-offline.png", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_TRAY_CONNECT, "tray", "tray-connecting.png", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE }, - { PIDGIN_STOCK_TRAY_PENDING, "tray", "tray-message.png", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE } -}; - -static gchar * -find_file(const char *dir, const char *base) -{ - char *filename; - - if (base == NULL) - return NULL; - - if (!strcmp(dir, "gaim")) - filename = g_build_filename(DATADIR, "pixmaps", "gaim", base, NULL); - else - { - filename = g_build_filename(DATADIR, "pixmaps", "gaim", dir, - base, NULL); - } - - return filename; -} - -static void -add_sized_icon(GtkIconSet *iconset, GtkIconSize sizeid, const char *dir, - gboolean rtl, const char *size, const char *file) -{ - char *filename; - GtkIconSource *source; - - filename = g_build_filename(DATADIR, "pixmaps", "pidgin", dir, size, file, NULL); - source = gtk_icon_source_new(); - gtk_icon_source_set_filename(source, filename); - gtk_icon_source_set_direction(source, GTK_TEXT_DIR_LTR); - gtk_icon_source_set_direction_wildcarded(source, !rtl); - gtk_icon_source_set_size(source, sizeid); - gtk_icon_source_set_size_wildcarded(source, FALSE); - gtk_icon_source_set_state_wildcarded(source, TRUE); - gtk_icon_set_add_source(iconset, source); - gtk_icon_source_free(source); - - if (sizeid == gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL)) { - source = gtk_icon_source_new(); - gtk_icon_source_set_filename(source, filename); - gtk_icon_source_set_direction_wildcarded(source, TRUE); - gtk_icon_source_set_size(source, GTK_ICON_SIZE_MENU); - gtk_icon_source_set_size_wildcarded(source, FALSE); - gtk_icon_source_set_state_wildcarded(source, TRUE); - gtk_icon_set_add_source(iconset, source); - gtk_icon_source_free(source); - } - g_free(filename); - - if (rtl) { - filename = g_build_filename(DATADIR, "pixmaps", "pidgin", dir, size, "rtl", file, NULL); - source = gtk_icon_source_new(); - gtk_icon_source_set_filename(source, filename); - gtk_icon_source_set_direction(source, GTK_TEXT_DIR_RTL); - gtk_icon_source_set_size(source, sizeid); - gtk_icon_source_set_size_wildcarded(source, FALSE); - gtk_icon_source_set_state_wildcarded(source, TRUE); - gtk_icon_set_add_source(iconset, source); - g_free(filename); - gtk_icon_source_free(source); - } - - -} - -void -pidgin_stock_init(void) -{ - static gboolean stock_initted = FALSE; - GtkIconFactory *icon_factory; - size_t i; - GtkWidget *win; - GtkIconSize extra_small, small, medium, large, huge; - - if (stock_initted) - return; - - stock_initted = TRUE; - - /* Setup the icon factory. */ - icon_factory = gtk_icon_factory_new(); - - gtk_icon_factory_add_default(icon_factory); - - /* Er, yeah, a hack, but it works. :) */ - win = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_widget_realize(win); - - for (i = 0; i < G_N_ELEMENTS(stock_icons); i++) - { - GtkIconSource *source; - GtkIconSet *iconset; - gchar *filename; - - if (stock_icons[i].dir == NULL) - { - /* GTK+ Stock icon */ - iconset = gtk_style_lookup_icon_set(gtk_widget_get_style(win), - stock_icons[i].filename); - } - else - { - filename = find_file(stock_icons[i].dir, stock_icons[i].filename); - - if (filename == NULL) - continue; - - source = gtk_icon_source_new(); - gtk_icon_source_set_filename(source, filename); - gtk_icon_source_set_direction_wildcarded(source, TRUE); - gtk_icon_source_set_size_wildcarded(source, TRUE); - gtk_icon_source_set_state_wildcarded(source, TRUE); - - - iconset = gtk_icon_set_new(); - gtk_icon_set_add_source(iconset, source); - - gtk_icon_source_free(source); - g_free(filename); - } - - gtk_icon_factory_add(icon_factory, stock_icons[i].name, iconset); - - gtk_icon_set_unref(iconset); - } - - /* register custom icon sizes */ - extra_small = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL, 16, 16); - small = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_SMALL, 22, 22); - medium = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_MEDIUM, 32, 32); - large = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_LARGE, 48, 48); - huge = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_HUGE, 64, 64); - - for (i = 0; i < G_N_ELEMENTS(sized_stock_icons); i++) - { - GtkIconSet *iconset; - - iconset = gtk_icon_set_new(); - if (sized_stock_icons[i].extra_small) - add_sized_icon(iconset, extra_small, - sized_stock_icons[i].dir, sized_stock_icons[i].rtl, - "16", sized_stock_icons[i].filename); - if (sized_stock_icons[i].small) - add_sized_icon(iconset, small, - sized_stock_icons[i].dir, sized_stock_icons[i].rtl, - "22", sized_stock_icons[i].filename); - if (sized_stock_icons[i].medium) - add_sized_icon(iconset, medium, - sized_stock_icons[i].dir, sized_stock_icons[i].rtl, - "32", sized_stock_icons[i].filename); - if (sized_stock_icons[i].large) - add_sized_icon(iconset, large, - sized_stock_icons[i].dir, sized_stock_icons[i].rtl, - "48", sized_stock_icons[i].filename); - if (sized_stock_icons[i].huge) - add_sized_icon(iconset, huge, - sized_stock_icons[i].dir, sized_stock_icons[i].rtl, - "64", sized_stock_icons[i].filename); - - gtk_icon_factory_add(icon_factory, sized_stock_icons[i].name, iconset); - gtk_icon_set_unref(iconset); - } - - gtk_widget_destroy(win); - g_object_unref(G_OBJECT(icon_factory)); - - /* Register the stock items. */ - gtk_stock_add_static(stock_items, G_N_ELEMENTS(stock_items)); -}
--- a/pidgin/gaimstock.h Mon Mar 19 06:34:51 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,152 +0,0 @@ -/** - * @file gtkstock.h GTK+ Stock resources - * @ingroup gtkui - * - * gaim - * - * 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 - * 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 <gtk/gtkstock.h> - -#ifndef _PIDGIN_STOCK_H_ -#define _PIDGIN_STOCK_H_ - -/**************************************************************************/ -/** @name Stock images */ -/**************************************************************************/ -/*@{*/ -#define PIDGIN_STOCK_ABOUT "pidgin-about" -#define PIDGIN_STOCK_ACTION "pidgin-action" -#define PIDGIN_STOCK_ALIAS "pidgin-alias" -#define PIDGIN_STOCK_AWAY "pidgin-away" -#define PIDGIN_STOCK_BLOCK "pidgin-block" -#define PIDGIN_STOCK_UNBLOCK "pidgin-unblock" -#define PIDGIN_STOCK_CHAT "pidgin-chat" -#define PIDGIN_STOCK_CLEAR "pidgin-clear" -#define PIDGIN_STOCK_CLOSE_TABS "pidgin-close-tab" -#define PIDGIN_STOCK_CONNECT "pidgin-connect" -#define PIDGIN_STOCK_DEBUG "pidgin-debug" -#define PIDGIN_STOCK_DISCONNECT "pidgin-disconnect" -#define PIDGIN_STOCK_DOWNLOAD "pidgin-download" -#define PIDGIN_STOCK_EDIT "pidgin-edit" -#define PIDGIN_STOCK_FGCOLOR "pidgin-fgcolor" -#define PIDGIN_STOCK_FILE_CANCELED "pidgin-file-canceled" -#define PIDGIN_STOCK_FILE_DONE "pidgin-file-done" -#define PIDGIN_STOCK_FILE_TRANSFER "pidgin-file-transfer" -#define PIDGIN_STOCK_IGNORE "pidgin-ignore" -#define PIDGIN_STOCK_INVITE "pidgin-invite" -#define PIDGIN_STOCK_MODIFY "pidgin-modify" -#define PIDGIN_STOCK_OPEN_MAIL "pidgin-stock-open-mail" -#define PIDGIN_STOCK_PAUSE "pidgin-pause" -#define PIDGIN_STOCK_POUNCE "pidgin-pounce" -#define PIDGIN_STOCK_SIGN_OFF "pidgin-sign-off" -#define PIDGIN_STOCK_SIGN_ON "pidgin-sign-on" -#define PIDGIN_STOCK_TEXT_NORMAL "pidgin-text-normal" -#define PIDGIN_STOCK_TYPED "pidgin-typed" -#define PIDGIN_STOCK_UPLOAD "pidgin-upload" - -/* Status icons */ -#define PIDGIN_STOCK_STATUS_AVAILABLE "pidgin-status-available" -#define PIDGIN_STOCK_STATUS_AVAILABLE_I "pidgin-status-available-i" -#define PIDGIN_STOCK_STATUS_AWAY "pidgin-status-away" -#define PIDGIN_STOCK_STATUS_AWAY_I "pidgin-status-away-i" -#define PIDGIN_STOCK_STATUS_BUSY "pidgin-status-busy" -#define PIDGIN_STOCK_STATUS_BUSY_I "pidgin-status-busy-i" -#define PIDGIN_STOCK_STATUS_CHAT "pidgin-status-chat" -#define PIDGIN_STOCK_STATUS_XA "pidgin-status-xa" -#define PIDGIN_STOCK_STATUS_XA_I "pidgin-status-xa-i" -#define PIDGIN_STOCK_STATUS_LOGIN "pidgin-status-login" -#define PIDGIN_STOCK_STATUS_LOGOUT "pidgin-status-logout" -#define PIDGIN_STOCK_STATUS_OFFLINE "pidgin-status-offline" -#define PIDGIN_STOCK_STATUS_PERSON "pidgin-status-person" -#define PIDGIN_STOCK_STATUS_MESSAGE "pidgin-status-message" - -/* Chat room emblems */ -#define PIDGIN_STOCK_STATUS_IGNORED "pidgin-status-ignored" -#define PIDGIN_STOCK_STATUS_FOUNDER "pidgin-status-founder" -#define PIDGIN_STOCK_STATUS_OPERATOR "pidgin-status-operator" -#define PIDGIN_STOCK_STATUS_HALFOP "pidgin-status-halfop" -#define PIDGIN_STOCK_STATUS_VOICE "pidgin-status-voice" - -/* Dialog icons */ -#define PIDGIN_STOCK_DIALOG_AUTH "pidgin-dialog-auth" -#define PIDGIN_STOCK_DIALOG_ERROR "pidgin-dialog-error" -#define PIDGIN_STOCK_DIALOG_INFO "pidgin-dialog-info" -#define PIDGIN_STOCK_DIALOG_MAIL "pidgin-dialog-mail" -#define PIDGIN_STOCK_DIALOG_QUESTION "pidgin-dialog-question" -#define PIDGIN_STOCK_DIALOG_COOL "pidgin-dialog-cool" -#define PIDGIN_STOCK_DIALOG_WARNING "pidgin-dialog-warning" - -/* StatusBox Animations */ -#define PIDGIN_STOCK_ANIMATION_CONNECT0 "pidgin-anim-connect0" -#define PIDGIN_STOCK_ANIMATION_CONNECT1 "pidgin-anim-connect1" -#define PIDGIN_STOCK_ANIMATION_CONNECT2 "pidgin-anim-connect2" -#define PIDGIN_STOCK_ANIMATION_CONNECT3 "pidgin-anim-connect3" -#define PIDGIN_STOCK_ANIMATION_CONNECT4 "pidgin-anim-connect4" -#define PIDGIN_STOCK_ANIMATION_CONNECT5 "pidgin-anim-connect5" -#define PIDGIN_STOCK_ANIMATION_CONNECT6 "pidgin-anim-connect6" -#define PIDGIN_STOCK_ANIMATION_CONNECT7 "pidgin-anim-connect7" -#define PIDGIN_STOCK_ANIMATION_CONNECT8 "pidgin-anim-connect8" -#define PIDGIN_STOCK_ANIMATION_TYPING0 "pidgin-anim-typing0" -#define PIDGIN_STOCK_ANIMATION_TYPING1 "pidgin-anim-typing1" -#define PIDGIN_STOCK_ANIMATION_TYPING2 "pidgin-anim-typing2" -#define PIDGIN_STOCK_ANIMATION_TYPING3 "pidgin-anim-typing3" -#define PIDGIN_STOCK_ANIMATION_TYPING4 "pidgin-anim-typing4" - -/* Toolbar (and menu) icons */ -#define PIDGIN_STOCK_TOOLBAR_ACCOUNTS "pidgin-accounts" -#define PIDGIN_STOCK_TOOLBAR_BGCOLOR "pidgin-bgcolor" -#define PIDGIN_STOCK_TOOLBAR_FGCOLOR "pidgin-fgcolor" -#define PIDGIN_STOCK_TOOLBAR_SMILEY "pidgin-smiley" -#define PIDGIN_STOCK_TOOLBAR_TEXT_SMALLER "pidgin-text-smaller" -#define PIDGIN_STOCK_TOOLBAR_TEXT_LARGER "pidgin-text-larger" -#define PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE "pidgin-insert-image" -#define PIDGIN_STOCK_TOOLBAR_INSERT_LINK "pidgin-insert-link" -#define PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW "pidgin-message-new" -#define PIDGIN_STOCK_TOOLBAR_PLUGINS "pidgin-plugins" -#define PIDGIN_STOCK_TOOLBAR_TYPING "pidgin-typing" -#define PIDGIN_STOCK_TOOLBAR_USER_INFO "pidgin-info" -#define PIDGIN_STOCK_TOOLBAR_PENDING "pidgin-pending" - -/* Tray icons */ -#define PIDGIN_STOCK_TRAY_AVAILABLE "pidgin-tray-available" -#define PIDGIN_STOCK_TRAY_AWAY "pidgin-tray-away" -#define PIDGIN_STOCK_TRAY_BUSY "pidgin-tray-busy" -#define PIDGIN_STOCK_TRAY_XA "pidgin-tray-xa" -#define PIDGIN_STOCK_TRAY_OFFLINE "pidgin-tray-offline" -#define PIDGIN_STOCK_TRAY_CONNECT "pidgin-tray-connect" -#define PIDGIN_STOCK_TRAY_PENDING "pidgin-tray-pending" - - -/*@}*/ - -/** - * For using icons that aren't one of the default GTK_ICON_SIZEs - */ -#define PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL "pidgin-icon-size-tango-extra-small" -#define PIDGIN_ICON_SIZE_TANGO_SMALL "pidgin-icon-size-tango-small" -#define PIDGIN_ICON_SIZE_TANGO_MEDIUM "pidgin-icon-size-tango-medium" -#define PIDGIN_ICON_SIZE_TANGO_LARGE "pidgin-icon-size-tango-large" -#define PIDGIN_ICON_SIZE_TANGO_HUGE "pidgin-icon-size-tango-huge" -/** - * Sets up the gaim stock repository. - */ -void pidgin_stock_init(void); - -#endif /* _PIDGIN_STOCK_H_ */
--- a/pidgin/gtkaccount.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkaccount.c Mon Mar 19 06:35:51 2007 +0000 @@ -44,7 +44,7 @@ #include "gtkdialogs.h" #include "gtkutils.h" #include "gtkstatusbox.h" -#include "gaimstock.h" +#include "pidginstock.h" enum { @@ -177,7 +177,7 @@ GtkWidget *hbox; GtkWidget *label; - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(parent), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); @@ -187,7 +187,7 @@ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, GAIM_HIG_BORDER); + gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, PIDGIN_HIG_BORDER); gtk_widget_show(widget); pidgin_set_accessible_label (widget, label); @@ -396,7 +396,7 @@ gtk_widget_show(dialog->login_frame); /* Main vbox */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_container_add(GTK_CONTAINER(frame), vbox); gtk_widget_show(vbox); @@ -483,7 +483,7 @@ dialog->password_entry = gtk_entry_new(); gtk_entry_set_visibility(GTK_ENTRY(dialog->password_entry), FALSE); if (gtk_entry_get_invisible_char(GTK_ENTRY(dialog->password_entry)) == '*') - gtk_entry_set_invisible_char(GTK_ENTRY(dialog->password_entry), GAIM_INVISIBLE_CHAR); + gtk_entry_set_invisible_char(GTK_ENTRY(dialog->password_entry), PIDGIN_INVISIBLE_CHAR); dialog->password_box = add_pref_box(dialog, vbox, _("Password:"), dialog->password_entry); @@ -558,7 +558,7 @@ gtk_widget_show(dialog->user_frame); /* Main vbox */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_container_add(GTK_CONTAINER(frame), vbox); gtk_widget_show(vbox); @@ -574,7 +574,7 @@ gtk_widget_show(dialog->icon_check); gtk_box_pack_start(GTK_BOX(vbox), dialog->icon_check, FALSE, FALSE, 0); - dialog->icon_hbox = hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + dialog->icon_hbox = hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_widget_set_sensitive(hbox, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); @@ -601,8 +601,8 @@ gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0); gtk_widget_show(vbox2); - hbox2 = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); - gtk_box_pack_start(GTK_BOX(vbox2), hbox2, FALSE, FALSE, GAIM_HIG_BORDER); + hbox2 = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); + gtk_box_pack_start(GTK_BOX(vbox2), hbox2, FALSE, FALSE, PIDGIN_HIG_BORDER); gtk_widget_show(hbox2); button = gtk_button_new_from_stock(GTK_STOCK_REMOVE); @@ -691,7 +691,7 @@ gtk_widget_show(dialog->protocol_frame); /* Main vbox */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_container_add(GTK_CONTAINER(frame), vbox); gtk_widget_show(vbox); @@ -779,7 +779,7 @@ { gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); if (gtk_entry_get_invisible_char(GTK_ENTRY(entry)) == '*') - gtk_entry_set_invisible_char(GTK_ENTRY(entry), GAIM_INVISIBLE_CHAR); + gtk_entry_set_invisible_char(GTK_ENTRY(entry), PIDGIN_INVISIBLE_CHAR); } if (str_value != NULL) @@ -979,7 +979,7 @@ gtk_widget_show(dialog->proxy_frame); /* Main vbox */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_container_add(GTK_CONTAINER(frame), vbox); gtk_widget_show(vbox); @@ -989,8 +989,8 @@ add_pref_box(dialog, vbox, _("Proxy _type:"), dialog->proxy_dropdown); /* Setup the second vbox, which may be hidden at times. */ - dialog->proxy_vbox = vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); - gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, FALSE, GAIM_HIG_BORDER); + dialog->proxy_vbox = vbox2 = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); + gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, FALSE, PIDGIN_HIG_BORDER); gtk_widget_show(vbox2); /* Host */ @@ -1013,7 +1013,7 @@ dialog->proxy_pass_entry = gtk_entry_new(); gtk_entry_set_visibility(GTK_ENTRY(dialog->proxy_pass_entry), FALSE); if (gtk_entry_get_invisible_char(GTK_ENTRY(dialog->proxy_pass_entry)) == '*') - gtk_entry_set_invisible_char(GTK_ENTRY(dialog->proxy_pass_entry), GAIM_INVISIBLE_CHAR); + gtk_entry_set_invisible_char(GTK_ENTRY(dialog->proxy_pass_entry), PIDGIN_INVISIBLE_CHAR); add_pref_box(dialog, vbox2, _("Pa_ssword:"), dialog->proxy_pass_entry); if (dialog->account != NULL && @@ -1431,13 +1431,13 @@ gtk_window_set_resizable(GTK_WINDOW(win), FALSE); - gtk_container_set_border_width(GTK_CONTAINER(win), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(win), PIDGIN_HIG_BORDER); g_signal_connect(G_OBJECT(win), "delete_event", G_CALLBACK(account_win_destroy_cb), dialog); /* Setup the vbox */ - main_vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + main_vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(win), main_vbox); gtk_widget_show(main_vbox); @@ -1446,8 +1446,8 @@ gtk_widget_show(GTK_WIDGET(notebook)); /* Setup the inner vbox */ - dialog->top_vbox = vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); - gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BORDER); + dialog->top_vbox = vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(vbox), PIDGIN_HIG_BORDER); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, gtk_label_new_with_mnemonic(_("_Basic"))); gtk_widget_show(vbox); @@ -1457,8 +1457,8 @@ add_user_options(dialog, vbox); /* Setup the page with 'Advanced'. */ - dialog->bottom_vbox = dbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); - gtk_container_set_border_width(GTK_CONTAINER(dbox), GAIM_HIG_BORDER); + dialog->bottom_vbox = dbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(dbox), PIDGIN_HIG_BORDER); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), dbox, gtk_label_new_with_mnemonic(_("_Advanced"))); gtk_widget_show(dbox); @@ -1469,7 +1469,7 @@ /* Setup the button box */ bbox = gtk_hbutton_box_new(); - gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE); + gtk_box_set_spacing(GTK_BOX(bbox), PIDGIN_HIG_BOX_SPACE); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); gtk_box_pack_end(GTK_BOX(main_vbox), bbox, FALSE, TRUE, 0); gtk_widget_show(bbox); @@ -2268,7 +2268,7 @@ gtk_window_set_default_size(GTK_WINDOW(win), width, height); gtk_window_set_role(GTK_WINDOW(win), "accounts"); gtk_window_set_title(GTK_WINDOW(win), _("Accounts")); - gtk_container_set_border_width(GTK_CONTAINER(win), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(win), PIDGIN_HIG_BORDER); g_signal_connect(G_OBJECT(win), "delete_event", G_CALLBACK(accedit_win_destroy_cb), accounts_window); @@ -2276,7 +2276,7 @@ G_CALLBACK(configure_cb), accounts_window); /* Setup the vbox */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(win), vbox); gtk_widget_show(vbox); @@ -2287,7 +2287,7 @@ /* Button box. */ bbox = gtk_hbutton_box_new(); - gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE); + gtk_box_set_spacing(GTK_BOX(bbox), PIDGIN_HIG_BOX_SPACE); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0); gtk_widget_show(bbox);
--- a/pidgin/gtkblist.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkblist.c Mon Mar 19 06:35:51 2007 +0000 @@ -36,7 +36,7 @@ #include "plugin.h" #include "request.h" #include "signals.h" -#include "gaimstock.h" +#include "pidginstock.h" #include "util.h" #include "gtkaccount.h" @@ -128,12 +128,12 @@ static void pidgin_blist_update(GaimBuddyList *list, GaimBlistNode *node); static void pidgin_blist_update_group(GaimBuddyList *list, GaimBlistNode *node); static void pidgin_blist_update_contact(GaimBuddyList *list, GaimBlistNode *node); -static char *gaim_get_tooltip_text(GaimBlistNode *node, gboolean full); +static char *pidgin_get_tooltip_text(GaimBlistNode *node, gboolean full); static const char *item_factory_translate_func (const char *path, gpointer func_data); static gboolean get_iter_from_node(GaimBlistNode *node, GtkTreeIter *iter); static void redo_buddy_list(GaimBuddyList *list, gboolean remove, gboolean rerender); static void pidgin_blist_collapse_contact_cb(GtkWidget *w, GaimBlistNode *node); -static char *gaim_get_group_title(GaimBlistNode *gnode, gboolean expanded); +static char *pidgin_get_group_title(GaimBlistNode *gnode, gboolean expanded); static void pidgin_blist_tooltip_destroy(void); @@ -590,7 +590,7 @@ pce = tmp->data; - rowbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); + rowbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_box_pack_start(GTK_BOX(data->entries_box), rowbox, FALSE, FALSE, 0); label = gtk_label_new_with_mnemonic(pce->label); @@ -619,7 +619,7 @@ { gtk_entry_set_visibility(GTK_ENTRY(input), FALSE); if (gtk_entry_get_invisible_char(GTK_ENTRY(input)) == '*') - gtk_entry_set_invisible_char(GTK_ENTRY(input), GAIM_INVISIBLE_CHAR); + gtk_entry_set_invisible_char(GTK_ENTRY(input), PIDGIN_INVISIBLE_CHAR); } gtk_box_pack_end(GTK_BOX(rowbox), input, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(input), "changed", @@ -706,14 +706,14 @@ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, PIDGIN_STOCK_CHAT, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response(GTK_DIALOG(data->window), GTK_RESPONSE_OK); - gtk_container_set_border_width(GTK_CONTAINER(data->window), GAIM_HIG_BOX_SPACE); + 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), GAIM_HIG_BORDER); + 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), GAIM_HIG_BOX_SPACE); + GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), PIDGIN_HIG_BOX_SPACE); gtk_window_set_role(GTK_WINDOW(data->window), "join_chat"); - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), hbox); gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); gtk_misc_set_alignment(GTK_MISC(img), 0, 0); @@ -728,7 +728,7 @@ gtk_misc_set_alignment(GTK_MISC(label), 0, 0); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - rowbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); + rowbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_box_pack_start(GTK_BOX(vbox), rowbox, TRUE, TRUE, 0); data->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); @@ -774,7 +774,7 @@ if (GAIM_BLIST_NODE_IS_GROUP(node)) { char *title; - title = gaim_get_group_title(node, TRUE); + title = pidgin_get_group_title(node, TRUE); gtk_tree_store_set(gtkblist->treemodel, iter, NAME_COLUMN, title, @@ -798,7 +798,7 @@ if (GAIM_BLIST_NODE_IS_GROUP(node)) { char *title; - title = gaim_get_group_title(node, FALSE); + title = pidgin_get_group_title(node, FALSE); gtk_tree_store_set(gtkblist->treemodel, iter, NAME_COLUMN, title, @@ -2270,7 +2270,7 @@ td->status_icon = pidgin_blist_get_status_icon(node, PIDGIN_STATUS_ICON_LARGE); td->avatar = pidgin_blist_get_buddy_icon(node, !full, FALSE, TRUE); td->prpl_icon = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL); - tooltip_text = gaim_get_tooltip_text(node, full); + tooltip_text = pidgin_get_tooltip_text(node, full); td->layout = gtk_widget_create_pango_layout(gtkblist->tipwindow, NULL); td->name_layout = gtk_widget_create_pango_layout(gtkblist->tipwindow, NULL); @@ -2799,7 +2799,7 @@ * Private Utility functions * *********************************************************/ -static char *gaim_get_tooltip_text(GaimBlistNode *node, gboolean full) +static char *pidgin_get_tooltip_text(GaimBlistNode *node, gboolean full) { GString *str = g_string_new(""); GaimPlugin *prpl; @@ -3925,7 +3925,7 @@ g_object_unref(pixbuf); gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, - GAIM_HIG_BOX_SPACE); + PIDGIN_HIG_BOX_SPACE); } } @@ -3937,7 +3937,7 @@ g_object_set(label, "ellipsize", PANGO_ELLIPSIZE_END, NULL); #endif gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, - GAIM_HIG_BOX_SPACE); + PIDGIN_HIG_BOX_SPACE); /* Create the actual button and put the icon and text on it */ button = gtk_button_new(); @@ -4052,7 +4052,7 @@ static GtkWidget * kiosk_page() { - GtkWidget *ret = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + GtkWidget *ret = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); GtkWidget *label; GtkWidget *entry; GtkWidget *bbox; @@ -4088,7 +4088,7 @@ label = gtk_label_new(NULL); gtk_box_pack_start(GTK_BOX(ret), label, TRUE, TRUE, 0); - gtk_container_set_border_width(GTK_CONTAINER(ret), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(ret), PIDGIN_HIG_BORDER); gtk_widget_show_all(ret); return ret; @@ -4754,7 +4754,7 @@ expanded = gtk_tree_view_row_expanded(GTK_TREE_VIEW(gtkblist->treeview), path); gtk_tree_path_free(path); - title = gaim_get_group_title(gnode, expanded); + title = pidgin_get_group_title(gnode, expanded); gtk_tree_store_set(gtkblist->treemodel, &iter, STATUS_ICON_VISIBLE_COLUMN, FALSE, @@ -4774,7 +4774,7 @@ } } -static char *gaim_get_group_title(GaimBlistNode *gnode, gboolean expanded) +static char *pidgin_get_group_title(GaimBlistNode *gnode, gboolean expanded) { GaimGroup *group; GdkColor textcolor; @@ -5248,15 +5248,15 @@ NULL); gtk_dialog_set_default_response(GTK_DIALOG(data->window), GTK_RESPONSE_OK); - gtk_container_set_border_width(GTK_CONTAINER(data->window), GAIM_HIG_BOX_SPACE); + 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), GAIM_HIG_BORDER); - gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BOX_SPACE); + 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_window_set_role(GTK_WINDOW(data->window), "add_buddy"); gtk_window_set_type_hint(GTK_WINDOW(data->window), GDK_WINDOW_TYPE_HINT_DIALOG); - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), hbox); gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); gtk_misc_set_alignment(GTK_MISC(img), 0, 0); @@ -5275,7 +5275,7 @@ gtk_misc_set_alignment(GTK_MISC(label), 0, 0); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_container_add(GTK_CONTAINER(vbox), hbox); g_signal_connect(G_OBJECT(data->window), "destroy", @@ -5518,7 +5518,7 @@ { gtk_entry_set_visibility(GTK_ENTRY(input), FALSE); if (gtk_entry_get_invisible_char(GTK_ENTRY(input)) == '*') - gtk_entry_set_invisible_char(GTK_ENTRY(input), GAIM_INVISIBLE_CHAR); + gtk_entry_set_invisible_char(GTK_ENTRY(input), PIDGIN_INVISIBLE_CHAR); } gtk_box_pack_end(GTK_BOX(rowbox), input, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(input), "changed", @@ -5624,15 +5624,15 @@ NULL); gtk_dialog_set_default_response(GTK_DIALOG(data->window), GTK_RESPONSE_OK); - gtk_container_set_border_width(GTK_CONTAINER(data->window), GAIM_HIG_BOX_SPACE); + 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), GAIM_HIG_BORDER); - gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BOX_SPACE); + 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_window_set_role(GTK_WINDOW(data->window), "add_chat"); gtk_window_set_type_hint(GTK_WINDOW(data->window), GDK_WINDOW_TYPE_HINT_DIALOG); - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), hbox); gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
--- a/pidgin/gtkcellrendererexpander.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkcellrendererexpander.c Mon Mar 19 06:35:51 2007 +0000 @@ -185,7 +185,7 @@ GtkCellRenderer *pidgin_cell_renderer_expander_new(void) { - return g_object_new(GAIM_TYPE_GTK_CELL_RENDERER_EXPANDER, NULL); + return g_object_new(PIDGIN_TYPE_GTK_CELL_RENDERER_EXPANDER, NULL); } static void pidgin_cell_renderer_expander_get_size (GtkCellRenderer *cell,
--- a/pidgin/gtkcellrendererexpander.h Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkcellrendererexpander.h Mon Mar 19 06:35:51 2007 +0000 @@ -28,12 +28,12 @@ #endif /* __cplusplus */ -#define GAIM_TYPE_GTK_CELL_RENDERER_EXPANDER (pidgin_cell_renderer_expander_get_type()) -#define PIDGIN_CELL_RENDERER_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GAIM_TYPE_GTK_CELL_RENDERER_EXPANDER, PidginCellRendererExpander)) +#define PIDGIN_TYPE_GTK_CELL_RENDERER_EXPANDER (pidgin_cell_renderer_expander_get_type()) +#define PIDGIN_CELL_RENDERER_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PIDGIN_TYPE_GTK_CELL_RENDERER_EXPANDER, PidginCellRendererExpander)) #define PIDGIN_CELL_RENDERER_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIM_TYPE_GTK_CELL_RENDERER_EXPANDER, PidginCellRendererExpanderClass)) -#define GAIM_IS_GTK_CELL_RENDERER_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIM_TYPE_GTK_CELL_RENDERER_EXPANDER)) -#define GAIM_IS_GTK_CELL_RENDERER_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIM_TYPE_GTK_CELL_RENDERER_EXPANDER)) -#define PIDGIN_CELL_RENDERER_EXPANDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIM_TYPE_GTK_CELL_RENDERER_EXPANDER, PidginCellRendererExpanderClass)) +#define PIDGIN_IS_GTK_CELL_RENDERER_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIDGIN_TYPE_GTK_CELL_RENDERER_EXPANDER)) +#define PIDGIN_IS_GTK_CELL_RENDERER_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIDGIN_TYPE_GTK_CELL_RENDERER_EXPANDER)) +#define PIDGIN_CELL_RENDERER_EXPANDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIDGIN_TYPE_GTK_CELL_RENDERER_EXPANDER, PidginCellRendererExpanderClass)) typedef struct _PidginCellRendererExpander PidginCellRendererExpander; typedef struct _PidginCellRendererExpanderClass PidginCellRendererExpanderClass;
--- a/pidgin/gtkcellrendererprogress.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkcellrendererprogress.c Mon Mar 19 06:35:51 2007 +0000 @@ -214,7 +214,7 @@ GtkCellRenderer *pidgin_cell_renderer_progress_new(void) { - return g_object_new(GAIM_TYPE_GTK_CELL_RENDERER_PROGRESS, NULL); + return g_object_new(PIDGIN_TYPE_GTK_CELL_RENDERER_PROGRESS, NULL); } static void pidgin_cell_renderer_progress_get_size (GtkCellRenderer *cell,
--- a/pidgin/gtkcellrendererprogress.h Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkcellrendererprogress.h Mon Mar 19 06:35:51 2007 +0000 @@ -28,12 +28,12 @@ #endif /* __cplusplus */ -#define GAIM_TYPE_GTK_CELL_RENDERER_PROGRESS (pidgin_cell_renderer_progress_get_type()) -#define PIDGIN_CELL_RENDERER_PROGRESS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GAIM_TYPE_GTK_CELL_RENDERER_PROGRESS, PidginCellRendererProgress)) -#define PIDGIN_CELL_RENDERER_PROGRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIM_TYPE_GTK_CELL_RENDERER_PROGRESS, PidginCellRendererProgressClass)) -#define GAIM_IS_GTK_CELL_PROGRESS_PROGRESS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIM_TYPE_GTK_CELL_RENDERER_PROGRESS)) -#define GAIM_IS_GTK_CELL_PROGRESS_PROGRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIM_TYPE_GTK_CELL_RENDERER_PROGRESS)) -#define PIDGIN_CELL_RENDERER_PROGRESS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIM_TYPE_GTK_CELL_RENDERER_PROGRESS, PidginCellRendererProgressClass)) +#define PIDGIN_TYPE_GTK_CELL_RENDERER_PROGRESS (pidgin_cell_renderer_progress_get_type()) +#define PIDGIN_CELL_RENDERER_PROGRESS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PIDGIN_TYPE_GTK_CELL_RENDERER_PROGRESS, PidginCellRendererProgress)) +#define PIDGIN_CELL_RENDERER_PROGRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIDGIN_TYPE_GTK_CELL_RENDERER_PROGRESS, PidginCellRendererProgressClass)) +#define PIDGIN_IS_GTK_CELL_PROGRESS_PROGRESS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIDGIN_TYPE_GTK_CELL_RENDERER_PROGRESS)) +#define PIDGIN_IS_GTK_CELL_PROGRESS_PROGRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIDGIN_TYPE_GTK_CELL_RENDERER_PROGRESS)) +#define PIDGIN_CELL_RENDERER_PROGRESS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIDGIN_TYPE_GTK_CELL_RENDERER_PROGRESS, PidginCellRendererProgressClass)) typedef struct _PidginCellRendererProgress PidginCellRendererProgress; typedef struct _PidginCellRendererProgressClass PidginCellRendererProgressClass;
--- a/pidgin/gtkconn.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkconn.c Mon Mar 19 06:35:51 2007 +0000 @@ -33,7 +33,7 @@ #include "gtkconn.h" #include "gtkdialogs.h" #include "gtkstatusbox.h" -#include "gaimstock.h" +#include "pidginstock.h" #include "gtkutils.h" #include "util.h" @@ -45,12 +45,12 @@ typedef struct { int delay; guint timeout; -} GaimAutoRecon; +} PidginAutoRecon; /** * Contains accounts that are auto-reconnecting. * The key is a pointer to the GaimAccount and the - * value is a pointer to a GaimAutoRecon. + * value is a pointer to a PidginAutoRecon. */ static GHashTable *hash = NULL; @@ -102,7 +102,7 @@ static void free_auto_recon(gpointer data) { - GaimAutoRecon *info = data; + PidginAutoRecon *info = data; if (info->timeout != 0) g_source_remove(info->timeout); @@ -114,7 +114,7 @@ do_signon(gpointer data) { GaimAccount *account = data; - GaimAutoRecon *info; + PidginAutoRecon *info; GaimStatus *status; gaim_debug_info("autorecon", "do_signon called\n"); @@ -139,7 +139,7 @@ pidgin_connection_report_disconnect(GaimConnection *gc, const char *text) { GaimAccount *account = NULL; - GaimAutoRecon *info; + PidginAutoRecon *info; account = gaim_connection_get_account(gc); info = g_hash_table_lookup(hash, account); @@ -147,7 +147,7 @@ pidgin_blist_update_account_error_state(account, text); if (!gc->wants_to_die) { if (info == NULL) { - info = g_new0(GaimAutoRecon, 1); + info = g_new0(PidginAutoRecon, 1); g_hash_table_insert(hash, account, info); info->delay = g_random_int_range(INITIAL_RECON_DELAY_MIN, INITIAL_RECON_DELAY_MAX); } else {
--- a/pidgin/gtkconv.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkconv.c Mon Mar 19 06:35:51 2007 +0000 @@ -64,7 +64,7 @@ #include "gtkprivacy.h" #include "gtkthemes.h" #include "gtkutils.h" -#include "gaimstock.h" +#include "pidginstock.h" #include "gtknickcolors.h" @@ -166,7 +166,7 @@ static void add_chat_buddy_common(GaimConversation *conv, GaimConvChatBuddy *cb, const char *old_name); static gboolean tab_complete(GaimConversation *conv); static void pidgin_conv_updated(GaimConversation *conv, GaimConvUpdateType type); -static void gtkconv_set_unseen(PidginConversation *gtkconv, GaimUnseenState state); +static void gtkconv_set_unseen(PidginConversation *gtkconv, PidginUnseenState state); static void update_typing_icon(PidginConversation *gtkconv); static const char *item_factory_translate_func (const char *path, gpointer func_data); gboolean pidgin_conv_has_focus(GaimConversation *conv); @@ -859,7 +859,7 @@ gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), GTK_RESPONSE_OK); - gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), GAIM_HIG_BOX_SPACE); + gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), PIDGIN_HIG_BOX_SPACE); gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); @@ -868,11 +868,11 @@ /* Setup the outside spacing. */ vbox = GTK_DIALOG(invite_dialog)->vbox; - gtk_box_set_spacing(GTK_BOX(vbox), GAIM_HIG_BORDER); - gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); + gtk_box_set_spacing(GTK_BOX(vbox), PIDGIN_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(vbox), PIDGIN_HIG_BOX_SPACE); /* Setup the inner hbox and put the dialog's icon in it. */ - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(vbox), hbox); gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); gtk_misc_set_alignment(GTK_MISC(img), 0, 0); @@ -891,14 +891,14 @@ gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); /* hbox for the table, and to give it some spacing on the left. */ - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_container_add(GTK_CONTAINER(vbox), hbox); /* Setup the table we're going to use to lay stuff out. */ table = gtk_table_new(2, 2, FALSE); - gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); - gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); - gtk_container_set_border_width(GTK_CONTAINER(table), GAIM_HIG_BORDER); + gtk_table_set_row_spacings(GTK_TABLE(table), PIDGIN_HIG_BOX_SPACE); + gtk_table_set_col_spacings(GTK_TABLE(table), PIDGIN_HIG_BOX_SPACE); + gtk_container_set_border_width(GTK_CONTAINER(table), PIDGIN_HIG_BORDER); gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); /* Now the Buddy label */ @@ -1166,14 +1166,14 @@ g_signal_connect(G_OBJECT(gtkwin->dialogs.search), "response", G_CALLBACK(do_search_cb), s); - gtk_container_set_border_width(GTK_CONTAINER(gtkwin->dialogs.search), GAIM_HIG_BOX_SPACE); + gtk_container_set_border_width(GTK_CONTAINER(gtkwin->dialogs.search), PIDGIN_HIG_BOX_SPACE); gtk_window_set_resizable(GTK_WINDOW(gtkwin->dialogs.search), FALSE); gtk_dialog_set_has_separator(GTK_DIALOG(gtkwin->dialogs.search), FALSE); - gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(gtkwin->dialogs.search)->vbox), GAIM_HIG_BORDER); + gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(gtkwin->dialogs.search)->vbox), PIDGIN_HIG_BORDER); gtk_container_set_border_width( - GTK_CONTAINER(GTK_DIALOG(gtkwin->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); - - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); + GTK_CONTAINER(GTK_DIALOG(gtkwin->dialogs.search)->vbox), PIDGIN_HIG_BOX_SPACE); + + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkwin->dialogs.search)->vbox), hbox); gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); @@ -2685,7 +2685,7 @@ GList * pidgin_conversations_find_unseen_list(GaimConversationType type, - GaimUnseenState min_state, + PidginUnseenState min_state, gboolean hidden_only, guint max_count) { @@ -4103,10 +4103,10 @@ height += (oneline.height + pad_inside) * (wrapped_lines - lines); gtk_widget_size_request(gtkconv->lower_hbox, &sr); - if (sr.height < height + GAIM_HIG_BOX_SPACE) { + if (sr.height < height + PIDGIN_HIG_BOX_SPACE) { gtkconv->auto_resize = TRUE; gtkconv->entry_growing = TRUE; - gtk_widget_set_size_request(gtkconv->lower_hbox, -1, height + GAIM_HIG_BOX_SPACE); + gtk_widget_set_size_request(gtkconv->lower_hbox, -1, height + PIDGIN_HIG_BOX_SPACE); g_idle_add(reset_auto_resize_cb, gtkconv); } } @@ -4143,13 +4143,13 @@ gtk_widget_show(vpaned); /* Setup the top part of the pane. */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); gtk_widget_show(vbox); if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) { - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); @@ -4200,7 +4200,7 @@ G_CALLBACK(refocus_entry_cb), gtkconv); /* Build the right pane. */ - lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + lbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); gtk_widget_show(lbox); @@ -4275,15 +4275,15 @@ gtk_container_add(GTK_CONTAINER(sw), list); /* Setup the bottom half of the conversation window */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); gtk_widget_show(vbox); - gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + gtkconv->lower_hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); gtk_widget_show(gtkconv->lower_hbox); - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); gtk_widget_show(vbox); @@ -4345,7 +4345,7 @@ gtk_widget_show(paned); /* Setup the top part of the pane */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); gtk_widget_show(vbox); @@ -4374,15 +4374,15 @@ G_CALLBACK(refocus_entry_cb), gtkconv); /* Setup the bottom half of the conversation window */ - vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox2 = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); gtk_widget_show(vbox2); - gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + gtkconv->lower_hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); gtk_widget_show(gtkconv->lower_hbox); - vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox2 = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); gtk_widget_show(vbox2); @@ -4669,9 +4669,9 @@ G_CALLBACK(conv_dnd_recv), gtkconv); /* Setup the container for the tab. */ - gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); g_object_set_data(G_OBJECT(tab_cont), "PidginConversation", gtkconv); - gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); + gtk_container_set_border_width(GTK_CONTAINER(tab_cont), PIDGIN_HIG_BOX_SPACE); gtk_container_add(GTK_CONTAINER(tab_cont), pane); gtk_widget_show(pane); @@ -5256,7 +5256,7 @@ /* Tab highlighting stuff */ if (!(flags & GAIM_MESSAGE_SEND) && !pidgin_conv_has_focus(conv)) { - GaimUnseenState unseen = PIDGIN_UNSEEN_NONE; + PidginUnseenState unseen = PIDGIN_UNSEEN_NONE; if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) unseen = PIDGIN_UNSEEN_NICK; @@ -6325,8 +6325,8 @@ continue; if (horiz) { - if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && - x_rel <= tab->allocation.x + tab->allocation.width + GAIM_HIG_BOX_SPACE) { + if (x_rel >= tab->allocation.x - PIDGIN_HIG_BOX_SPACE && + x_rel <= tab->allocation.x + tab->allocation.width + PIDGIN_HIG_BOX_SPACE) { page_num = i; if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) @@ -6335,8 +6335,8 @@ break; } } else { - if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && - y_rel <= tab->allocation.y + tab->allocation.height + GAIM_HIG_BOX_SPACE) { + if (y_rel >= tab->allocation.y - PIDGIN_HIG_BOX_SPACE && + y_rel <= tab->allocation.y + tab->allocation.height + PIDGIN_HIG_BOX_SPACE) { page_num = i; if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) @@ -6605,7 +6605,7 @@ conv_placement_pref_cb(const char *name, GaimPrefType type, gconstpointer value, gpointer data) { - GaimConvPlacementFunc func; + PidginConvPlacementFunc func; if (strcmp(name, "/gaim/gtk/conversations/placement")) return; @@ -7089,7 +7089,7 @@ #include "gtkprefs.h" #include "gtkprivacy.h" #include "gtkutils.h" -#include "gaimstock.h" +#include "pidginstock.h" #include "gtkimhtml.h" #include "gtkimhtmltoolbar.h" @@ -7189,7 +7189,7 @@ } static void -gtkconv_set_unseen(PidginConversation *gtkconv, GaimUnseenState state) +gtkconv_set_unseen(PidginConversation *gtkconv, PidginUnseenState state) { if (state == PIDGIN_UNSEEN_NONE) { @@ -7979,10 +7979,10 @@ angle = 270; if (angle) - gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + gtkconv->tabby = tabby = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); else - gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); - gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + gtkconv->tabby = tabby = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); + gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); /* Close button. */ gtkconv->close = gtk_button_new(); @@ -8274,12 +8274,12 @@ { char *id; char *name; - GaimConvPlacementFunc fnc; + PidginConvPlacementFunc fnc; } ConvPlacementData; static GList *conv_placement_fncs = NULL; -static GaimConvPlacementFunc place_conv = NULL; +static PidginConvPlacementFunc place_conv = NULL; /* This one places conversations in the last made window. */ static void @@ -8451,7 +8451,7 @@ static void add_conv_placement_fnc(const char *id, const char *name, - GaimConvPlacementFunc fnc) + PidginConvPlacementFunc fnc) { ConvPlacementData *data; @@ -8501,7 +8501,7 @@ void pidgin_conv_placement_add_fnc(const char *id, const char *name, - GaimConvPlacementFunc fnc) + PidginConvPlacementFunc fnc) { g_return_if_fail(id != NULL); g_return_if_fail(name != NULL); @@ -8542,7 +8542,7 @@ return data->name; } -GaimConvPlacementFunc +PidginConvPlacementFunc pidgin_conv_placement_get_fnc(const char *id) { ConvPlacementData *data; @@ -8558,7 +8558,7 @@ } void -pidgin_conv_placement_set_current_func(GaimConvPlacementFunc func) +pidgin_conv_placement_set_current_func(PidginConvPlacementFunc func) { g_return_if_fail(func != NULL); @@ -8569,7 +8569,7 @@ place_conv = NULL; } -GaimConvPlacementFunc +PidginConvPlacementFunc pidgin_conv_placement_get_current_func(void) { return place_conv;
--- a/pidgin/gtkconv.h Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkconv.h Mon Mar 19 06:35:51 2007 +0000 @@ -39,7 +39,7 @@ PIDGIN_UNSEEN_NO_LOG, /**< Unseen text with NO_LOG flag. */ PIDGIN_UNSEEN_TEXT, /**< Unseen text in the conversation. */ PIDGIN_UNSEEN_NICK /**< Unseen text and the nick was said. */ -} GaimUnseenState; +} PidginUnseenState; enum { CHAT_USERS_ICON_COLUMN, @@ -147,7 +147,7 @@ GtkWidget *toolbar; - GaimUnseenState unseen_state; + PidginUnseenState unseen_state; guint unseen_count; union @@ -212,7 +212,7 @@ */ GList * pidgin_conversations_find_unseen_list(GaimConversationType type, - GaimUnseenState min_state, + PidginUnseenState min_state, gboolean hidden_only, guint max_count);
--- a/pidgin/gtkconvwin.h Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkconvwin.h Mon Mar 19 06:35:51 2007 +0000 @@ -132,15 +132,15 @@ **************************************************************************/ /*@{*/ -typedef void (*GaimConvPlacementFunc)(PidginConversation *); +typedef void (*PidginConvPlacementFunc)(PidginConversation *); GList *pidgin_conv_placement_get_options(void); -void pidgin_conv_placement_add_fnc(const char *id, const char *name, GaimConvPlacementFunc fnc); +void pidgin_conv_placement_add_fnc(const char *id, const char *name, PidginConvPlacementFunc fnc); void pidgin_conv_placement_remove_fnc(const char *id); const char *pidgin_conv_placement_get_name(const char *id); -GaimConvPlacementFunc pidgin_conv_placement_get_fnc(const char *id); -void pidgin_conv_placement_set_current_func(GaimConvPlacementFunc func); -GaimConvPlacementFunc pidgin_conv_placement_get_current_func(void); +PidginConvPlacementFunc pidgin_conv_placement_get_fnc(const char *id); +void pidgin_conv_placement_set_current_func(PidginConvPlacementFunc func); +PidginConvPlacementFunc pidgin_conv_placement_get_current_func(void); void pidgin_conv_placement_place(PidginConversation *gtkconv); /*@}*/
--- a/pidgin/gtkdebug.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkdebug.c Mon Mar 19 06:35:51 2007 +0000 @@ -34,7 +34,7 @@ #include "gtkdialogs.h" #include "gtkimhtml.h" #include "gtkutils.h" -#include "gaimstock.h" +#include "pidginstock.h" #ifdef HAVE_REGEX_H # include <regex.h> @@ -172,14 +172,14 @@ g_signal_connect(G_OBJECT(win->find), "response", G_CALLBACK(do_find_cb), f); - gtk_container_set_border_width(GTK_CONTAINER(win->find), GAIM_HIG_BOX_SPACE); + gtk_container_set_border_width(GTK_CONTAINER(win->find), PIDGIN_HIG_BOX_SPACE); gtk_window_set_resizable(GTK_WINDOW(win->find), FALSE); gtk_dialog_set_has_separator(GTK_DIALOG(win->find), FALSE); - gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(win->find)->vbox), GAIM_HIG_BORDER); + gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(win->find)->vbox), PIDGIN_HIG_BORDER); gtk_container_set_border_width( - GTK_CONTAINER(GTK_DIALOG(win->find)->vbox), GAIM_HIG_BOX_SPACE); + GTK_CONTAINER(GTK_DIALOG(win->find)->vbox), PIDGIN_HIG_BOX_SPACE); - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(win->find)->vbox), hbox); img = gtk_image_new_from_stock(PIDGIN_STOCK_DIALOG_QUESTION,
--- a/pidgin/gtkdialogs.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkdialogs.c Mon Mar 19 06:35:51 2007 +0000 @@ -37,13 +37,13 @@ #include "gtkimhtmltoolbar.h" #include "gtklog.h" #include "gtkutils.h" -#include "gaimstock.h" +#include "pidginstock.h" static GList *dialogwindows = NULL; static GtkWidget *about = NULL; -struct _GaimGroupMergeObject { +struct _PidginGroupMergeObject { GaimGroup* parent; char *new_name; }; @@ -321,11 +321,11 @@ gtk_window_set_resizable(GTK_WINDOW(about), TRUE); gtk_window_set_default_size(GTK_WINDOW(about), 340, 450); - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); - gtk_container_set_border_width(GTK_CONTAINER(hbox), GAIM_HIG_BORDER); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(hbox), PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(about), hbox); - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(hbox), vbox); /* Generate a logo with a version number */ @@ -777,17 +777,17 @@ if (strlen(gtk_label_get_label(GTK_LABEL(label))) <= 0) return FALSE; - window = gtk_dialog_new_with_buttons(GAIM_ALERT_TITLE, NULL, 0, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); + window = gtk_dialog_new_with_buttons(PIDGIN_ALERT_TITLE, NULL, 0, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG(window), GTK_RESPONSE_OK); g_signal_connect(G_OBJECT(window), "response", G_CALLBACK(gtk_widget_destroy), NULL); - gtk_container_set_border_width (GTK_CONTAINER(window), GAIM_HIG_BOX_SPACE); + 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), GAIM_HIG_BORDER); - gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(window)->vbox), GAIM_HIG_BOX_SPACE); + 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); - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), 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); @@ -1054,14 +1054,14 @@ } } -static void free_ggmo(struct _GaimGroupMergeObject *ggp) +static void free_ggmo(struct _PidginGroupMergeObject *ggp) { g_free(ggp->new_name); g_free(ggp); } static void -pidgindialogs_merge_groups_cb(struct _GaimGroupMergeObject *GGP) +pidgindialogs_merge_groups_cb(struct _PidginGroupMergeObject *GGP) { gaim_blist_rename_group(GGP->parent, GGP->new_name); free_ggmo(GGP); @@ -1071,7 +1071,7 @@ pidgindialogs_merge_groups(GaimGroup *source, const char *new_name) { gchar *text; - struct _GaimGroupMergeObject *ggp; + struct _PidginGroupMergeObject *ggp; g_return_if_fail(source != NULL); g_return_if_fail(new_name != NULL); @@ -1080,7 +1080,7 @@ _("You are about to merge the group called %s into the group " "called %s. Do you want to continue?"), source->name, new_name); - ggp = g_new(struct _GaimGroupMergeObject, 1); + ggp = g_new(struct _PidginGroupMergeObject, 1); ggp->parent = source; ggp->new_name = g_strdup(new_name);
--- a/pidgin/gtkdnd-hints.h Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkdnd-hints.h Mon Mar 19 06:35:51 2007 +0000 @@ -20,8 +20,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef _GAIM_DND_HINTS_H_ -#define _GAIM_DND_HINTS_H_ +#ifndef _PIDGIN_DND_HINTS_H_ +#define _PIDGIN_DND_HINTS_H_ #include <glib.h> #include <gtk/gtkwidget.h> @@ -83,4 +83,4 @@ void dnd_hints_show_relative(DndHintWindowId id, GtkWidget *widget, DndHintPosition horiz, DndHintPosition vert); -#endif /* _GAIM_DND_HINTS_H_ */ +#endif /* _PIDGIN_DND_HINTS_H_ */
--- a/pidgin/gtkdocklet-x11.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkdocklet-x11.c Mon Mar 19 06:35:51 2007 +0000 @@ -25,7 +25,7 @@ #include "internal.h" #include "pidgin.h" #include "debug.h" -#include "gaimstock.h" +#include "pidginstock.h" #include "gtkdialogs.h"
--- a/pidgin/gtkdocklet.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkdocklet.c Mon Mar 19 06:35:51 2007 +0000 @@ -39,7 +39,7 @@ #include "gtksavedstatuses.h" #include "gtksound.h" #include "gtkutils.h" -#include "gaimstock.h" +#include "pidginstock.h" #include "gtkdocklet.h" #include "gtkdialogs.h" @@ -244,7 +244,7 @@ **************************************************************************/ #if 0 static void -gaim_quit_cb() +pidgin_quit_cb() { /* TODO: confirm quit while pending */ } @@ -409,7 +409,7 @@ } static GtkWidget * -new_menu_item_with_gaim_icon(GtkWidget *menu, const char *str, GaimStatusPrimitive primitive, GtkSignalFunc sf, gpointer data, guint accel_key, guint accel_mods, char *mod) +new_menu_item_with_status_icon(GtkWidget *menu, const char *str, GaimStatusPrimitive primitive, GtkSignalFunc sf, gpointer data, guint accel_key, guint accel_mods, char *mod) { GtkWidget *menuitem; GdkPixbuf *pixbuf; @@ -443,19 +443,19 @@ menuitem = gtk_menu_item_new_with_label(_("Change Status")); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); - new_menu_item_with_gaim_icon(submenu, _("Available"), + new_menu_item_with_status_icon(submenu, _("Available"), GAIM_STATUS_AVAILABLE, G_CALLBACK(activate_status_primitive_cb), GINT_TO_POINTER(GAIM_STATUS_AVAILABLE), 0, 0, NULL); - new_menu_item_with_gaim_icon(submenu, _("Away"), + new_menu_item_with_status_icon(submenu, _("Away"), GAIM_STATUS_AWAY, G_CALLBACK(activate_status_primitive_cb), GINT_TO_POINTER(GAIM_STATUS_AWAY), 0, 0, NULL); - new_menu_item_with_gaim_icon(submenu, _("Invisible"), + new_menu_item_with_status_icon(submenu, _("Invisible"), GAIM_STATUS_INVISIBLE, G_CALLBACK(activate_status_primitive_cb), GINT_TO_POINTER(GAIM_STATUS_INVISIBLE), 0, 0, NULL); - new_menu_item_with_gaim_icon(submenu, _("Offline"), + new_menu_item_with_status_icon(submenu, _("Offline"), GAIM_STATUS_OFFLINE, G_CALLBACK(activate_status_primitive_cb), GINT_TO_POINTER(GAIM_STATUS_OFFLINE), 0, 0, NULL); @@ -466,7 +466,7 @@ { GaimSavedStatus *saved_status = cur->data; time_t creation_time = gaim_savedstatus_get_creation_time(saved_status); - new_menu_item_with_gaim_icon(submenu, + new_menu_item_with_status_icon(submenu, gaim_savedstatus_get_title(saved_status), gaim_savedstatus_get_type(saved_status), G_CALLBACK(activate_saved_status_cb), GINT_TO_POINTER(creation_time), 0, 0, NULL); @@ -475,8 +475,8 @@ pidgin_separator(submenu); - new_menu_item_with_gaim_icon(submenu, _("New..."), GAIM_STATUS_AVAILABLE, G_CALLBACK(show_custom_status_editor_cb), NULL, 0, 0, NULL); - new_menu_item_with_gaim_icon(submenu, _("Saved..."), GAIM_STATUS_AVAILABLE, G_CALLBACK(pidgin_status_window_show), NULL, 0, 0, NULL); + new_menu_item_with_status_icon(submenu, _("New..."), GAIM_STATUS_AVAILABLE, G_CALLBACK(show_custom_status_editor_cb), NULL, 0, 0, NULL); + new_menu_item_with_status_icon(submenu, _("Saved..."), GAIM_STATUS_AVAILABLE, G_CALLBACK(pidgin_status_window_show), NULL, 0, 0, NULL); return menuitem; }
--- a/pidgin/gtkft.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkft.c Mon Mar 19 06:35:51 2007 +0000 @@ -35,7 +35,7 @@ #include "gtkft.h" #include "prefs.h" #include "gtkexpander.h" -#include "gaimstock.h" +#include "pidginstock.h" #include "gtkutils.h" #define PIDGINXFER(xfer) \ @@ -703,8 +703,8 @@ /* Setup the initial table */ dialog->table = table = gtk_table_new(9, 2, FALSE); - gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); - gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); + gtk_table_set_row_spacings(GTK_TABLE(table), PIDGIN_HIG_BOX_SPACE); + gtk_table_set_col_spacings(GTK_TABLE(table), PIDGIN_HIG_BOX_SPACE); /* Setup the labels */ for (i = 0; i < sizeof(labels) / sizeof(*labels); i++) { @@ -761,18 +761,18 @@ dialog->window = window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_role(GTK_WINDOW(window), "file transfer"); gtk_window_set_title(GTK_WINDOW(window), _("File Transfers")); - gtk_container_set_border_width(GTK_CONTAINER(window), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(window), PIDGIN_HIG_BORDER); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_win_cb), dialog); /* Create the parent vbox for everything. */ - vbox1 = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox1 = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(window), vbox1); gtk_widget_show(vbox1); /* Create the main vbox for top half of the window. */ - vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox2 = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox1), vbox2, TRUE, TRUE, 0); gtk_widget_show(vbox2); @@ -816,7 +816,7 @@ /* Now the button box for the buttons */ bbox = gtk_hbutton_box_new(); - gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE); + gtk_box_set_spacing(GTK_BOX(bbox), PIDGIN_HIG_BOX_SPACE); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); gtk_box_pack_end(GTK_BOX(vbox1), bbox, FALSE, TRUE, 0); gtk_widget_show(bbox);
--- a/pidgin/gtkimhtmltoolbar.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkimhtmltoolbar.c Mon Mar 19 06:35:51 2007 +0000 @@ -29,7 +29,7 @@ #include "imgstore.h" #include "notify.h" #include "request.h" -#include "gaimstock.h" +#include "pidginstock.h" #include "util.h" #include "gtkdialogs.h"
--- a/pidgin/gtklog.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtklog.c Mon Mar 19 06:35:51 2007 +0000 @@ -32,7 +32,7 @@ #include "request.h" #include "util.h" -#include "gaimstock.h" +#include "pidginstock.h" #include "gtkblist.h" #include "gtkimhtml.h" #include "gtklog.h" @@ -541,7 +541,7 @@ /* Steal the "HELP" response and use it to trigger browsing to the logs folder */ gtk_dialog_add_button(GTK_DIALOG(lv->window), _("_Browse logs folder"), GTK_RESPONSE_HELP); #endif - gtk_container_set_border_width (GTK_CONTAINER(lv->window), GAIM_HIG_BOX_SPACE); + gtk_container_set_border_width (GTK_CONTAINER(lv->window), PIDGIN_HIG_BOX_SPACE); gtk_dialog_set_has_separator(GTK_DIALOG(lv->window), FALSE); gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(lv->window)->vbox), 0); g_signal_connect(G_OBJECT(lv->window), "response", @@ -550,8 +550,8 @@ /* Icon *************/ if (icon != NULL) { - title_box = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); - gtk_container_set_border_width(GTK_CONTAINER(title_box), GAIM_HIG_BOX_SPACE); + title_box = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); + gtk_container_set_border_width(GTK_CONTAINER(title_box), PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(lv->window)->vbox), title_box, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(title_box), icon, FALSE, FALSE, 0); @@ -570,7 +570,7 @@ /* Pane *************/ pane = gtk_hpaned_new(); - gtk_container_set_border_width(GTK_CONTAINER(pane), GAIM_HIG_BOX_SPACE); + gtk_container_set_border_width(GTK_CONTAINER(pane), PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(lv->window)->vbox), pane, TRUE, TRUE, 0); /* List *************/ @@ -614,7 +614,7 @@ } /* A fancy little box ************/ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_paned_add2(GTK_PANED(pane), vbox); /* Viewer ************/ @@ -625,7 +625,7 @@ gtk_widget_show(frame); /* Search box **********/ - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); lv->entry = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox), lv->entry, TRUE, TRUE, 0);
--- a/pidgin/gtkmain.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkmain.c Mon Mar 19 06:35:51 2007 +0000 @@ -63,7 +63,7 @@ #include "gtksound.h" #include "gtkthemes.h" #include "gtkutils.h" -#include "gaimstock.h" +#include "pidginstock.h" #include "gtkwhiteboard.h" #ifdef HAVE_SIGNAL_H
--- a/pidgin/gtknotify.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtknotify.c Mon Mar 19 06:35:51 2007 +0000 @@ -30,7 +30,7 @@ #include "connection.h" #include "debug.h" #include "prefs.h" -#include "gaimstock.h" +#include "pidginstock.h" #include "util.h" #include "gtkblist.h" @@ -45,7 +45,7 @@ GtkWidget *label; GtkTreeIter iter; int count; -} GaimNotifyMailData; +} PidginNotifyMailData; typedef struct { @@ -56,14 +56,14 @@ gpointer user_data; GaimNotifySearchResults *results; -} GaimNotifySearchResultsData; +} PidginNotifySearchResultsData; typedef struct { GaimNotifySearchButton *button; - GaimNotifySearchResultsData *data; + PidginNotifySearchResultsData *data; -} GaimNotifySearchResultsButtonData; +} PidginNotifySearchResultsButtonData; enum { @@ -102,7 +102,7 @@ static void email_response_cb(GtkDialog *dlg, gint id, PidginMailDialog *dialog) { - GaimNotifyMailData *data = NULL; + PidginNotifyMailData *data = NULL; GtkTreeIter iter; if (id == GTK_RESPONSE_YES) @@ -162,15 +162,15 @@ } static void -searchresults_close_cb(GaimNotifySearchResultsData *data, GdkEvent *event, gpointer user_data) +searchresults_close_cb(PidginNotifySearchResultsData *data, GdkEvent *event, gpointer user_data) { gaim_notify_close(GAIM_NOTIFY_SEARCHRESULTS, data); } static void -searchresults_callback_wrapper_cb(GtkWidget *widget, GaimNotifySearchResultsButtonData *bd) +searchresults_callback_wrapper_cb(GtkWidget *widget, PidginNotifySearchResultsButtonData *bd) { - GaimNotifySearchResultsData *data = bd->data; + PidginNotifySearchResultsData *data = bd->data; GtkTreeSelection *selection; GtkTreeModel *model; @@ -235,7 +235,7 @@ gtk_misc_set_alignment(GTK_MISC(img), 0, 0); } - dialog = gtk_dialog_new_with_buttons(title ? title : GAIM_ALERT_TITLE, + dialog = gtk_dialog_new_with_buttons(title ? title : PIDGIN_ALERT_TITLE, NULL, 0, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); @@ -244,13 +244,13 @@ g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(message_response_cb), dialog); - gtk_container_set_border_width(GTK_CONTAINER(dialog), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(dialog), PIDGIN_HIG_BORDER); gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); - gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BORDER); - gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BOX_SPACE); + gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BOX_SPACE); - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); if (img != NULL) @@ -281,7 +281,7 @@ { GtkTreeIter iter; GtkTreeModel *model; - GaimNotifyMailData *data; + PidginNotifyMailData *data; gboolean active = TRUE; if (gtk_tree_selection_get_selected(sel, &model, &iter) == FALSE) @@ -340,10 +340,10 @@ PIDGIN_STOCK_OPEN_MAIL, GTK_RESPONSE_YES); /* Setup the dialog */ - gtk_container_set_border_width(GTK_CONTAINER(dialog), GAIM_HIG_BOX_SPACE); - gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BOX_SPACE); + gtk_container_set_border_width(GTK_CONTAINER(dialog), PIDGIN_HIG_BOX_SPACE); + gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BOX_SPACE); gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); - gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BORDER); + gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER); /* Vertical box */ vbox = GTK_DIALOG(dialog)->vbox; @@ -402,7 +402,7 @@ static void * pidgin_notify_add_mail(GtkTreeStore *treemodel, GaimAccount *account, char *notification, const char *url, int count) { - GaimNotifyMailData *data = NULL; + PidginNotifyMailData *data = NULL; GtkTreeIter iter; GdkPixbuf *icon; gboolean new_n = TRUE; @@ -427,7 +427,7 @@ } if (new_n) { - data = g_new0(GaimNotifyMailData, 1); + data = g_new0(PidginNotifyMailData, 1); gtk_tree_store_append(treemodel, &iter, NULL); } @@ -457,7 +457,7 @@ GtkWidget *dialog = NULL; char *notification; GaimAccount *account; - GaimNotifyMailData *data = NULL; + PidginNotifyMailData *data = NULL; account = gaim_connection_get_account(gc); dialog = pidgin_get_mail_dialog(); /* This creates mail_dialog if necessary */ @@ -566,13 +566,13 @@ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), title); gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG); - gtk_container_set_border_width(GTK_CONTAINER(window), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(window), PIDGIN_HIG_BORDER); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(formatted_close_cb), NULL); /* Setup the main vbox */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(window), vbox); gtk_widget_show(vbox); @@ -638,7 +638,7 @@ pidgin_notify_searchresults_new_rows(GaimConnection *gc, GaimNotifySearchResults *results, void *data_) { - GaimNotifySearchResultsData *data = data_; + PidginNotifySearchResultsData *data = data_; GtkListStore *model = data->model; GtkTreeIter iter; GdkPixbuf *pixbuf; @@ -693,14 +693,14 @@ GtkWidget *button_area; GtkWidget *label; GtkWidget *sw; - GaimNotifySearchResultsData *data; + PidginNotifySearchResultsData *data; char *label_text; char *primary_esc, *secondary_esc; g_return_val_if_fail(gc != NULL, NULL); g_return_val_if_fail(results != NULL, NULL); - data = g_malloc(sizeof(GaimNotifySearchResultsData)); + data = g_malloc(sizeof(PidginNotifySearchResultsData)); data->user_data = user_data; data->results = results; @@ -708,13 +708,13 @@ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), (title ? title :_("Search Results"))); gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG); - gtk_container_set_border_width(GTK_CONTAINER(window), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(window), PIDGIN_HIG_BORDER); g_signal_connect_swapped(G_OBJECT(window), "delete_event", G_CALLBACK(searchresults_close_cb), data); /* Setup the main vbox */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(window), vbox); gtk_widget_show(vbox); @@ -784,7 +784,7 @@ button_area = gtk_hbutton_box_new(); gtk_box_pack_start(GTK_BOX(vbox), button_area, FALSE, FALSE, 0); gtk_button_box_set_layout(GTK_BUTTON_BOX(button_area), GTK_BUTTONBOX_END); - gtk_box_set_spacing(GTK_BOX(button_area), GAIM_HIG_BORDER); + gtk_box_set_spacing(GTK_BOX(button_area), PIDGIN_HIG_BORDER); gtk_widget_show(button_area); for (i = 0; i < g_list_length(results->buttons); i++) { @@ -820,12 +820,12 @@ gaim_debug_warning("gtknotify", "Incorrect button type: %d\n", b->type); } if (button != NULL) { - GaimNotifySearchResultsButtonData *bd; + PidginNotifySearchResultsButtonData *bd; gtk_box_pack_start(GTK_BOX(button_area), button, FALSE, FALSE, 0); gtk_widget_show(button); - bd = g_new0(GaimNotifySearchResultsButtonData, 1); + bd = g_new0(PidginNotifySearchResultsButtonData, 1); bd->button = b; bd->data = data; @@ -876,14 +876,14 @@ { if (type == GAIM_NOTIFY_EMAIL || type == GAIM_NOTIFY_EMAILS) { - GaimNotifyMailData *data = (GaimNotifyMailData *)ui_handle; + PidginNotifyMailData *data = (PidginNotifyMailData *)ui_handle; g_free(data->url); g_free(data); } else if (type == GAIM_NOTIFY_SEARCHRESULTS) { - GaimNotifySearchResultsData *data = (GaimNotifySearchResultsData *)ui_handle; + PidginNotifySearchResultsData *data = (PidginNotifySearchResultsData *)ui_handle; gtk_widget_destroy(data->window); gaim_notify_searchresults_free(data->results);
--- a/pidgin/gtkplugin.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkplugin.c Mon Mar 19 06:35:51 2007 +0000 @@ -470,7 +470,7 @@ if (box == NULL) break; - dialog = gtk_dialog_new_with_buttons(GAIM_ALERT_TITLE, GTK_WINDOW(d), + dialog = gtk_dialog_new_with_buttons(PIDGIN_ALERT_TITLE, GTK_WINDOW(d), GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
--- a/pidgin/gtkpluginpref.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkpluginpref.c Mon Mar 19 06:35:51 2007 +0000 @@ -92,9 +92,9 @@ case GAIM_PLUGIN_PREF_NONE: default: if (format == GAIM_STRING_FORMAT_TYPE_NONE) - box = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + box = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); else - box = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + box = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_widget_show(box); gtk_box_pack_start(GTK_BOX(parent), box, FALSE, FALSE, 0); @@ -117,7 +117,7 @@ { gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); if (gtk_entry_get_invisible_char(GTK_ENTRY(entry)) == '*') - gtk_entry_set_invisible_char(GTK_ENTRY(entry), GAIM_INVISIBLE_CHAR); + gtk_entry_set_invisible_char(GTK_ENTRY(entry), PIDGIN_INVISIBLE_CHAR); } g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(entry_cb), @@ -134,7 +134,7 @@ GtkWidget *toolbar; GtkWidget *frame; - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); @@ -213,7 +213,7 @@ sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); parent = ret = gtk_vbox_new(FALSE, 16); - gtk_container_set_border_width(GTK_CONTAINER(ret), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(ret), PIDGIN_HIG_BORDER); gtk_widget_show(ret); for(pp = gaim_plugin_pref_frame_get_prefs(frame);
--- a/pidgin/gtkpounce.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkpounce.c Mon Mar 19 06:35:51 2007 +0000 @@ -39,7 +39,7 @@ #include "gtkblist.h" #include "gtkdialogs.h" #include "gtkpounce.h" -#include "gaimstock.h" +#include "pidginstock.h" #include "gtkutils.h" /** @@ -504,25 +504,25 @@ (cur_pounce == NULL ? _("New Buddy Pounce") : _("Edit Buddy Pounce"))); - gtk_container_set_border_width(GTK_CONTAINER(window), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(window), PIDGIN_HIG_BORDER); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_win_cb), dialog); /* Create the parent vbox for everything. */ - vbox1 = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox1 = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(window), vbox1); gtk_widget_show(vbox1); /* Create the vbox that will contain all the prefs stuff. */ - vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox2 = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox1), vbox2, TRUE, TRUE, 0); /* Create the "Pounce on Whom" frame. */ frame = pidgin_make_frame(vbox2, _("Pounce on Whom")); /* Account: */ - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); @@ -542,7 +542,7 @@ pidgin_set_accessible_label (dialog->account_menu, label); /* Buddy: */ - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); @@ -576,7 +576,7 @@ table = gtk_table_new(5, 2, FALSE); gtk_container_add(GTK_CONTAINER(frame), table); - gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BORDER); + gtk_table_set_col_spacings(GTK_TABLE(table), PIDGIN_HIG_BORDER); gtk_widget_show(table); dialog->signon = @@ -637,7 +637,7 @@ table = gtk_table_new(3, 5, FALSE); gtk_container_add(GTK_CONTAINER(frame), table); - gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BORDER); + gtk_table_set_col_spacings(GTK_TABLE(table), PIDGIN_HIG_BORDER); gtk_widget_show(table); dialog->open_win @@ -706,7 +706,7 @@ gtk_table_attach(GTK_TABLE(table), dialog->play_sound_test, 3, 4, 4, 5, GTK_FILL | GTK_EXPAND, 0, 0, 0); - gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE / 2); + gtk_table_set_row_spacings(GTK_TABLE(table), PIDGIN_HIG_BOX_SPACE / 2); gtk_widget_show(dialog->open_win); gtk_widget_show(dialog->popup); @@ -777,7 +777,7 @@ table = gtk_table_new(2, 1, FALSE); gtk_container_add(GTK_CONTAINER(frame), table); - gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BORDER); + gtk_table_set_col_spacings(GTK_TABLE(table), PIDGIN_HIG_BORDER); gtk_widget_show(table); dialog->on_away = @@ -795,7 +795,7 @@ /* Now the button box! */ bbox = gtk_hbutton_box_new(); - gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE); + gtk_box_set_spacing(GTK_BOX(bbox), PIDGIN_HIG_BOX_SPACE); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); gtk_box_pack_end(GTK_BOX(vbox1), bbox, FALSE, FALSE, 0); gtk_widget_show(bbox); @@ -1323,7 +1323,7 @@ gtk_window_set_default_size(GTK_WINDOW(win), width, height); gtk_window_set_role(GTK_WINDOW(win), "pounces"); gtk_window_set_title(GTK_WINDOW(win), _("Buddy Pounces")); - gtk_container_set_border_width(GTK_CONTAINER(win), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(win), PIDGIN_HIG_BORDER); g_signal_connect(G_OBJECT(win), "delete_event", G_CALLBACK(pounces_manager_destroy_cb), dialog); @@ -1331,7 +1331,7 @@ G_CALLBACK(pounces_manager_configure_cb), dialog); /* Setup the vbox */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(win), vbox); gtk_widget_show(vbox); @@ -1341,7 +1341,7 @@ /* Button box. */ bbox = gtk_hbutton_box_new(); - gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE); + gtk_box_set_spacing(GTK_BOX(bbox), PIDGIN_HIG_BOX_SPACE); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0); gtk_widget_show(bbox);
--- a/pidgin/gtkprefs.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkprefs.c Mon Mar 19 06:35:51 2007 +0000 @@ -48,7 +48,7 @@ #include "gtksound.h" #include "gtkthemes.h" #include "gtkutils.h" -#include "gaimstock.h" +#include "pidginstock.h" #define PROXYHOST 0 #define PROXYPORT 1 @@ -632,8 +632,8 @@ GtkWidget *label; GtkTargetEntry te[3] = {{"text/plain", 0, 0},{"text/uri-list", 0, 1},{"STRING", 0, 2}}; - ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); - gtk_container_set_border_width (GTK_CONTAINER (ret), GAIM_HIG_BORDER); + ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); + gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER); label = gtk_label_new(_("Select a smiley theme that you would like to use from the list below. New themes can be installed by dragging and dropping them onto the theme list.")); @@ -808,8 +808,8 @@ GtkSizeGroup *sg; GList *names = NULL; - ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); - gtk_container_set_border_width(GTK_CONTAINER(ret), GAIM_HIG_BORDER); + ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); + gtk_container_set_border_width(GTK_CONTAINER(ret), PIDGIN_HIG_BORDER); sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); @@ -892,8 +892,8 @@ GtkWidget *imhtml; GtkWidget *frame; - ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); - gtk_container_set_border_width(GTK_CONTAINER(ret), GAIM_HIG_BORDER); + ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); + gtk_container_set_border_width(GTK_CONTAINER(ret), PIDGIN_HIG_BORDER); vbox = pidgin_make_frame(ret, _("Conversations")); @@ -1009,15 +1009,15 @@ GtkSizeGroup *sg; GaimProxyInfo *proxy_info = NULL; - ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); - gtk_container_set_border_width (GTK_CONTAINER (ret), GAIM_HIG_BORDER); + ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); + gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER); vbox = pidgin_make_frame (ret, _("IP Address")); sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); pidgin_prefs_labeled_entry(vbox,_("ST_UN server:"), "/core/network/stun_server", sg); - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_container_add(GTK_CONTAINER(vbox), hbox); label = gtk_label_new(NULL); @@ -1176,7 +1176,7 @@ gtk_table_attach(GTK_TABLE(table), entry, 3, 4, 1, 2, GTK_FILL , 0, 0, 0); gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); if (gtk_entry_get_invisible_char(GTK_ENTRY(entry)) == '*') - gtk_entry_set_invisible_char(GTK_ENTRY(entry), GAIM_INVISIBLE_CHAR); + gtk_entry_set_invisible_char(GTK_ENTRY(entry), PIDGIN_INVISIBLE_CHAR); g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(proxy_print_option), (void *)PROXYPASS); @@ -1280,8 +1280,8 @@ GtkSizeGroup *sg; GList *browsers = NULL; - ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); - gtk_container_set_border_width (GTK_CONTAINER (ret), GAIM_HIG_BORDER); + ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); + gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER); sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); vbox = pidgin_make_frame (ret, _("Browser Selection")); @@ -1348,8 +1348,8 @@ GtkWidget *vbox; GList *names; - ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); - gtk_container_set_border_width (GTK_CONTAINER (ret), GAIM_HIG_BORDER); + ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); + gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER); vbox = pidgin_make_frame (ret, _("Logging")); @@ -1587,8 +1587,8 @@ const char *cmd; #endif - ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); - gtk_container_set_border_width (GTK_CONTAINER (ret), GAIM_HIG_BORDER); + ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); + gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER); sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); @@ -1607,7 +1607,7 @@ gtk_size_group_add_widget(sg, dd); gtk_misc_set_alignment(GTK_MISC(dd), 0, 0.5); - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new_with_mnemonic(_("Sound c_ommand:\n(%s for filename)")); @@ -1647,7 +1647,7 @@ NULL); #ifdef USE_GSTREAMER - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new_with_mnemonic(_("Volume:")); @@ -1744,7 +1744,7 @@ g_object_unref(G_OBJECT(event_store)); gtk_container_add(GTK_CONTAINER(sw), event_view); - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); sound_entry = gtk_entry_new(); pref = g_strdup_printf("/gaim/gtk/sound/file/%s", @@ -1753,7 +1753,7 @@ g_free(pref); gtk_entry_set_text(GTK_ENTRY(sound_entry), (file && *file != '\0') ? file : "(default)"); gtk_editable_set_editable(GTK_EDITABLE(sound_entry), FALSE); - gtk_box_pack_start(GTK_BOX(hbox), sound_entry, FALSE, FALSE, GAIM_HIG_BOX_SPACE); + gtk_box_pack_start(GTK_BOX(hbox), sound_entry, FALSE, FALSE, PIDGIN_HIG_BOX_SPACE); button = gtk_button_new_with_label(_("Test")); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(test_sound), NULL); @@ -1798,8 +1798,8 @@ GtkWidget *menu; GtkSizeGroup *sg; - ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); - gtk_container_set_border_width (GTK_CONTAINER (ret), GAIM_HIG_BORDER); + ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); + gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER); sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); @@ -1950,11 +1950,11 @@ gtk_window_set_role(GTK_WINDOW(prefs), "preferences"); gtk_window_set_title(GTK_WINDOW(prefs), _("Preferences")); gtk_window_set_resizable (GTK_WINDOW(prefs), FALSE); - gtk_container_set_border_width(GTK_CONTAINER(prefs), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(prefs), PIDGIN_HIG_BORDER); g_signal_connect(G_OBJECT(prefs), "destroy", G_CALLBACK(delete_prefs), NULL); - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(prefs), vbox); gtk_widget_show(vbox); @@ -1965,7 +1965,7 @@ /* The buttons to press! */ bbox = gtk_hbutton_box_new(); - gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE); + gtk_box_set_spacing(GTK_BOX(bbox), PIDGIN_HIG_BOX_SPACE); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); gtk_widget_show (bbox);
--- a/pidgin/gtkprivacy.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkprivacy.c Mon Mar 19 06:35:51 2007 +0000 @@ -370,13 +370,13 @@ gtk_window_set_resizable(GTK_WINDOW(dialog->win), FALSE); gtk_window_set_role(GTK_WINDOW(dialog->win), "privacy"); gtk_window_set_title(GTK_WINDOW(dialog->win), _("Privacy")); - gtk_container_set_border_width(GTK_CONTAINER(dialog->win), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(dialog->win), PIDGIN_HIG_BORDER); g_signal_connect(G_OBJECT(dialog->win), "delete_event", G_CALLBACK(destroy_cb), dialog); /* Main vbox */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(dialog->win), vbox); gtk_widget_show(vbox); @@ -389,7 +389,7 @@ gtk_widget_show(label); /* Hbox for the accounts drop-down and label. */ - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox);
--- a/pidgin/gtkrequest.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkrequest.c Mon Mar 19 06:35:51 2007 +0000 @@ -32,7 +32,7 @@ #include "gtkimhtmltoolbar.h" #include "gtkrequest.h" #include "gtkutils.h" -#include "gaimstock.h" +#include "pidginstock.h" #include <gdk/gdkkeysyms.h> @@ -309,7 +309,7 @@ data->cbs[1] = cancel_cb; /* Create the dialog. */ - dialog = gtk_dialog_new_with_buttons(title ? title : GAIM_ALERT_TITLE, + dialog = gtk_dialog_new_with_buttons(title ? title : PIDGIN_ALERT_TITLE, NULL, 0, text_to_stock(cancel_text), 1, text_to_stock(ok_text), 0, @@ -320,15 +320,15 @@ G_CALLBACK(input_response_cb), data); /* Setup the dialog */ - gtk_container_set_border_width(GTK_CONTAINER(dialog), GAIM_HIG_BORDER/2); - gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BORDER/2); + gtk_container_set_border_width(GTK_CONTAINER(dialog), PIDGIN_HIG_BORDER/2); + gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER/2); gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); gtk_dialog_set_default_response(GTK_DIALOG(dialog), 0); - gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BORDER); + gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER); /* Setup the main horizontal box */ - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); /* Dialog icon. */ @@ -338,7 +338,7 @@ gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); /* Vertical box */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); @@ -424,7 +424,7 @@ { gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); if (gtk_entry_get_invisible_char(GTK_ENTRY(entry)) == '*') - gtk_entry_set_invisible_char(GTK_ENTRY(entry), GAIM_INVISIBLE_CHAR); + gtk_entry_set_invisible_char(GTK_ENTRY(entry), PIDGIN_INVISIBLE_CHAR); } } } @@ -482,14 +482,14 @@ G_CALLBACK(choice_response_cb), data); /* Setup the dialog */ - gtk_container_set_border_width(GTK_CONTAINER(dialog), GAIM_HIG_BORDER/2); - gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BORDER/2); + gtk_container_set_border_width(GTK_CONTAINER(dialog), PIDGIN_HIG_BORDER/2); + gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER/2); gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); - gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BORDER); + gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER); /* Setup the main horizontal box */ - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); /* Dialog icon. */ @@ -499,7 +499,7 @@ gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); /* Vertical box */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); /* Descriptive label */ @@ -522,7 +522,7 @@ g_free(label_text); - vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox2 = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, FALSE, 0); while ((radio_text = va_arg(args, char*))) { int resp = va_arg(args, int); @@ -591,14 +591,14 @@ G_CALLBACK(action_response_cb), data); /* Setup the dialog */ - gtk_container_set_border_width(GTK_CONTAINER(dialog), GAIM_HIG_BORDER/2); - gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BORDER/2); + gtk_container_set_border_width(GTK_CONTAINER(dialog), PIDGIN_HIG_BORDER/2); + gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER/2); gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); - gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BORDER); + gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER); /* Setup the main horizontal box */ - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); /* Dialog icon. */ @@ -608,7 +608,7 @@ gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); /* Vertical box */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); /* Descriptive label */ @@ -762,7 +762,7 @@ { gtk_entry_set_visibility(GTK_ENTRY(widget), FALSE); if (gtk_entry_get_invisible_char(GTK_ENTRY(widget)) == '*') - gtk_entry_set_invisible_char(GTK_ENTRY(widget), GAIM_INVISIBLE_CHAR); + gtk_entry_set_invisible_char(GTK_ENTRY(widget), PIDGIN_INVISIBLE_CHAR); } gtk_editable_set_editable(GTK_EDITABLE(widget), @@ -863,7 +863,7 @@ gint i; if (g_list_length(labels) == 2) - box = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + box = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); else box = gtk_vbox_new(FALSE, 0); @@ -1066,13 +1066,13 @@ gtk_window_set_title(GTK_WINDOW(win), title); gtk_window_set_role(GTK_WINDOW(win), "multifield"); - gtk_container_set_border_width(GTK_CONTAINER(win), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(win), PIDGIN_HIG_BORDER); g_signal_connect(G_OBJECT(win), "delete_event", G_CALLBACK(destroy_multifield_cb), data); /* Setup the main horizontal box */ - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(win), hbox); gtk_widget_show(hbox); @@ -1084,7 +1084,7 @@ gtk_widget_show(img); /* Setup the vbox */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); gtk_widget_show(vbox); @@ -1119,7 +1119,7 @@ gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); gtk_widget_show(sw); - vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox2 = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), vbox2); gtk_widget_show(vbox2); } else { @@ -1205,8 +1205,8 @@ } table = gtk_table_new(rows, 2 * cols, FALSE); - gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); - gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); + gtk_table_set_row_spacings(GTK_TABLE(table), PIDGIN_HIG_BOX_SPACE); + gtk_table_set_col_spacings(GTK_TABLE(table), PIDGIN_HIG_BOX_SPACE); gtk_container_add(GTK_CONTAINER(frame), table); gtk_widget_show(table); @@ -1345,7 +1345,7 @@ /* Button box. */ bbox = gtk_hbutton_box_new(); - gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE); + gtk_box_set_spacing(GTK_BOX(bbox), PIDGIN_HIG_BOX_SPACE); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0); gtk_widget_show(bbox);
--- a/pidgin/gtkroomlist.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkroomlist.c Mon Mar 19 06:35:51 2007 +0000 @@ -26,7 +26,7 @@ #include "internal.h" #include "pidgin.h" #include "gtkutils.h" -#include "gaimstock.h" +#include "pidginstock.h" #include "debug.h" #include "account.h" #include "connection.h" @@ -375,22 +375,22 @@ gtk_window_set_role(GTK_WINDOW(window), "room list"); gtk_window_set_title(GTK_WINDOW(window), _("Room List")); - gtk_container_set_border_width(GTK_CONTAINER(window), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(window), PIDGIN_HIG_BORDER); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_win_cb), dialog); /* Create the parent vbox for everything. */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(window), vbox); gtk_widget_show(vbox); - vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox2 = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(vbox), vbox2); gtk_widget_show(vbox2); /* accounts dropdown list */ - account_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + account_hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox2), account_hbox, FALSE, FALSE, 0); gtk_widget_show(account_hbox); @@ -429,7 +429,7 @@ /* button box */ bbox = gtk_hbutton_box_new(); - gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE); + gtk_box_set_spacing(GTK_BOX(bbox), PIDGIN_HIG_BOX_SPACE); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, TRUE, 0); gtk_widget_show(bbox);
--- a/pidgin/gtksavedstatuses.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtksavedstatuses.c Mon Mar 19 06:35:51 2007 +0000 @@ -37,7 +37,7 @@ #include "gtkimhtml.h" #include "gtkimhtmltoolbar.h" #include "gtksavedstatuses.h" -#include "gaimstock.h" +#include "pidginstock.h" #include "gtkutils.h" /* @@ -554,7 +554,7 @@ gtk_window_set_default_size(GTK_WINDOW(win), width, height); gtk_window_set_role(GTK_WINDOW(win), "statuses"); gtk_window_set_title(GTK_WINDOW(win), _("Saved Statuses")); - gtk_container_set_border_width(GTK_CONTAINER(win), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(win), PIDGIN_HIG_BORDER); g_signal_connect(G_OBJECT(win), "delete_event", G_CALLBACK(status_window_destroy_cb), dialog); @@ -562,7 +562,7 @@ G_CALLBACK(configure_cb), dialog); /* Setup the vbox */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(win), vbox); /* List of saved status states */ @@ -571,7 +571,7 @@ /* Button box. */ bbox = gtk_hbutton_box_new(); - gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE); + gtk_box_set_spacing(GTK_BOX(bbox), PIDGIN_HIG_BOX_SPACE); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0); @@ -1088,19 +1088,19 @@ gtk_window_set_role(GTK_WINDOW(win), "status"); gtk_window_set_title(GTK_WINDOW(win), _("Status")); gtk_window_set_resizable(GTK_WINDOW(win), FALSE); - gtk_container_set_border_width(GTK_CONTAINER(win), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(win), PIDGIN_HIG_BORDER); g_signal_connect(G_OBJECT(win), "delete_event", G_CALLBACK(status_editor_destroy_cb), dialog); /* Setup the vbox */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(win), vbox); sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); /* Title */ - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new_with_mnemonic(_("_Title:")); @@ -1119,7 +1119,7 @@ G_CALLBACK(editor_title_changed_cb), dialog); /* Status type */ - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new_with_mnemonic(_("_Status:")); @@ -1135,7 +1135,7 @@ gtk_box_pack_start(GTK_BOX(hbox), dropdown, TRUE, TRUE, 0); /* Status message */ - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new_with_mnemonic(_("_Message:")); @@ -1158,7 +1158,7 @@ gtk_box_pack_start(GTK_BOX(vbox), expander, FALSE, FALSE, 0); /* Setup the box that the expander will cover */ - dbox = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); + dbox = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); gtk_container_add(GTK_CONTAINER(expander), dbox); /* Different status message treeview */ @@ -1198,7 +1198,7 @@ /* Button box */ bbox = gtk_hbutton_box_new(); - gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE); + gtk_box_set_spacing(GTK_BOX(bbox), PIDGIN_HIG_BOX_SPACE); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0); @@ -1428,19 +1428,19 @@ gtk_window_set_title(GTK_WINDOW(win), tmp); g_free(tmp); gtk_window_set_resizable(GTK_WINDOW(win), FALSE); - gtk_container_set_border_width(GTK_CONTAINER(win), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(win), PIDGIN_HIG_BORDER); g_signal_connect(G_OBJECT(win), "delete_event", G_CALLBACK(substatus_editor_destroy_cb), dialog); /* Setup the vbox */ - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); gtk_container_add(GTK_CONTAINER(win), vbox); sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); /* Status type */ - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new_with_mnemonic(_("_Status:")); @@ -1471,7 +1471,7 @@ gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0); /* Status mesage */ - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new_with_mnemonic(_("_Message:")); @@ -1486,7 +1486,7 @@ /* Button box */ bbox = gtk_hbutton_box_new(); - gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE); + gtk_box_set_spacing(GTK_BOX(bbox), PIDGIN_HIG_BOX_SPACE); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
--- a/pidgin/gtkstatusbox.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkstatusbox.c Mon Mar 19 06:35:51 2007 +0000 @@ -50,7 +50,7 @@ #include "pidgin.h" #include "gtksavedstatuses.h" -#include "gaimstock.h" +#include "pidginstock.h" #include "gtkstatusbox.h" #include "gtkutils.h" @@ -2315,7 +2315,7 @@ height = (oneline.height + pad_top + pad_bottom) * lines; height += (oneline.height + pad_inside) * (wrapped_lines - lines); - gtk_widget_set_size_request(status_box->vbox, -1, height + GAIM_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)
--- a/pidgin/gtkutils.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkutils.c Mon Mar 19 06:35:51 2007 +0000 @@ -57,7 +57,7 @@ #include "gtkdialogs.h" #include "gtkimhtml.h" #include "gtkimhtmltoolbar.h" -#include "gaimstock.h" +#include "pidginstock.h" #include "gtkthemes.h" #include "gtkutils.h" @@ -400,7 +400,7 @@ GtkWidget *vbox, *label, *hbox; char *labeltitle; - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(parent), vbox, FALSE, FALSE, 0); gtk_widget_show(vbox); @@ -415,7 +415,7 @@ gtk_widget_show(label); pidgin_set_accessible_label (vbox, label); - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); @@ -423,7 +423,7 @@ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show(label); - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); gtk_widget_show(vbox); @@ -2359,7 +2359,7 @@ current_folder); gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview), -1, 50); - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start( GTK_BOX(GTK_FILE_SELECTION(dialog->icon_filesel)->main_vbox), hbox, FALSE, FALSE, 0); @@ -2909,7 +2909,7 @@ gtk_misc_set_alignment(GTK_MISC(img), 0, 0); vbox = gtk_vbox_new(FALSE,0); - gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); + gtk_container_set_border_width(GTK_CONTAINER(vbox), PIDGIN_HIG_BOX_SPACE); g_object_set_data(G_OBJECT(vbox), "gc" ,gc); minidialogs = g_slist_prepend(minidialogs, vbox); @@ -2943,7 +2943,7 @@ gtk_misc_set_alignment(GTK_MISC(label), 0, 0); gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); - hbox2 = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox2 = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 0); va_start(args, user_data);
--- a/pidgin/gtkwhiteboard.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/gtkwhiteboard.c Mon Mar 19 06:35:51 2007 +0000 @@ -173,13 +173,13 @@ /* Create horizontal box for the palette and all its entries */ hbox_palette = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox_palette_above_canvas_and_controls), - hbox_palette, FALSE, FALSE, GAIM_HIG_BORDER); + hbox_palette, FALSE, FALSE, PIDGIN_HIG_BORDER); gtk_widget_show(hbox_palette); /* Create horizontal box to seperate the canvas from the controls */ hbox_canvas_and_controls = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox_palette_above_canvas_and_controls), - hbox_canvas_and_controls, FALSE, FALSE, GAIM_HIG_BORDER); + hbox_canvas_and_controls, FALSE, FALSE, PIDGIN_HIG_BORDER); gtk_widget_show(hbox_canvas_and_controls); for(i = 0; i < PALETTE_NUM_COLORS; i++) @@ -196,13 +196,13 @@ gtk_widget_show(hbox_canvas_and_controls); gtk_container_add(GTK_CONTAINER(window), hbox_canvas_and_controls); - gtk_container_set_border_width(GTK_CONTAINER(window), GAIM_HIG_BORDER); + gtk_container_set_border_width(GTK_CONTAINER(window), PIDGIN_HIG_BORDER); /* Create the drawing area */ drawing_area = gtk_drawing_area_new(); gtkwb->drawing_area = drawing_area; gtk_widget_set_size_request(GTK_WIDGET(drawing_area), gtkwb->width, gtkwb->height); - gtk_box_pack_start(GTK_BOX(hbox_canvas_and_controls), drawing_area, TRUE, TRUE, GAIM_HIG_BOX_SPACE); + gtk_box_pack_start(GTK_BOX(hbox_canvas_and_controls), drawing_area, TRUE, TRUE, PIDGIN_HIG_BOX_SPACE); gtk_widget_show(drawing_area); @@ -234,19 +234,19 @@ /* Create vertical box to contain the controls */ vbox_controls = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_canvas_and_controls), - vbox_controls, FALSE, FALSE, GAIM_HIG_BOX_SPACE); + vbox_controls, FALSE, FALSE, PIDGIN_HIG_BOX_SPACE); gtk_widget_show(vbox_controls); /* Add a clear button */ clear_button = gtk_button_new_from_stock(GTK_STOCK_CLEAR); - gtk_box_pack_start(GTK_BOX(vbox_controls), clear_button, FALSE, FALSE, GAIM_HIG_BOX_SPACE); + gtk_box_pack_start(GTK_BOX(vbox_controls), clear_button, FALSE, FALSE, PIDGIN_HIG_BOX_SPACE); gtk_widget_show(clear_button); g_signal_connect(G_OBJECT(clear_button), "clicked", G_CALLBACK(pidgin_whiteboard_button_clear_press), gtkwb); /* Add a save button */ save_button = gtk_button_new_from_stock(GTK_STOCK_SAVE); - gtk_box_pack_start(GTK_BOX(vbox_controls), save_button, FALSE, FALSE, GAIM_HIG_BOX_SPACE); + gtk_box_pack_start(GTK_BOX(vbox_controls), save_button, FALSE, FALSE, PIDGIN_HIG_BOX_SPACE); gtk_widget_show(save_button); g_signal_connect(G_OBJECT(save_button), "clicked", @@ -254,7 +254,7 @@ /* Add a color selector */ color_button = gtk_button_new_from_stock(GTK_STOCK_SELECT_COLOR); - gtk_box_pack_start(GTK_BOX(vbox_controls), color_button, FALSE, FALSE, GAIM_HIG_BOX_SPACE); + gtk_box_pack_start(GTK_BOX(vbox_controls), color_button, FALSE, FALSE, PIDGIN_HIG_BOX_SPACE); gtk_widget_show(color_button); g_signal_connect(G_OBJECT(color_button), "clicked", G_CALLBACK(color_select_dialog), gtkwb);
--- a/pidgin/pidgin.h Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/pidgin.h Mon Mar 19 06:35:51 2007 +0000 @@ -42,9 +42,9 @@ #define PIDGIN_UI "pidgin" #ifndef _WIN32 -# define GAIM_ALERT_TITLE "" +# define PIDGIN_ALERT_TITLE "" #else -# define GAIM_ALERT_TITLE PIDGIN_NAME +# define PIDGIN_ALERT_TITLE PIDGIN_NAME #endif /* @@ -78,15 +78,15 @@ * Spacings between components, as defined by the * GNOME Human Interface Guidelines. */ -#define GAIM_HIG_CAT_SPACE 18 -#define GAIM_HIG_BORDER 12 -#define GAIM_HIG_BOX_SPACE 6 +#define PIDGIN_HIG_CAT_SPACE 18 +#define PIDGIN_HIG_BORDER 12 +#define PIDGIN_HIG_BOX_SPACE 6 /* * See GNOME bug #307304 for some discussion about the invisible * character. 0x25cf is a good choice, too. */ -#define GAIM_INVISIBLE_CHAR (gunichar)0x2022 +#define PIDGIN_INVISIBLE_CHAR (gunichar)0x2022 #endif /* _PIDGIN_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pidgin/pidgincombobox.c Mon Mar 19 06:35:51 2007 +0000 @@ -0,0 +1,3749 @@ +/* gaimcombobox.c + * Copyright (C) 2002, 2003 Kristian Rietveld <kris@gtk.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* +#include <config.h> +*/ +#include <gtk/gtkversion.h> +#if !GTK_CHECK_VERSION(2,6,0) +#include "pidgincombobox.h" + +#if !GTK_CHECK_VERSION(2,4,0) +#include <gtk/gtkarrow.h> +#include <gtk/gtkbindings.h> +#include "gtkcelllayout.h" +#include <gtk/gtkcellrenderertext.h> +#include "gtkcellview.h" +#include "gtkcellviewmenuitem.h" +#include <gtk/gtkeventbox.h> +#include <gtk/gtkframe.h> +#include <gtk/gtkhbox.h> +#include <gtk/gtkliststore.h> +#include <gtk/gtkmain.h> +#include <gtk/gtkmenu.h> +#include <gtk/gtktogglebutton.h> +#include <gtk/gtktreeselection.h> +/* +#include <gtk/gtktreeprivate.h> +*/ +#include <gtk/gtkvseparator.h> +#include <gtk/gtkwindow.h> +#include <gtk/gtkversion.h> + +#include <gdk/gdkkeysyms.h> + +#include <gobject/gvaluecollector.h> + +#include <string.h> +#include <stdarg.h> + +#define P_(x) (x) + +/* WELCOME, to THE house of evil code */ + +typedef struct _ComboCellInfo ComboCellInfo; +struct _ComboCellInfo +{ + GtkCellRenderer *cell; + GSList *attributes; + + GtkCellLayoutDataFunc func; + gpointer func_data; + GDestroyNotify destroy; + + guint expand : 1; + guint pack : 1; +}; + +struct _GtkComboBoxPrivate +{ + GtkTreeModel *model; + + gint col_column; + gint row_column; + + gint wrap_width; + + gint active_item; + + GtkWidget *tree_view; + GtkTreeViewColumn *column; + + GtkWidget *cell_view; + GtkWidget *cell_view_frame; + + GtkWidget *button; + GtkWidget *box; + GtkWidget *arrow; + GtkWidget *separator; + + GtkWidget *popup_widget; + GtkWidget *popup_window; + GtkWidget *popup_frame; + + guint inserted_id; + guint deleted_id; + guint reordered_id; + guint changed_id; + + gint width; + GSList *cells; + + guint popup_in_progress : 1; + guint destroying : 1; +}; + +/* While debugging this evil code, I have learned that + * there are actually 4 modes to this widget, which can + * be characterized as follows + * + * 1) menu mode, no child added + * + * tree_view -> NULL + * cell_view -> GtkCellView, regular child + * cell_view_frame -> NULL + * button -> GtkToggleButton set_parent to combo + * box -> child of button + * arrow -> child of box + * separator -> child of box + * popup_widget -> GtkMenu + * popup_window -> NULL + * popup_frame -> NULL + * + * 2) menu mode, child added + * + * tree_view -> NULL + * cell_view -> NULL + * cell_view_frame -> NULL + * button -> GtkToggleButton set_parent to combo + * box -> NULL + * arrow -> GtkArrow, child of button + * separator -> NULL + * popup_widget -> GtkMenu + * popup_window -> NULL + * popup_frame -> NULL + * + * 3) list mode, no child added + * + * tree_view -> GtkTreeView, child of popup_frame + * cell_view -> GtkCellView, regular child + * cell_view_frame -> GtkFrame, set parent to combo + * button -> GtkToggleButton, set_parent to combo + * box -> NULL + * arrow -> GtkArrow, child of button + * separator -> NULL + * popup_widget -> tree_view + * popup_window -> GtkWindow + * popup_frame -> GtkFrame, child of popup_window + * + * 4) list mode, child added + * + * tree_view -> GtkTreeView, child of popup_frame + * cell_view -> NULL + * cell_view_frame -> NULL + * button -> GtkToggleButton, set_parent to combo + * box -> NULL + * arrow -> GtkArrow, child of button + * separator -> NULL + * popup_widget -> tree_view + * popup_window -> GtkWindow + * popup_frame -> GtkFrame, child of popup_window + * + */ + +enum { + CHANGED, + LAST_SIGNAL +}; + +enum { + PROP_0, + PROP_MODEL, + PROP_WRAP_WIDTH, + PROP_ROW_SPAN_COLUMN, + PROP_COLUMN_SPAN_COLUMN, + PROP_ACTIVE +}; + +static GtkBinClass *parent_class = NULL; +static guint combo_box_signals[LAST_SIGNAL] = {0,}; + +#define BONUS_PADDING 4 + + +/* common */ +static void gtk_combo_box_class_init (GtkComboBoxClass *klass); +static void gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface); +static void gtk_combo_box_init (GtkComboBox *combo_box); +static void gtk_combo_box_finalize (GObject *object); +static void gtk_combo_box_destroy (GtkObject *object); + +static void gtk_combo_box_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *spec); +static void gtk_combo_box_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *spec); + +static void gtk_combo_box_state_changed (GtkWidget *widget, + GtkStateType previous); +static void gtk_combo_box_style_set (GtkWidget *widget, + GtkStyle *previous); +static void gtk_combo_box_button_toggled (GtkWidget *widget, + gpointer data); +static void gtk_combo_box_add (GtkContainer *container, + GtkWidget *widget); +static void gtk_combo_box_remove (GtkContainer *container, + GtkWidget *widget); + +static ComboCellInfo *gtk_combo_box_get_cell_info (GtkComboBox *combo_box, + GtkCellRenderer *cell); + +static void gtk_combo_box_menu_show (GtkWidget *menu, + gpointer user_data); +static void gtk_combo_box_menu_hide (GtkWidget *menu, + gpointer user_data); + +static void gtk_combo_box_set_popup_widget (GtkComboBox *combo_box, + GtkWidget *popup); +#if GTK_CHECK_VERSION(2,2,0) +static void gtk_combo_box_menu_position_below (GtkMenu *menu, + gint *x, + gint *y, + gint *push_in, + gpointer user_data); +static void gtk_combo_box_menu_position_over (GtkMenu *menu, + gint *x, + gint *y, + gint *push_in, + gpointer user_data); +static void gtk_combo_box_menu_position (GtkMenu *menu, + gint *x, + gint *y, + gint *push_in, + gpointer user_data); +#endif + +static gint gtk_combo_box_calc_requested_width (GtkComboBox *combo_box, + GtkTreePath *path); +static void gtk_combo_box_remeasure (GtkComboBox *combo_box); + +static void gtk_combo_box_unset_model (GtkComboBox *combo_box); + +static void gtk_combo_box_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static void gtk_combo_box_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); +static void gtk_combo_box_forall (GtkContainer *container, + gboolean include_internals, + GtkCallback callback, + gpointer callback_data); +static gboolean gtk_combo_box_expose_event (GtkWidget *widget, + GdkEventExpose *event); +static gboolean gtk_combo_box_scroll_event (GtkWidget *widget, + GdkEventScroll *event); +static void gtk_combo_box_set_active_internal (GtkComboBox *combo_box, + gint index); +static gboolean gtk_combo_box_key_press (GtkWidget *widget, + GdkEventKey *event, + gpointer data); + +/* listening to the model */ +static void gtk_combo_box_model_row_inserted (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer user_data); +static void gtk_combo_box_model_row_deleted (GtkTreeModel *model, + GtkTreePath *path, + gpointer user_data); +static void gtk_combo_box_model_rows_reordered (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gint *new_order, + gpointer user_data); +static void gtk_combo_box_model_row_changed (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data); + +/* list */ +static void gtk_combo_box_list_position (GtkComboBox *combo_box, + gint *x, + gint *y, + gint *width, + gint *height); + +static void gtk_combo_box_list_setup (GtkComboBox *combo_box); +static void gtk_combo_box_list_destroy (GtkComboBox *combo_box); + +static void gtk_combo_box_list_remove_grabs (GtkComboBox *combo_box); + +static gboolean gtk_combo_box_list_button_released (GtkWidget *widget, + GdkEventButton *event, + gpointer data); +static gboolean gtk_combo_box_list_key_press (GtkWidget *widget, + GdkEventKey *event, + gpointer data); +static gboolean gtk_combo_box_list_button_pressed (GtkWidget *widget, + GdkEventButton *event, + gpointer data); + +static void gtk_combo_box_list_row_changed (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data); + +/* menu */ +static void gtk_combo_box_menu_setup (GtkComboBox *combo_box, + gboolean add_children); +static void gtk_combo_box_menu_fill (GtkComboBox *combo_box); +static void gtk_combo_box_menu_destroy (GtkComboBox *combo_box); + +static void gtk_combo_box_item_get_size (GtkComboBox *combo_box, + gint index, + gint *cols, + gint *rows); +static void gtk_combo_box_relayout_item (GtkComboBox *combo_box, + gint index); +static void gtk_combo_box_relayout (GtkComboBox *combo_box); + +static gboolean gtk_combo_box_menu_button_press (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data); +static void gtk_combo_box_menu_item_activate (GtkWidget *item, + gpointer user_data); +static void gtk_combo_box_menu_row_inserted (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer user_data); +static void gtk_combo_box_menu_row_deleted (GtkTreeModel *model, + GtkTreePath *path, + gpointer user_data); +static void gtk_combo_box_menu_rows_reordered (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gint *new_order, + gpointer user_data); +static void gtk_combo_box_menu_row_changed (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data); +static gboolean gtk_combo_box_menu_key_press (GtkWidget *widget, + GdkEventKey *event, + gpointer data); + +/* cell layout */ +static void gtk_combo_box_cell_layout_pack_start (GtkCellLayout *layout, + GtkCellRenderer *cell, + gboolean expand); +static void gtk_combo_box_cell_layout_pack_end (GtkCellLayout *layout, + GtkCellRenderer *cell, + gboolean expand); +static void gtk_combo_box_cell_layout_clear (GtkCellLayout *layout); +static void gtk_combo_box_cell_layout_add_attribute (GtkCellLayout *layout, + GtkCellRenderer *cell, + const gchar *attribute, + gint column); +static void gtk_combo_box_cell_layout_set_cell_data_func (GtkCellLayout *layout, + GtkCellRenderer *cell, + GtkCellLayoutDataFunc func, + gpointer func_data, + GDestroyNotify destroy); +static void gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout *layout, + GtkCellRenderer *cell); +static void gtk_combo_box_cell_layout_reorder (GtkCellLayout *layout, + GtkCellRenderer *cell, + gint position); +static gboolean gtk_combo_box_mnemonic_activate (GtkWidget *widget, + gboolean group_cycling); + +static void cell_view_sync_cells (GtkComboBox *combo_box, + GtkCellView *cell_view); + +#if !GTK_CHECK_VERSION(2,4,0) +static void gtk_menu_attach (GtkMenu *menu, + GtkWidget *child, + guint left_attach, + guint right_attach, + guint top_attach, + guint bottom_attach); +#endif + +GType +gtk_combo_box_get_type (void) +{ + static GType combo_box_type = 0; + + if (!combo_box_type) + { + static const GTypeInfo combo_box_info = + { + sizeof (GtkComboBoxClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) gtk_combo_box_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GtkComboBox), + 0, + (GInstanceInitFunc) gtk_combo_box_init + }; + + static const GInterfaceInfo cell_layout_info = + { + (GInterfaceInitFunc) gtk_combo_box_cell_layout_init, + NULL, + NULL + }; + + combo_box_type = g_type_register_static (GTK_TYPE_BIN, + "PidginComboBox", + &combo_box_info, + 0); + + g_type_add_interface_static (combo_box_type, + GTK_TYPE_CELL_LAYOUT, + &cell_layout_info); + } + + return combo_box_type; +} + +/* common */ +static void +gtk_combo_box_class_init (GtkComboBoxClass *klass) +{ + GObjectClass *object_class; + GtkBindingSet *binding_set; + GtkObjectClass *gtk_object_class; + GtkContainerClass *container_class; + GtkWidgetClass *widget_class; + + binding_set = gtk_binding_set_by_class (klass); + + container_class = (GtkContainerClass *)klass; + container_class->forall = gtk_combo_box_forall; + container_class->add = gtk_combo_box_add; + container_class->remove = gtk_combo_box_remove; + + widget_class = (GtkWidgetClass *)klass; + widget_class->size_allocate = gtk_combo_box_size_allocate; + widget_class->size_request = gtk_combo_box_size_request; + widget_class->expose_event = gtk_combo_box_expose_event; + widget_class->scroll_event = gtk_combo_box_scroll_event; + widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate; + widget_class->style_set = gtk_combo_box_style_set; + widget_class->state_changed = gtk_combo_box_state_changed; + + gtk_object_class = (GtkObjectClass *)klass; + gtk_object_class->destroy = gtk_combo_box_destroy; + + object_class = (GObjectClass *)klass; + object_class->finalize = gtk_combo_box_finalize; + object_class->set_property = gtk_combo_box_set_property; + object_class->get_property = gtk_combo_box_get_property; + + parent_class = g_type_class_peek_parent (klass); + + /* signals */ + combo_box_signals[CHANGED] = + g_signal_new ("changed", + G_OBJECT_CLASS_TYPE (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkComboBoxClass, changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + /* properties */ + g_object_class_install_property (object_class, + PROP_MODEL, + g_param_spec_object ("model", + P_("ComboBox model"), + P_("The model for the combo box"), + GTK_TYPE_TREE_MODEL, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_WRAP_WIDTH, + g_param_spec_int ("wrap_width", + P_("Wrap width"), + P_("Wrap width for layouting the items in a grid"), + 0, + G_MAXINT, + 0, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_ROW_SPAN_COLUMN, + g_param_spec_int ("row_span_column", + P_("Row span column"), + P_("TreeModel column containing the row span values"), + 0, + G_MAXINT, + 0, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_COLUMN_SPAN_COLUMN, + g_param_spec_int ("column_span_column", + P_("Column span column"), + + P_("TreeModel column containing the column span values"), + 0, + G_MAXINT, + 0, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_ACTIVE, + g_param_spec_int ("active", + P_("Active item"), + P_("The item which is currently active"), + -1, + G_MAXINT, + -1, + G_PARAM_READWRITE)); + + gtk_widget_class_install_style_property (widget_class, + g_param_spec_boolean ("appears-as-list", + P_("Appears as list"), + P_("Whether combobox dropdowns should look like lists rather than menus"), + FALSE, + G_PARAM_READABLE)); +} + +static void +gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface) +{ + iface->pack_start = gtk_combo_box_cell_layout_pack_start; + iface->pack_end = gtk_combo_box_cell_layout_pack_end; + iface->clear = gtk_combo_box_cell_layout_clear; + iface->add_attribute = gtk_combo_box_cell_layout_add_attribute; + iface->set_cell_data_func = gtk_combo_box_cell_layout_set_cell_data_func; + iface->clear_attributes = gtk_combo_box_cell_layout_clear_attributes; + iface->reorder = gtk_combo_box_cell_layout_reorder; +} + +static void +gtk_combo_box_init (GtkComboBox *combo_box) +{ + combo_box->priv = g_new0(GtkComboBoxPrivate,1); + + combo_box->priv->cell_view = gtk_cell_view_new (); + gtk_widget_set_parent (combo_box->priv->cell_view, GTK_WIDGET (combo_box)); + GTK_BIN (combo_box)->child = combo_box->priv->cell_view; + gtk_widget_show (combo_box->priv->cell_view); + + combo_box->priv->width = 0; + combo_box->priv->wrap_width = 0; + + combo_box->priv->active_item = -1; + combo_box->priv->col_column = -1; + combo_box->priv->row_column = -1; +} + +static void +gtk_combo_box_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (object); + + switch (prop_id) + { + case PROP_MODEL: + gtk_combo_box_set_model (combo_box, g_value_get_object (value)); + break; + + case PROP_WRAP_WIDTH: + gtk_combo_box_set_wrap_width (combo_box, g_value_get_int (value)); + break; + + case PROP_ROW_SPAN_COLUMN: + gtk_combo_box_set_row_span_column (combo_box, g_value_get_int (value)); + break; + + case PROP_COLUMN_SPAN_COLUMN: + gtk_combo_box_set_column_span_column (combo_box, g_value_get_int (value)); + break; + + case PROP_ACTIVE: + gtk_combo_box_set_active (combo_box, g_value_get_int (value)); + break; + + default: + break; + } +} + +static void +gtk_combo_box_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (object); + + switch (prop_id) + { + case PROP_MODEL: + g_value_set_object (value, combo_box->priv->model); + break; + + case PROP_WRAP_WIDTH: + g_value_set_int (value, combo_box->priv->wrap_width); + break; + + case PROP_ROW_SPAN_COLUMN: + g_value_set_int (value, combo_box->priv->row_column); + break; + + case PROP_COLUMN_SPAN_COLUMN: + g_value_set_int (value, combo_box->priv->col_column); + break; + + case PROP_ACTIVE: + g_value_set_int (value, gtk_combo_box_get_active (combo_box)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gtk_combo_box_state_changed (GtkWidget *widget, + GtkStateType previous) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (widget); + + if (GTK_WIDGET_REALIZED (widget)) + { + if (combo_box->priv->tree_view && combo_box->priv->cell_view) + gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view), + &widget->style->base[GTK_WIDGET_STATE (widget)]); + } + + gtk_widget_queue_draw (widget); +} + +static void +gtk_combo_box_check_appearance (GtkComboBox *combo_box) +{ + gboolean appears_as_list; + + /* if wrap_width > 0, then we are in grid-mode and forced to use + * unix style + */ + if (combo_box->priv->wrap_width) + appears_as_list = FALSE; + else + gtk_widget_style_get (GTK_WIDGET (combo_box), + "appears-as-list", &appears_as_list, + NULL); + + if (appears_as_list) + { + /* Destroy all the menu mode widgets, if they exist. */ + if (GTK_IS_MENU (combo_box->priv->popup_widget)) + gtk_combo_box_menu_destroy (combo_box); + + /* Create the list mode widgets, if they don't already exist. */ + if (!GTK_IS_TREE_VIEW (combo_box->priv->tree_view)) + gtk_combo_box_list_setup (combo_box); + } + else + { + /* Destroy all the list mode widgets, if they exist. */ + if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view)) + gtk_combo_box_list_destroy (combo_box); + + /* Create the menu mode widgets, if they don't already exist. */ + if (!GTK_IS_MENU (combo_box->priv->popup_widget)) + gtk_combo_box_menu_setup (combo_box, TRUE); + } +} + +static void +gtk_combo_box_style_set (GtkWidget *widget, + GtkStyle *previous) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (widget); + + gtk_combo_box_check_appearance (combo_box); + + if (combo_box->priv->tree_view && combo_box->priv->cell_view) + gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view), + &widget->style->base[GTK_WIDGET_STATE (widget)]); +} + +static void +gtk_combo_box_button_toggled (GtkWidget *widget, + gpointer data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (data); + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) + { + if (!combo_box->priv->popup_in_progress) + gtk_combo_box_popup (combo_box); + } + else + gtk_combo_box_popdown (combo_box); +} + +static void +gtk_combo_box_add (GtkContainer *container, + GtkWidget *widget) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (container); + + if (combo_box->priv->cell_view && combo_box->priv->cell_view->parent) + { + gtk_widget_unparent (combo_box->priv->cell_view); + GTK_BIN (container)->child = NULL; + gtk_widget_queue_resize (GTK_WIDGET (container)); + } + + gtk_widget_set_parent (widget, GTK_WIDGET (container)); + GTK_BIN (container)->child = widget; + + if (combo_box->priv->cell_view && + widget != combo_box->priv->cell_view) + { + /* since the cell_view was unparented, it's gone now */ + combo_box->priv->cell_view = NULL; + + if (!combo_box->priv->tree_view && combo_box->priv->separator) + { + gtk_container_remove (GTK_CONTAINER (combo_box->priv->separator->parent), + combo_box->priv->separator); + combo_box->priv->separator = NULL; + + gtk_widget_queue_resize (GTK_WIDGET (container)); + } + else if (combo_box->priv->cell_view_frame) + { + gtk_widget_unparent (combo_box->priv->cell_view_frame); + combo_box->priv->cell_view_frame = NULL; + } + } +} + +static void +gtk_combo_box_remove (GtkContainer *container, + GtkWidget *widget) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (container); + gboolean appears_as_list; + + gtk_widget_unparent (widget); + GTK_BIN (container)->child = NULL; + + if (combo_box->priv->destroying) + return; + + gtk_widget_queue_resize (GTK_WIDGET (container)); + + if (!combo_box->priv->tree_view) + appears_as_list = FALSE; + else + appears_as_list = TRUE; + + if (appears_as_list) + gtk_combo_box_list_destroy (combo_box); + else if (GTK_IS_MENU (combo_box->priv->popup_widget)) + { + gtk_combo_box_menu_destroy (combo_box); + gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget)); + combo_box->priv->popup_widget = NULL; + } + + if (!combo_box->priv->cell_view) + { + combo_box->priv->cell_view = gtk_cell_view_new (); + gtk_widget_set_parent (combo_box->priv->cell_view, GTK_WIDGET (container)); + GTK_BIN (container)->child = combo_box->priv->cell_view; + + gtk_widget_show (combo_box->priv->cell_view); + gtk_cell_view_set_model (GTK_CELL_VIEW (combo_box->priv->cell_view), + combo_box->priv->model); + cell_view_sync_cells (combo_box, GTK_CELL_VIEW (combo_box->priv->cell_view)); + } + + + if (appears_as_list) + gtk_combo_box_list_setup (combo_box); + else + gtk_combo_box_menu_setup (combo_box, TRUE); + + gtk_combo_box_set_active_internal (combo_box, combo_box->priv->active_item); +} + +static ComboCellInfo * +gtk_combo_box_get_cell_info (GtkComboBox *combo_box, + GtkCellRenderer *cell) +{ + GSList *i; + + for (i = combo_box->priv->cells; i; i = i->next) + { + ComboCellInfo *info = (ComboCellInfo *)i->data; + + if (info && info->cell == cell) + return info; + } + + return NULL; +} + +static void +gtk_combo_box_menu_show (GtkWidget *menu, + gpointer user_data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button), + TRUE); + combo_box->priv->popup_in_progress = FALSE; +} + +static void +gtk_combo_box_menu_hide (GtkWidget *menu, + gpointer user_data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button), + FALSE); +} + +static void +gtk_combo_box_detacher (GtkWidget *widget, + GtkMenu *menu) +{ + GtkComboBox *combo_box; + + g_return_if_fail (GTK_IS_COMBO_BOX (widget)); + + combo_box = GTK_COMBO_BOX (widget); + g_return_if_fail (combo_box->priv->popup_widget == (GtkWidget*) menu); + + g_signal_handlers_disconnect_by_func (menu, + gtk_combo_box_menu_show, + combo_box); + g_signal_handlers_disconnect_by_func (menu, + gtk_combo_box_menu_hide, + combo_box); + + combo_box->priv->popup_widget = NULL; +} + +static void +gtk_combo_box_set_popup_widget (GtkComboBox *combo_box, + GtkWidget *popup) +{ + if (GTK_IS_MENU (combo_box->priv->popup_widget)) + { + gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget)); + combo_box->priv->popup_widget = NULL; + } + else if (combo_box->priv->popup_widget) + { + gtk_container_remove (GTK_CONTAINER (combo_box->priv->popup_frame), + combo_box->priv->popup_widget); + g_object_unref (G_OBJECT (combo_box->priv->popup_widget)); + combo_box->priv->popup_widget = NULL; + } + + if (GTK_IS_MENU (popup)) + { + if (combo_box->priv->popup_window) + { + gtk_widget_destroy (combo_box->priv->popup_window); + combo_box->priv->popup_window = NULL; + combo_box->priv->popup_frame = NULL; + } + + combo_box->priv->popup_widget = popup; + + g_signal_connect (popup, "show", + G_CALLBACK (gtk_combo_box_menu_show), combo_box); + g_signal_connect (popup, "hide", + G_CALLBACK (gtk_combo_box_menu_hide), combo_box); + + gtk_menu_attach_to_widget (GTK_MENU (popup), + GTK_WIDGET (combo_box), + gtk_combo_box_detacher); + } + else + { + if (!combo_box->priv->popup_window) + { + combo_box->priv->popup_window = gtk_window_new (GTK_WINDOW_POPUP); + gtk_window_set_resizable (GTK_WINDOW (combo_box->priv->popup_window), FALSE); +#if GTK_CHECK_VERSION(2,2,0) + gtk_window_set_screen (GTK_WINDOW (combo_box->priv->popup_window), + gtk_widget_get_screen (GTK_WIDGET (combo_box))); +#endif + + combo_box->priv->popup_frame = gtk_frame_new (NULL); + gtk_frame_set_shadow_type (GTK_FRAME (combo_box->priv->popup_frame), + GTK_SHADOW_ETCHED_IN); + gtk_container_add (GTK_CONTAINER (combo_box->priv->popup_window), + combo_box->priv->popup_frame); + + gtk_widget_show (combo_box->priv->popup_frame); + } + + gtk_container_add (GTK_CONTAINER (combo_box->priv->popup_frame), + popup); + gtk_widget_show (popup); + g_object_ref (G_OBJECT (popup)); + combo_box->priv->popup_widget = popup; + } +} + +#if GTK_CHECK_VERSION(2,2,0) +static void +gtk_combo_box_menu_position_below (GtkMenu *menu, + gint *x, + gint *y, + gint *push_in, + gpointer user_data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); + gint sx, sy; + GtkWidget *child; + GtkRequisition req; + GdkScreen *screen; + gint monitor_num; + GdkRectangle monitor; + + /* FIXME: is using the size request here broken? */ + child = GTK_BIN (combo_box)->child; + + gdk_window_get_origin (child->window, &sx, &sy); + + if (GTK_WIDGET_NO_WINDOW (child)) + { + sx += child->allocation.x; + sy += child->allocation.y; + } + + gtk_widget_size_request (GTK_WIDGET (menu), &req); + + if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_LTR) + *x = sx; + else + *x = sx + child->allocation.width - req.width; + *y = sy; + + screen = gtk_widget_get_screen (GTK_WIDGET (combo_box)); + monitor_num = gdk_screen_get_monitor_at_window (screen, + GTK_WIDGET (combo_box)->window); + gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); + + if (*x < monitor.x) + *x = monitor.x; + else if (*x + req.width > monitor.x + monitor.width) + *x = monitor.x + monitor.width - req.width; + + if (monitor.y + monitor.height - *y - child->allocation.height >= req.height) + *y += child->allocation.height; + else if (*y - monitor.y >= req.height) + *y -= req.height; + else if (monitor.y + monitor.height - *y - child->allocation.height > *y - monitor.y) + *y += child->allocation.height; + else + *y -= req.height; + + *push_in = FALSE; +} + +static void +gtk_combo_box_menu_position_over (GtkMenu *menu, + gint *x, + gint *y, + gboolean *push_in, + gpointer user_data) +{ + GtkComboBox *combo_box; + GtkWidget *active; + GtkWidget *child; + GtkWidget *widget; + GtkRequisition requisition; + GList *children; + gint screen_width; + gint menu_xpos; + gint menu_ypos; + gint menu_width; + + g_return_if_fail (GTK_IS_COMBO_BOX (user_data)); + + combo_box = GTK_COMBO_BOX (user_data); + widget = GTK_WIDGET (combo_box); + + gtk_widget_get_child_requisition (GTK_WIDGET (menu), &requisition); + menu_width = requisition.width; + + active = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget)); + gdk_window_get_origin (widget->window, &menu_xpos, &menu_ypos); + + menu_xpos += widget->allocation.x; + menu_ypos += widget->allocation.y + widget->allocation.height / 2 - 2; + + if (active != NULL) + { + gtk_widget_get_child_requisition (active, &requisition); + menu_ypos -= requisition.height / 2; + } + + children = GTK_MENU_SHELL (combo_box->priv->popup_widget)->children; + while (children) + { + child = children->data; + + if (active == child) + break; + + if (GTK_WIDGET_VISIBLE (child)) + { + gtk_widget_get_child_requisition (child, &requisition); + menu_ypos -= requisition.height; + } + + children = children->next; + } + + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) + menu_xpos = menu_xpos + widget->allocation.width - menu_width; + + /* Clamp the position on screen */ + screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget)); + + if (menu_xpos < 0) + menu_xpos = 0; + else if ((menu_xpos + menu_width) > screen_width) + menu_xpos -= ((menu_xpos + menu_width) - screen_width); + + *x = menu_xpos; + *y = menu_ypos; + + *push_in = TRUE; +} + +static void +gtk_combo_box_menu_position (GtkMenu *menu, + gint *x, + gint *y, + gint *push_in, + gpointer user_data) +{ + GtkComboBox *combo_box; + GtkWidget *menu_item; + + combo_box = GTK_COMBO_BOX (user_data); + + if (combo_box->priv->wrap_width > 0 || combo_box->priv->cell_view == NULL) + gtk_combo_box_menu_position_below (menu, x, y, push_in, user_data); + else + { + menu_item = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget)); + if (menu_item) + gtk_menu_shell_select_item (GTK_MENU_SHELL (combo_box->priv->popup_widget), + menu_item); + + gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data); + } + +} +#endif /* Gtk 2.2 */ + +static void +gtk_combo_box_list_position (GtkComboBox *combo_box, + gint *x, + gint *y, + gint *width, + gint *height) +{ + GtkWidget *sample; + GtkRequisition popup_req; +#if GTK_CHECK_VERSION(2,2,0) + GdkScreen *screen; + gint monitor_num; + GdkRectangle monitor; +#endif + + sample = GTK_BIN (combo_box)->child; + + *width = sample->allocation.width; + gtk_widget_size_request (combo_box->priv->popup_window, &popup_req); + *height = popup_req.height; + + gdk_window_get_origin (sample->window, x, y); + + if (combo_box->priv->cell_view_frame) + { + *x -= GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + + GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness; + *width += 2 * (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + + GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness); + } + + if (GTK_WIDGET_NO_WINDOW (sample)) + { + *x += sample->allocation.x; + *y += sample->allocation.y; + } + +#if GTK_CHECK_VERSION(2,2,0) + screen = gtk_widget_get_screen (GTK_WIDGET (combo_box)); + monitor_num = gdk_screen_get_monitor_at_window (screen, + GTK_WIDGET (combo_box)->window); + gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); + + if (*x < monitor.x) + *x = monitor.x; + else if (*x + *width > monitor.x + monitor.width) + *x = monitor.x + monitor.width - *width; + + if (*y + sample->allocation.height + *height <= monitor.y + monitor.height) + *y += sample->allocation.height; + else + *y -= *height; +#endif /* Gtk 2.2 */ +} + +/** + * gtk_combo_box_popup: + * @combo_box: a #GtkComboBox + * + * Pops up the menu or dropdown list of @combo_box. + * + * This function is mostly intended for use by accessibility technologies; + * applications should have little use for it. + * + * Since: 2.4 + **/ +void +gtk_combo_box_popup (GtkComboBox *combo_box) +{ + gint x, y, width, height; + + g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); + + if (GTK_WIDGET_MAPPED (combo_box->priv->popup_widget)) + return; + + if (GTK_IS_MENU (combo_box->priv->popup_widget)) + { + gtk_menu_set_active (GTK_MENU (combo_box->priv->popup_widget), + combo_box->priv->active_item); + + if (combo_box->priv->wrap_width == 0) + { + GtkRequisition requisition; + + width = GTK_WIDGET (combo_box)->allocation.width; + gtk_widget_size_request (combo_box->priv->popup_widget, &requisition); + + gtk_widget_set_size_request (combo_box->priv->popup_widget, + MAX (width, requisition.width), -1); + } + + gtk_menu_popup (GTK_MENU (combo_box->priv->popup_widget), + NULL, NULL, +#if GTK_CHECK_VERSION(2,2,0) + gtk_combo_box_menu_position, +#else + NULL, +#endif + combo_box, 0, 0); + return; + } + + gtk_widget_show_all (combo_box->priv->popup_frame); + gtk_combo_box_list_position (combo_box, &x, &y, &width, &height); + + gtk_widget_set_size_request (combo_box->priv->popup_window, width, -1); + gtk_window_move (GTK_WINDOW (combo_box->priv->popup_window), x, y); + + /* popup */ + gtk_widget_show (combo_box->priv->popup_window); + + gtk_widget_grab_focus (combo_box->priv->popup_window); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button), + TRUE); + + if (!GTK_WIDGET_HAS_FOCUS (combo_box->priv->tree_view)) + { + gdk_keyboard_grab (combo_box->priv->popup_window->window, + FALSE, GDK_CURRENT_TIME); + gtk_widget_grab_focus (combo_box->priv->tree_view); + } + + gtk_grab_add (combo_box->priv->popup_window); + gdk_pointer_grab (combo_box->priv->popup_window->window, TRUE, + GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK, + NULL, NULL, GDK_CURRENT_TIME); + + gtk_grab_add (combo_box->priv->tree_view); +} + +/** + * gtk_combo_box_popdown: + * @combo_box: a #GtkComboBox + * + * Hides the menu or dropdown list of @combo_box. + * + * This function is mostly intended for use by accessibility technologies; + * applications should have little use for it. + * + * Since: 2.4 + **/ +void +gtk_combo_box_popdown (GtkComboBox *combo_box) +{ + g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); + + if (!GTK_WIDGET_REALIZED (GTK_WIDGET (combo_box))) + return; + + if (GTK_IS_MENU (combo_box->priv->popup_widget)) + { + gtk_menu_popdown (GTK_MENU (combo_box->priv->popup_widget)); + return; + } + + gtk_combo_box_list_remove_grabs (combo_box); + gtk_widget_hide_all (combo_box->priv->popup_window); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button), + FALSE); +} + +static gint +gtk_combo_box_calc_requested_width (GtkComboBox *combo_box, + GtkTreePath *path) +{ + gint padding; + GtkRequisition req; + + if (combo_box->priv->cell_view) + gtk_widget_style_get (combo_box->priv->cell_view, + "focus-line-width", &padding, + NULL); + else + padding = 0; + + /* add some pixels for good measure */ + padding += BONUS_PADDING; + + if (combo_box->priv->cell_view) + gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (combo_box->priv->cell_view), + path, &req); + else + req.width = 0; + + return req.width + padding; +} + +static void +gtk_combo_box_remeasure (GtkComboBox *combo_box) +{ + GtkTreeIter iter; + GtkTreePath *path; + gint padding = 0; + + if (!combo_box->priv->model || + !gtk_tree_model_get_iter_first (combo_box->priv->model, &iter)) + return; + + combo_box->priv->width = 0; + +#if GTK_CHECK_VERSION(2,2,0) + path = gtk_tree_path_new_from_indices (0, -1); +#else + path = gtk_tree_path_new_first(); +#endif + + if (combo_box->priv->cell_view) + gtk_widget_style_get (combo_box->priv->cell_view, + "focus-line-width", &padding, + NULL); + else + padding = 0; + + /* add some pixels for good measure */ + padding += BONUS_PADDING; + + do + { + GtkRequisition req; + + if (combo_box->priv->cell_view) + gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (combo_box->priv->cell_view), + path, &req); + else + req.width = 0; + + combo_box->priv->width = MAX (combo_box->priv->width, + req.width + padding); + + gtk_tree_path_next (path); + } + while (gtk_tree_model_iter_next (combo_box->priv->model, &iter)); + + gtk_tree_path_free (path); +} + +static void +gtk_combo_box_size_request (GtkWidget *widget, + GtkRequisition *requisition) +{ + gint width, height; + GtkRequisition bin_req; + + GtkComboBox *combo_box = GTK_COMBO_BOX (widget); + + /* common */ + gtk_widget_size_request (GTK_BIN (widget)->child, &bin_req); + gtk_combo_box_remeasure (combo_box); + bin_req.width = MAX (bin_req.width, combo_box->priv->width); + + gtk_combo_box_check_appearance (combo_box); + + if (!combo_box->priv->tree_view) + { + /* menu mode */ + + if (combo_box->priv->cell_view) + { + GtkRequisition button_req, sep_req, arrow_req; + gint border_width, xthickness, ythickness; + + gtk_widget_size_request (combo_box->priv->button, &button_req); + border_width = GTK_CONTAINER (combo_box->priv->button)->border_width; + xthickness = combo_box->priv->button->style->xthickness; + ythickness = combo_box->priv->button->style->ythickness; + + bin_req.width = MAX (bin_req.width, combo_box->priv->width); + + gtk_widget_size_request (combo_box->priv->separator, &sep_req); + gtk_widget_size_request (combo_box->priv->arrow, &arrow_req); + + height = MAX (sep_req.height, arrow_req.height); + height = MAX (height, bin_req.height); + + width = bin_req.width + sep_req.width + arrow_req.width; + + height += border_width + 1 + ythickness * 2 + 4; + width += border_width + 1 + xthickness * 2 + 4; + + requisition->width = width; + requisition->height = height; + } + else + { + GtkRequisition but_req; + + gtk_widget_size_request (combo_box->priv->button, &but_req); + + requisition->width = bin_req.width + but_req.width; + requisition->height = MAX (bin_req.height, but_req.height); + } + } + else + { + /* list mode */ + GtkRequisition button_req, frame_req; + + /* sample + frame */ + *requisition = bin_req; + + if (combo_box->priv->cell_view_frame) + { + gtk_widget_size_request (combo_box->priv->cell_view_frame, &frame_req); + requisition->width += 2 * + (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + + GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness); + requisition->height += 2 * + (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + + GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness); + } + + /* the button */ + gtk_widget_size_request (combo_box->priv->button, &button_req); + + requisition->height = MAX (requisition->height, button_req.height); + requisition->width += button_req.width; + } +} + +static void +gtk_combo_box_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (widget); + GtkAllocation child; + GtkRequisition req; + gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL; + + widget->allocation = *allocation; + + gtk_combo_box_check_appearance (combo_box); + + if (!combo_box->priv->tree_view) + { + if (combo_box->priv->cell_view) + { + gint border_width, xthickness, ythickness; + gint width; + + /* menu mode */ + gtk_widget_size_allocate (combo_box->priv->button, allocation); + + /* set some things ready */ + border_width = GTK_CONTAINER (combo_box->priv->button)->border_width; + xthickness = combo_box->priv->button->style->xthickness; + ythickness = combo_box->priv->button->style->ythickness; + + child.x = allocation->x + border_width + 1 + xthickness + 2; + child.y = allocation->y + border_width + 1 + ythickness + 2; + + width = MAX(1, allocation->width - (border_width + 1 + xthickness * 2 + 4)); + + /* handle the children */ + gtk_widget_size_request (combo_box->priv->arrow, &req); + child.width = req.width; + child.height = MAX(1, allocation->height - 2 * (child.y - allocation->y)); + if (!is_rtl) + child.x += width - req.width; + gtk_widget_size_allocate (combo_box->priv->arrow, &child); + if (is_rtl) + child.x += req.width; + gtk_widget_size_request (combo_box->priv->separator, &req); + child.width = req.width; + if (!is_rtl) + child.x -= req.width; + gtk_widget_size_allocate (combo_box->priv->separator, &child); + + if (is_rtl) + { + child.x += req.width; + child.width = MAX(1, allocation->x + allocation->width + - (border_width + 1 + xthickness + 2) - child.x); + } + else + { + child.width = child.x; + child.x = allocation->x + border_width + 1 + xthickness + 2; + child.width = MAX(1, child.width - child.x); + } + + gtk_widget_size_allocate (GTK_BIN (widget)->child, &child); + } + else + { + gtk_widget_size_request (combo_box->priv->button, &req); + if (is_rtl) + child.x = allocation->x; + else + child.x = allocation->x + allocation->width - req.width; + child.y = allocation->y; + child.width = req.width; + child.height = allocation->height; + gtk_widget_size_allocate (combo_box->priv->button, &child); + + if (is_rtl) + child.x = allocation->x + req.width; + else + child.x = allocation->x; + child.y = allocation->y; + child.width = MAX(1, allocation->width - req.width); + gtk_widget_size_allocate (GTK_BIN (widget)->child, &child); + } + } + else + { + /* list mode */ + + /* button */ + gtk_widget_size_request (combo_box->priv->button, &req); + if (is_rtl) + child.x = allocation->x; + else + child.x = allocation->x + allocation->width - req.width; + child.y = allocation->y; + child.width = req.width; + child.height = allocation->height; + gtk_widget_size_allocate (combo_box->priv->button, &child); + + /* frame */ + if (is_rtl) + child.x = allocation->x + req.width; + else + child.x = allocation->x; + child.y = allocation->y; + child.width = MAX (1, allocation->width - req.width); + child.height = allocation->height; + + if (combo_box->priv->cell_view_frame) + { + gtk_widget_size_allocate (combo_box->priv->cell_view_frame, &child); + + /* the sample */ + child.x += + GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + + GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness; + child.y += + GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + + GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness; + child.width -= 2 * ( + GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + + GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness); + child.width = MAX(1,child.width); + child.height -= 2 * ( + GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + + GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness); + child.height = MAX(1,child.height); + } + + gtk_widget_size_allocate (GTK_BIN (combo_box)->child, &child); + } +} + +static void +gtk_combo_box_unset_model (GtkComboBox *combo_box) +{ + if (combo_box->priv->model) + { + g_signal_handler_disconnect (combo_box->priv->model, + combo_box->priv->inserted_id); + g_signal_handler_disconnect (combo_box->priv->model, + combo_box->priv->deleted_id); + g_signal_handler_disconnect (combo_box->priv->model, + combo_box->priv->reordered_id); + g_signal_handler_disconnect (combo_box->priv->model, + combo_box->priv->changed_id); + } + + /* menu mode */ + if (!combo_box->priv->tree_view) + { + if (combo_box->priv->popup_widget) + gtk_container_foreach (GTK_CONTAINER (combo_box->priv->popup_widget), + (GtkCallback)gtk_widget_destroy, NULL); + } + + if (combo_box->priv->model) + { + g_object_unref (G_OBJECT (combo_box->priv->model)); + combo_box->priv->model = NULL; + } + + if (combo_box->priv->cell_view) + gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (combo_box->priv->cell_view), NULL); +} + +static void +gtk_combo_box_forall (GtkContainer *container, + gboolean include_internals, + GtkCallback callback, + gpointer callback_data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (container); + + if (include_internals) + { + if (combo_box->priv->button) + (* callback) (combo_box->priv->button, callback_data); + if (combo_box->priv->cell_view_frame) + (* callback) (combo_box->priv->cell_view_frame, callback_data); + } + + if (GTK_BIN (container)->child) + (* callback) (GTK_BIN (container)->child, callback_data); +} + +static gboolean +gtk_combo_box_expose_event (GtkWidget *widget, + GdkEventExpose *event) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (widget); + + if (!combo_box->priv->tree_view) + { + gtk_container_propagate_expose (GTK_CONTAINER (widget), + combo_box->priv->button, event); + } + else + { + gtk_container_propagate_expose (GTK_CONTAINER (widget), + combo_box->priv->button, event); + + if (combo_box->priv->cell_view_frame) + gtk_container_propagate_expose (GTK_CONTAINER (widget), + combo_box->priv->cell_view_frame, event); + } + + gtk_container_propagate_expose (GTK_CONTAINER (widget), + GTK_BIN (widget)->child, event); + + return FALSE; +} + +static gboolean +gtk_combo_box_scroll_event (GtkWidget *widget, + GdkEventScroll *event) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (widget); + gint index; + gint items; + + index = gtk_combo_box_get_active (combo_box); + + if (index != -1) + { + items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL); + + if (event->direction == GDK_SCROLL_UP) + index--; + else + index++; + + gtk_combo_box_set_active (combo_box, CLAMP (index, 0, items - 1)); + } + + return TRUE; +} + +/* + * menu style + */ + +static void +cell_view_sync_cells (GtkComboBox *combo_box, + GtkCellView *cell_view) +{ + GSList *k; + + for (k = combo_box->priv->cells; k; k = k->next) + { + GSList *j; + ComboCellInfo *info = (ComboCellInfo *)k->data; + + if (info->pack == GTK_PACK_START) + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cell_view), + info->cell, info->expand); + else if (info->pack == GTK_PACK_END) + gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (cell_view), + info->cell, info->expand); + + gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (cell_view), + info->cell, + info->func, info->func_data, NULL); + + for (j = info->attributes; j; j = j->next->next) + { + gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (cell_view), + info->cell, + j->data, + GPOINTER_TO_INT (j->next->data)); + } + } +} + +static void +gtk_combo_box_menu_setup (GtkComboBox *combo_box, + gboolean add_children) +{ + GtkWidget *menu; + + if (combo_box->priv->cell_view) + { + combo_box->priv->button = gtk_toggle_button_new (); + g_signal_connect (combo_box->priv->button, "toggled", + G_CALLBACK (gtk_combo_box_button_toggled), combo_box); + g_signal_connect_after (combo_box->priv->button, "key_press_event", + G_CALLBACK (gtk_combo_box_key_press), combo_box); + gtk_widget_set_parent (combo_box->priv->button, + GTK_BIN (combo_box)->child->parent); + + combo_box->priv->box = gtk_hbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (combo_box->priv->button), + combo_box->priv->box); + + combo_box->priv->separator = gtk_vseparator_new (); + gtk_container_add (GTK_CONTAINER (combo_box->priv->box), + combo_box->priv->separator); + + combo_box->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); + gtk_container_add (GTK_CONTAINER (combo_box->priv->box), + combo_box->priv->arrow); + + gtk_widget_show_all (combo_box->priv->button); + } + else + { + combo_box->priv->button = gtk_toggle_button_new (); + g_signal_connect (combo_box->priv->button, "toggled", + G_CALLBACK (gtk_combo_box_button_toggled), combo_box); + g_signal_connect_after (combo_box, "key_press_event", + G_CALLBACK (gtk_combo_box_key_press), combo_box); + gtk_widget_set_parent (combo_box->priv->button, + GTK_BIN (combo_box)->child->parent); + + combo_box->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); + gtk_container_add (GTK_CONTAINER (combo_box->priv->button), + combo_box->priv->arrow); + gtk_widget_show_all (combo_box->priv->button); + } + + g_signal_connect (combo_box->priv->button, "button_press_event", + G_CALLBACK (gtk_combo_box_menu_button_press), + combo_box); + + /* create our funky menu */ + menu = gtk_menu_new (); + g_signal_connect (menu, "key_press_event", + G_CALLBACK (gtk_combo_box_menu_key_press), combo_box); + gtk_combo_box_set_popup_widget (combo_box, menu); + + /* add items */ + if (add_children) + gtk_combo_box_menu_fill (combo_box); + +} + +static void +gtk_combo_box_menu_fill (GtkComboBox *combo_box) +{ + gint i, items; + GtkWidget *menu; + GtkWidget *tmp; + + if (!combo_box->priv->model) + return; + + items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL); + menu = combo_box->priv->popup_widget; + + for (i = 0; i < items; i++) + { + GtkTreePath *path; +#if GTK_CHECK_VERSION(2,2,0) + path = gtk_tree_path_new_from_indices (i, -1); +#else + char buf[32]; + g_snprintf(buf, sizeof(buf), "%d", i); + path = gtk_tree_path_new_from_string(buf); +#endif + tmp = gtk_cell_view_menu_item_new_from_model (combo_box->priv->model, + path); + g_signal_connect (tmp, "activate", + G_CALLBACK (gtk_combo_box_menu_item_activate), + combo_box); + + cell_view_sync_cells (combo_box, + GTK_CELL_VIEW (GTK_BIN (tmp)->child)); + + gtk_menu_shell_append (GTK_MENU_SHELL (menu), tmp); + + if (combo_box->priv->wrap_width) + gtk_combo_box_relayout_item (combo_box, i); + + gtk_widget_show (tmp); + + gtk_tree_path_free (path); + } +} + +static void +gtk_combo_box_menu_destroy (GtkComboBox *combo_box) +{ + g_signal_handlers_disconnect_matched (combo_box->priv->button, + G_SIGNAL_MATCH_DATA, + 0, 0, NULL, + gtk_combo_box_menu_button_press, NULL); + + /* unparent will remove our latest ref */ + gtk_widget_unparent (combo_box->priv->button); + + combo_box->priv->box = NULL; + combo_box->priv->button = NULL; + combo_box->priv->arrow = NULL; + combo_box->priv->separator = NULL; + + /* changing the popup window will unref the menu and the children */ +} + +/* + * grid + */ + +static void +gtk_combo_box_item_get_size (GtkComboBox *combo_box, + gint index_, + gint *cols, + gint *rows) +{ + GtkTreeIter iter; + + gtk_tree_model_iter_nth_child (combo_box->priv->model, &iter, NULL, index_); + + if (cols) + { + if (combo_box->priv->col_column == -1) + *cols = 1; + else + gtk_tree_model_get (combo_box->priv->model, &iter, + combo_box->priv->col_column, cols, + -1); + } + + if (rows) + { + if (combo_box->priv->row_column == -1) + *rows = 1; + else + gtk_tree_model_get (combo_box->priv->model, &iter, + combo_box->priv->row_column, rows, + -1); + } +} + +static gboolean +menu_occupied (GtkMenu *menu, + guint left_attach, + guint right_attach, + guint top_attach, + guint bottom_attach) +{ + GList *i; + + g_return_val_if_fail (GTK_IS_MENU (menu), TRUE); + g_return_val_if_fail (left_attach < right_attach, TRUE); + g_return_val_if_fail (top_attach < bottom_attach, TRUE); + + for (i = GTK_MENU_SHELL (menu)->children; i; i = i->next) + { + guint l, r, b, t; + gboolean h_intersect = FALSE; + gboolean v_intersect = FALSE; + + gtk_container_child_get (GTK_CONTAINER (menu), i->data, + "left_attach", &l, + "right_attach", &r, + "bottom_attach", &b, + "top_attach", &t, + NULL); + + /* look if this item intersects with the given coordinates */ + h_intersect = left_attach <= l && l <= right_attach; + h_intersect &= left_attach <= r && r <= right_attach; + + v_intersect = top_attach <= t && t <= bottom_attach; + v_intersect &= top_attach <= b && b <= bottom_attach; + + if (h_intersect && v_intersect) + return TRUE; + } + + return FALSE; +} + +static void +gtk_combo_box_relayout_item (GtkComboBox *combo_box, + gint index) +{ + gint current_col = 0, current_row = 0; + gint rows, cols; + GList *list, *nth; + GtkWidget *item, *last; + GtkWidget *menu; + + menu = combo_box->priv->popup_widget; + if (!GTK_IS_MENU_SHELL (menu)) + return; + + list = gtk_container_get_children (GTK_CONTAINER (menu)); + nth = g_list_nth (list, index); + item = nth->data; + if (nth->prev) + last = nth->prev->data; + else + last = NULL; + g_list_free (list); + + gtk_combo_box_item_get_size (combo_box, index, &cols, &rows); + + if (combo_box->priv->col_column == -1 && + combo_box->priv->row_column == -1 && + last) + { + gtk_container_child_get (GTK_CONTAINER (menu), + last, + "right_attach", ¤t_col, + "top_attach", ¤t_row, + NULL); + if (current_col + cols > combo_box->priv->wrap_width) + { + current_col = 0; + current_row++; + } + } + else + { + /* look for a good spot */ + while (1) + { + if (current_col + cols > combo_box->priv->wrap_width) + { + current_col = 0; + current_row++; + } + + if (!menu_occupied (GTK_MENU (menu), + current_col, current_col + cols, + current_row, current_row + rows)) + break; + + current_col++; + } + } + + /* set attach props */ + gtk_menu_attach (GTK_MENU (menu), item, + current_col, current_col + cols, + current_row, current_row + rows); +} + +static void +gtk_combo_box_relayout (GtkComboBox *combo_box) +{ + GList *list, *j; + GtkWidget *menu; + + menu = combo_box->priv->popup_widget; + + /* do nothing unless we are in menu style and realized */ + if (combo_box->priv->tree_view || !GTK_IS_MENU_SHELL (menu)) + return; + + /* get rid of all children */ + list = gtk_container_get_children (GTK_CONTAINER (menu)); + + for (j = g_list_last (list); j; j = j->prev) + gtk_container_remove (GTK_CONTAINER (menu), j->data); + + g_list_free (list); + + /* and relayout */ + gtk_combo_box_menu_fill (combo_box); +} + +/* callbacks */ +static gboolean +gtk_combo_box_menu_button_press (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); + + if (! GTK_IS_MENU (combo_box->priv->popup_widget)) + return FALSE; + + if (event->type == GDK_BUTTON_PRESS && event->button == 1) + { + combo_box->priv->popup_in_progress = TRUE; + + gtk_menu_set_active (GTK_MENU (combo_box->priv->popup_widget), + combo_box->priv->active_item); + + if (combo_box->priv->wrap_width == 0) + { + GtkRequisition requisition; + gint width; + + width = GTK_WIDGET (combo_box)->allocation.width; + gtk_widget_size_request (combo_box->priv->popup_widget, &requisition); + + gtk_widget_set_size_request (combo_box->priv->popup_widget, + MAX (width, requisition.width), -1); + } + + gtk_menu_popup (GTK_MENU (combo_box->priv->popup_widget), + NULL, NULL, +#if GTK_CHECK_VERSION(2,2,0) + gtk_combo_box_menu_position, +#else + NULL, +#endif + combo_box, event->button, event->time); + + return TRUE; + } + + return FALSE; +} + +static void +gtk_combo_box_menu_item_activate (GtkWidget *item, + gpointer user_data) +{ + gint index; + GtkWidget *menu; + GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); + + menu = combo_box->priv->popup_widget; + g_return_if_fail (GTK_IS_MENU (menu)); + + index = g_list_index (GTK_MENU_SHELL (menu)->children, item); + + gtk_combo_box_set_active (combo_box, index); +} + +static void +gtk_combo_box_model_row_inserted (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer user_data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); + gint index = gtk_tree_path_get_indices (path)[0]; + + if (combo_box->priv->active_item >= index) + combo_box->priv->active_item++; + + if (!combo_box->priv->tree_view) + gtk_combo_box_menu_row_inserted (model, path, iter, user_data); +} + +static void +gtk_combo_box_model_row_deleted (GtkTreeModel *model, + GtkTreePath *path, + gpointer user_data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); + gint index = gtk_tree_path_get_indices (path)[0]; + + if (!combo_box->priv->tree_view) + gtk_combo_box_menu_row_deleted (model, path, user_data); + + if (index == combo_box->priv->active_item) + { + gint items = gtk_tree_model_iter_n_children (model, NULL); + + if (items == 0) + gtk_combo_box_set_active_internal (combo_box, -1); + else if (index == items) + gtk_combo_box_set_active_internal (combo_box, index - 1); + else + gtk_combo_box_set_active_internal (combo_box, index); + } + else if (combo_box->priv->active_item > index) + combo_box->priv->active_item--; +} + +static void +gtk_combo_box_model_rows_reordered (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gint *new_order, + gpointer user_data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); + gint items = gtk_tree_model_iter_n_children (model, NULL); + gint i; + + for (i = 0; i < items; i++) + if (new_order[i] == combo_box->priv->active_item) + { + combo_box->priv->active_item = i; + break; + } + + if (!combo_box->priv->tree_view) + gtk_combo_box_menu_rows_reordered (model, path, iter, new_order, user_data); +} + +static void +gtk_combo_box_model_row_changed (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer user_data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); + gint index = gtk_tree_path_get_indices (path)[0]; + + if (index == combo_box->priv->active_item && + combo_box->priv->cell_view) + gtk_widget_queue_resize (GTK_WIDGET (combo_box->priv->cell_view)); + + if (combo_box->priv->tree_view) + gtk_combo_box_list_row_changed (model, path, iter, user_data); + else + gtk_combo_box_menu_row_changed (model, path, iter, user_data); +} + + +static void +gtk_combo_box_menu_row_inserted (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer user_data) +{ + GtkWidget *menu; + GtkWidget *item; + GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); + + if (!combo_box->priv->popup_widget) + return; + + menu = combo_box->priv->popup_widget; + g_return_if_fail (GTK_IS_MENU (menu)); + + item = gtk_cell_view_menu_item_new_from_model (model, path); + g_signal_connect (item, "activate", + G_CALLBACK (gtk_combo_box_menu_item_activate), + combo_box); + + cell_view_sync_cells (combo_box, GTK_CELL_VIEW (GTK_BIN (item)->child)); + + gtk_menu_shell_insert (GTK_MENU_SHELL (menu), item, + gtk_tree_path_get_indices (path)[0]); + gtk_widget_show (item); +} + +static void +gtk_combo_box_menu_row_deleted (GtkTreeModel *model, + GtkTreePath *path, + gpointer user_data) +{ + gint index; + GtkWidget *menu; + GtkWidget *item; + GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); + + if (!combo_box->priv->popup_widget) + return; + + index = gtk_tree_path_get_indices (path)[0]; + + menu = combo_box->priv->popup_widget; + g_return_if_fail (GTK_IS_MENU (menu)); + + item = g_list_nth_data (GTK_MENU_SHELL (menu)->children, index); + g_return_if_fail (GTK_IS_MENU_ITEM (item)); + + gtk_container_remove (GTK_CONTAINER (menu), item); +} + +static void +gtk_combo_box_menu_rows_reordered (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gint *new_order, + gpointer user_data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); + + gtk_combo_box_relayout (combo_box); +} + +static void +gtk_combo_box_menu_row_changed (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer user_data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); + gint width; + + if (!combo_box->priv->popup_widget) + return; + + if (combo_box->priv->wrap_width) + gtk_combo_box_relayout_item (combo_box, + gtk_tree_path_get_indices (path)[0]); + + width = gtk_combo_box_calc_requested_width (combo_box, path); + + if (width > combo_box->priv->width) + { + if (combo_box->priv->cell_view) + { + gtk_widget_set_size_request (combo_box->priv->cell_view, width, -1); + gtk_widget_queue_resize (combo_box->priv->cell_view); + } + combo_box->priv->width = width; + } +} + +/* + * list style + */ + +static void +gtk_combo_box_list_setup (GtkComboBox *combo_box) +{ + GSList *i; + GtkTreeSelection *sel; + + combo_box->priv->button = gtk_toggle_button_new (); + gtk_widget_set_parent (combo_box->priv->button, + GTK_BIN (combo_box)->child->parent); + g_signal_connect (combo_box->priv->button, "button_press_event", + G_CALLBACK (gtk_combo_box_list_button_pressed), combo_box); + g_signal_connect (combo_box->priv->button, "toggled", + G_CALLBACK (gtk_combo_box_button_toggled), combo_box); + g_signal_connect_after (combo_box, "key_press_event", + G_CALLBACK (gtk_combo_box_key_press), combo_box); + + combo_box->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); + gtk_container_add (GTK_CONTAINER (combo_box->priv->button), + combo_box->priv->arrow); + combo_box->priv->separator = NULL; + gtk_widget_show_all (combo_box->priv->button); + + if (combo_box->priv->cell_view) + { + combo_box->priv->cell_view_frame = gtk_frame_new (NULL); + gtk_widget_set_parent (combo_box->priv->cell_view_frame, + GTK_BIN (combo_box)->child->parent); + gtk_frame_set_shadow_type (GTK_FRAME (combo_box->priv->cell_view_frame), + GTK_SHADOW_IN); + + gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view), + >K_WIDGET (combo_box)->style->base[GTK_WIDGET_STATE (combo_box)]); + + combo_box->priv->box = gtk_event_box_new (); + /* + gtk_event_box_set_visible_window (GTK_EVENT_BOX (combo_box->priv->box), + FALSE); + */ + + gtk_container_add (GTK_CONTAINER (combo_box->priv->cell_view_frame), + combo_box->priv->box); + + gtk_widget_show_all (combo_box->priv->cell_view_frame); + + g_signal_connect (combo_box->priv->box, "button_press_event", + G_CALLBACK (gtk_combo_box_list_button_pressed), + combo_box); + } + + combo_box->priv->tree_view = gtk_tree_view_new (); + sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view)); + gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE); + gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (combo_box->priv->tree_view), + FALSE); + /* + _gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (combo_box->priv->tree_view), + TRUE); + */ + if (combo_box->priv->model) + gtk_tree_view_set_model (GTK_TREE_VIEW (combo_box->priv->tree_view), + combo_box->priv->model); + + g_signal_connect (combo_box->priv->tree_view, "button_press_event", + G_CALLBACK (gtk_combo_box_list_button_pressed), + combo_box); + g_signal_connect (combo_box->priv->tree_view, "button_release_event", + G_CALLBACK (gtk_combo_box_list_button_released), + combo_box); + g_signal_connect (combo_box->priv->tree_view, "key_press_event", + G_CALLBACK (gtk_combo_box_list_key_press), + combo_box); + + combo_box->priv->column = gtk_tree_view_column_new (); + gtk_tree_view_append_column (GTK_TREE_VIEW (combo_box->priv->tree_view), + combo_box->priv->column); + + /* sync up */ + for (i = combo_box->priv->cells; i; i = i->next) + { + GSList *j; + ComboCellInfo *info = (ComboCellInfo *)i->data; + + if (info->pack == GTK_PACK_START) + gtk_tree_view_column_pack_start (combo_box->priv->column, + info->cell, info->expand); + else if (info->pack == GTK_PACK_END) + gtk_tree_view_column_pack_end (combo_box->priv->column, + info->cell, info->expand); + + for (j = info->attributes; j; j = j->next->next) + { + gtk_tree_view_column_add_attribute (combo_box->priv->column, + info->cell, + j->data, + GPOINTER_TO_INT (j->next->data)); + } + } + + if (combo_box->priv->active_item != -1) + { + GtkTreePath *path; + +#if GTK_CHECK_VERSION(2,2,0) + path = gtk_tree_path_new_from_indices (combo_box->priv->active_item, -1); +#else + char buf[32]; + g_snprintf(buf, sizeof(buf), "%d", combo_box->priv->active_item); + path = gtk_tree_path_new_from_string(buf); +#endif + if (path) + { + gtk_tree_view_set_cursor (GTK_TREE_VIEW (combo_box->priv->tree_view), + path, NULL, FALSE); + gtk_tree_path_free (path); + } + } + + /* set sample/popup widgets */ + gtk_combo_box_set_popup_widget (combo_box, combo_box->priv->tree_view); + + gtk_widget_show (combo_box->priv->tree_view); +} + +static void +gtk_combo_box_list_destroy (GtkComboBox *combo_box) +{ + /* disconnect signals */ + g_signal_handlers_disconnect_matched (combo_box->priv->tree_view, + G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, combo_box); + g_signal_handlers_disconnect_matched (combo_box->priv->button, + G_SIGNAL_MATCH_DATA, + 0, 0, NULL, + gtk_combo_box_list_button_pressed, + NULL); + if (combo_box->priv->box) + g_signal_handlers_disconnect_matched (combo_box->priv->box, + G_SIGNAL_MATCH_DATA, + 0, 0, NULL, + gtk_combo_box_list_button_pressed, + NULL); + + /* destroy things (unparent will kill the latest ref from us) + * last unref on button will destroy the arrow + */ + gtk_widget_unparent (combo_box->priv->button); + combo_box->priv->button = NULL; + combo_box->priv->arrow = NULL; + + if (combo_box->priv->cell_view) + { + g_object_set (G_OBJECT (combo_box->priv->cell_view), + "background_set", FALSE, + NULL); + } + + if (combo_box->priv->cell_view_frame) + { + gtk_widget_unparent (combo_box->priv->cell_view_frame); + combo_box->priv->cell_view_frame = NULL; + combo_box->priv->box = NULL; + } + + gtk_widget_destroy (combo_box->priv->tree_view); + + combo_box->priv->tree_view = NULL; + combo_box->priv->popup_widget = NULL; +} + +/* callbacks */ +static void +gtk_combo_box_list_remove_grabs (GtkComboBox *combo_box) +{ + if (combo_box->priv->tree_view && + GTK_WIDGET_HAS_GRAB (combo_box->priv->tree_view)) + { + gtk_grab_remove (combo_box->priv->tree_view); + } + + if (combo_box->priv->popup_window && + GTK_WIDGET_HAS_GRAB (combo_box->priv->popup_window)) + { + gtk_grab_remove (combo_box->priv->popup_window); + gdk_keyboard_ungrab (GDK_CURRENT_TIME); + gdk_pointer_ungrab (GDK_CURRENT_TIME); + } +} + +static gboolean +gtk_combo_box_list_button_pressed (GtkWidget *widget, + GdkEventButton *event, + gpointer data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (data); + + GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event); + + if (ewidget == combo_box->priv->tree_view) + return TRUE; + + if ((ewidget != combo_box->priv->button && ewidget != combo_box->priv->box) || + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (combo_box->priv->button))) + return FALSE; + + gtk_combo_box_popup (combo_box); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button), + TRUE); + + combo_box->priv->popup_in_progress = TRUE; + + return TRUE; +} + +static gboolean +gtk_combo_box_list_button_released (GtkWidget *widget, + GdkEventButton *event, + gpointer data) +{ + gboolean ret; + GtkTreePath *path = NULL; + + GtkComboBox *combo_box = GTK_COMBO_BOX (data); + + gboolean popup_in_progress = FALSE; + + GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event); + + if (combo_box->priv->popup_in_progress) + { + popup_in_progress = TRUE; + combo_box->priv->popup_in_progress = FALSE; + } + + if (ewidget != combo_box->priv->tree_view) + { + if (ewidget == combo_box->priv->button && + !popup_in_progress && + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (combo_box->priv->button))) + { + gtk_combo_box_popdown (combo_box); + return TRUE; + } + + /* released outside treeview */ + if (ewidget != combo_box->priv->button) + { + gtk_combo_box_popdown (combo_box); + + return TRUE; + } + + return FALSE; + } + + /* select something cool */ + ret = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), + event->x, event->y, + &path, + NULL, NULL, NULL); + + if (!ret) + return TRUE; /* clicked outside window? */ + + gtk_combo_box_set_active (combo_box, gtk_tree_path_get_indices (path)[0]); + gtk_combo_box_popdown (combo_box); + + gtk_tree_path_free (path); + + return TRUE; +} + +static gboolean +gtk_combo_box_key_press (GtkWidget *widget, + GdkEventKey *event, + gpointer data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (data); + guint state = event->state & gtk_accelerator_get_default_mod_mask (); + gint items = 0; + gint index = gtk_combo_box_get_active (combo_box); + gint new_index; + + if (combo_box->priv->model) + items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL); + + if ((event->keyval == GDK_Down || event->keyval == GDK_KP_Down) && + state == GDK_MOD1_MASK) + { + gtk_combo_box_popup (combo_box); + + return TRUE; + } + + switch (event->keyval) + { + case GDK_Down: + case GDK_KP_Down: + new_index = index + 1; + break; + case GDK_Up: + case GDK_KP_Up: + new_index = index - 1; + break; + case GDK_Page_Up: + case GDK_KP_Page_Up: + case GDK_Home: + case GDK_KP_Home: + new_index = 0; + break; + case GDK_Page_Down: + case GDK_KP_Page_Down: + case GDK_End: + case GDK_KP_End: + new_index = items - 1; + break; + default: + return FALSE; + } + + if (items > 0) + gtk_combo_box_set_active (combo_box, CLAMP (new_index, 0, items - 1)); + + return TRUE; +} + +static gboolean +gtk_combo_box_menu_key_press (GtkWidget *widget, + GdkEventKey *event, + gpointer data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (data); + guint state = event->state & gtk_accelerator_get_default_mod_mask (); + + if ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) && + state == GDK_MOD1_MASK) + { + gtk_combo_box_popdown (combo_box); + + return TRUE; + } + + return FALSE; +} + +static gboolean +gtk_combo_box_list_key_press (GtkWidget *widget, + GdkEventKey *event, + gpointer data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (data); + guint state = event->state & gtk_accelerator_get_default_mod_mask (); + + if (event->keyval == GDK_Escape || + ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) && + state == GDK_MOD1_MASK)) + { + /* reset active item -- this is incredibly lame and ugly */ + gtk_combo_box_set_active (combo_box, + gtk_combo_box_get_active (combo_box)); + + gtk_combo_box_popdown (combo_box); + + return TRUE; + } + + if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter || + event->keyval == GDK_space || event->keyval == GDK_KP_Space) + { + gboolean ret = FALSE; + GtkTreeIter iter; + GtkTreeModel *model = NULL; + + if (combo_box->priv->model) + { + GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view)); + + ret = gtk_tree_selection_get_selected (sel, &model, &iter); + } + if (ret) + { + GtkTreePath *path; + + path = gtk_tree_model_get_path (model, &iter); + if (path) + { + gtk_combo_box_set_active (combo_box, gtk_tree_path_get_indices (path)[0]); + gtk_tree_path_free (path); + } + } + + gtk_combo_box_popdown (combo_box); + + return TRUE; + } + + return FALSE; +} + +static void +gtk_combo_box_list_row_changed (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (data); + gint width; + + width = gtk_combo_box_calc_requested_width (combo_box, path); + + if (width > combo_box->priv->width) + { + if (combo_box->priv->cell_view) + { + gtk_widget_set_size_request (combo_box->priv->cell_view, width, -1); + gtk_widget_queue_resize (combo_box->priv->cell_view); + } + combo_box->priv->width = width; + } +} + +/* + * GtkCellLayout implementation + */ +static void +gtk_combo_box_cell_layout_pack_start (GtkCellLayout *layout, + GtkCellRenderer *cell, + gboolean expand) +{ + ComboCellInfo *info; + GtkComboBox *combo_box; + GtkWidget *menu; + + g_return_if_fail (GTK_IS_COMBO_BOX (layout)); + g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); + + combo_box = GTK_COMBO_BOX (layout); + + g_object_ref (G_OBJECT (cell)); + gtk_object_sink (GTK_OBJECT (cell)); + + info = g_new0 (ComboCellInfo, 1); + info->cell = cell; + info->expand = expand; + info->pack = GTK_PACK_START; + + combo_box->priv->cells = g_slist_append (combo_box->priv->cells, info); + + if (combo_box->priv->cell_view) + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box->priv->cell_view), + cell, expand); + + if (combo_box->priv->column) + gtk_tree_view_column_pack_start (combo_box->priv->column, cell, expand); + + menu = combo_box->priv->popup_widget; + if (GTK_IS_MENU (menu)) + { + GList *i, *list; + + list = gtk_container_get_children (GTK_CONTAINER (menu)); + for (i = list; i; i = i->next) + { + GtkCellView *view; + + if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) + view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); + else + view = GTK_CELL_VIEW (i->data); + + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (view), cell, expand); + } + g_list_free (list); + } +} + +static void +gtk_combo_box_cell_layout_pack_end (GtkCellLayout *layout, + GtkCellRenderer *cell, + gboolean expand) +{ + ComboCellInfo *info; + GtkComboBox *combo_box; + GtkWidget *menu; + + g_return_if_fail (GTK_IS_COMBO_BOX (layout)); + g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); + + combo_box = GTK_COMBO_BOX (layout); + + g_object_ref (G_OBJECT (cell)); + gtk_object_sink (GTK_OBJECT (cell)); + + info = g_new0 (ComboCellInfo, 1); + info->cell = cell; + info->expand = expand; + info->pack = GTK_PACK_END; + + combo_box->priv->cells = g_slist_append (combo_box->priv->cells, info); + + if (combo_box->priv->cell_view) + gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (combo_box->priv->cell_view), + cell, expand); + + if (combo_box->priv->column) + gtk_tree_view_column_pack_end (combo_box->priv->column, cell, expand); + + menu = combo_box->priv->popup_widget; + if (GTK_IS_MENU (menu)) + { + GList *i, *list; + + list = gtk_container_get_children (GTK_CONTAINER (menu)); + for (i = list; i; i = i->next) + { + GtkCellView *view; + + if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) + view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); + else + view = GTK_CELL_VIEW (i->data); + + gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (view), cell, expand); + } + g_list_free (list); + } +} + +static void +gtk_combo_box_cell_layout_clear (GtkCellLayout *layout) +{ + GtkWidget *menu; + GtkComboBox *combo_box; + GSList *i; + + g_return_if_fail (GTK_IS_COMBO_BOX (layout)); + + combo_box = GTK_COMBO_BOX (layout); + + if (combo_box->priv->cell_view) + gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_box->priv->cell_view)); + + if (combo_box->priv->column) + gtk_tree_view_column_clear (combo_box->priv->column); + + for (i = combo_box->priv->cells; i; i = i->next) + { + ComboCellInfo *info = (ComboCellInfo *)i->data; + + gtk_combo_box_cell_layout_clear_attributes (layout, info->cell); + g_object_unref (G_OBJECT (info->cell)); + g_free (info); + i->data = NULL; + } + g_slist_free (combo_box->priv->cells); + combo_box->priv->cells = NULL; + + menu = combo_box->priv->popup_widget; + if (GTK_IS_MENU (menu)) + { + GList *i, *list; + + list = gtk_container_get_children (GTK_CONTAINER (menu)); + for (i = list; i; i = i->next) + { + GtkCellView *view; + + if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) + view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); + else + view = GTK_CELL_VIEW (i->data); + + gtk_cell_layout_clear (GTK_CELL_LAYOUT (view)); + } + g_list_free (list); + } +} + +static void +gtk_combo_box_cell_layout_add_attribute (GtkCellLayout *layout, + GtkCellRenderer *cell, + const gchar *attribute, + gint column) +{ + ComboCellInfo *info; + GtkComboBox *combo_box; + GtkWidget *menu; + + g_return_if_fail (GTK_IS_COMBO_BOX (layout)); + g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); + + combo_box = GTK_COMBO_BOX (layout); + + info = gtk_combo_box_get_cell_info (combo_box, cell); + + info->attributes = g_slist_prepend (info->attributes, + GINT_TO_POINTER (column)); + info->attributes = g_slist_prepend (info->attributes, + g_strdup (attribute)); + + if (combo_box->priv->cell_view) + gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_box->priv->cell_view), + cell, attribute, column); + + if (combo_box->priv->column) + gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_box->priv->column), + cell, attribute, column); + + menu = combo_box->priv->popup_widget; + if (GTK_IS_MENU (menu)) + { + GList *i, *list; + + list = gtk_container_get_children (GTK_CONTAINER (menu)); + for (i = list; i; i = i->next) + { + GtkCellView *view; + + if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) + view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); + else + view = GTK_CELL_VIEW (i->data); + + gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (view), cell, + attribute, column); + } + g_list_free (list); + } + + gtk_widget_queue_resize (GTK_WIDGET (combo_box)); +} + +static void +gtk_combo_box_cell_layout_set_cell_data_func (GtkCellLayout *layout, + GtkCellRenderer *cell, + GtkCellLayoutDataFunc func, + gpointer func_data, + GDestroyNotify destroy) +{ + ComboCellInfo *info; + GtkComboBox *combo_box; + GtkWidget *menu; + + g_return_if_fail (GTK_IS_COMBO_BOX (layout)); + + combo_box = GTK_COMBO_BOX (layout); + + info = gtk_combo_box_get_cell_info (combo_box, cell); + g_return_if_fail (info != NULL); + + if (info->destroy) + { + GDestroyNotify d = info->destroy; + + info->destroy = NULL; + d (info->func_data); + } + + info->func = func; + info->func_data = func_data; + info->destroy = destroy; + + if (combo_box->priv->cell_view) + gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo_box->priv->cell_view), cell, func, func_data, NULL); + + if (combo_box->priv->column) + gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo_box->priv->column), cell, func, func_data, NULL); + + menu = combo_box->priv->popup_widget; + if (GTK_IS_MENU (menu)) + { + GList *i, *list; + + list = gtk_container_get_children (GTK_CONTAINER (menu)); + for (i = list; i; i = i->next) + { + GtkCellView *view; + + if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) + view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); + else + view = GTK_CELL_VIEW (i->data); + + gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (view), cell, + func, func_data, NULL); + } + g_list_free (list); + } + + gtk_widget_queue_resize (GTK_WIDGET (combo_box)); +} + +static void +gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout *layout, + GtkCellRenderer *cell) +{ + ComboCellInfo *info; + GtkComboBox *combo_box; + GtkWidget *menu; + GSList *list; + + g_return_if_fail (GTK_IS_COMBO_BOX (layout)); + g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); + + combo_box = GTK_COMBO_BOX (layout); + + info = gtk_combo_box_get_cell_info (combo_box, cell); + if (info) + { + list = info->attributes; + while (list && list->next) + { + g_free (list->data); + list = list->next->next; + } + g_slist_free (info->attributes); + info->attributes = NULL; + } + + if (combo_box->priv->cell_view) + gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (combo_box->priv->cell_view), cell); + + if (combo_box->priv->column) + gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (combo_box->priv->column), cell); + + menu = combo_box->priv->popup_widget; + if (GTK_IS_MENU (menu)) + { + GList *i, *list; + + list = gtk_container_get_children (GTK_CONTAINER (menu)); + for (i = list; i; i = i->next) + { + GtkCellView *view; + + if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) + view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); + else + view = GTK_CELL_VIEW (i->data); + + gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (view), cell); + } + g_list_free (list); + } + + gtk_widget_queue_resize (GTK_WIDGET (combo_box)); +} + +static void +gtk_combo_box_cell_layout_reorder (GtkCellLayout *layout, + GtkCellRenderer *cell, + gint position) +{ + ComboCellInfo *info; + GtkComboBox *combo_box; + GtkWidget *menu; + GSList *link; + + g_return_if_fail (GTK_IS_COMBO_BOX (layout)); + g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); + + combo_box = GTK_COMBO_BOX (layout); + + info = gtk_combo_box_get_cell_info (combo_box, cell); + + g_return_if_fail (info != NULL); + g_return_if_fail (position >= 0); + + link = g_slist_find (combo_box->priv->cells, info); + + g_return_if_fail (link != NULL); + + combo_box->priv->cells = g_slist_remove_link (combo_box->priv->cells, link); + combo_box->priv->cells = g_slist_insert (combo_box->priv->cells, info, + position); + + if (combo_box->priv->cell_view) + gtk_cell_layout_reorder (GTK_CELL_LAYOUT (combo_box->priv->cell_view), + cell, position); + + if (combo_box->priv->column) + gtk_cell_layout_reorder (GTK_CELL_LAYOUT (combo_box->priv->column), + cell, position); + + menu = combo_box->priv->popup_widget; + if (GTK_IS_MENU (menu)) + { + GList *i, *list; + + list = gtk_container_get_children (GTK_CONTAINER (menu)); + for (i = list; i; i = i->next) + { + GtkCellView *view; + + if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) + view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); + else + view = GTK_CELL_VIEW (i->data); + + gtk_cell_layout_reorder (GTK_CELL_LAYOUT (view), cell, position); + } + g_list_free (list); + } + + gtk_widget_queue_draw (GTK_WIDGET (combo_box)); +} + +/* + * public API + */ + +/** + * gtk_combo_box_new: + * + * Creates a new empty #GtkComboBox. + * + * Return value: A new #GtkComboBox. + * + * Since: 2.4 + */ +GtkWidget * +gtk_combo_box_new (void) +{ + return GTK_WIDGET (g_object_new (GTK_TYPE_COMBO_BOX, NULL)); +} + +/** + * gtk_combo_box_new_with_model: + * @model: A #GtkTreeModel. + * + * Creates a new #GtkComboBox with the model initialized to @model. + * + * Return value: A new #GtkComboBox. + * + * Since: 2.4 + */ +GtkWidget * +gtk_combo_box_new_with_model (GtkTreeModel *model) +{ + GtkComboBox *combo_box; + + g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL); + + combo_box = GTK_COMBO_BOX (g_object_new (GTK_TYPE_COMBO_BOX, + "model", model, + NULL)); + + return GTK_WIDGET (combo_box); +} + +/** + * gtk_combo_box_set_wrap_width: + * @combo_box: A #GtkComboBox. + * @width: Preferred number of columns. + * + * Sets the wrap width of @combo_box to be @width. The wrap width is basically + * the preferred number of columns when you want to the popup to be layed out + * in a table. + * + * Since: 2.4 + */ +void +gtk_combo_box_set_wrap_width (GtkComboBox *combo_box, + gint width) +{ + g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); + g_return_if_fail (width >= 0); + + if (width != combo_box->priv->wrap_width) + { + combo_box->priv->wrap_width = width; + + gtk_combo_box_check_appearance (combo_box); + gtk_combo_box_relayout (combo_box); + + g_object_notify (G_OBJECT (combo_box), "wrap_width"); + } +} + +/** + * gtk_combo_box_set_row_span_column: + * @combo_box: A #GtkComboBox. + * @row_span: A column in the model passed during construction. + * + * Sets the column with row span information for @combo_box to be @row_span. + * The row span column contains integers which indicate how many rows + * an item should span. + * + * Since: 2.4 + */ +void +gtk_combo_box_set_row_span_column (GtkComboBox *combo_box, + gint row_span) +{ + gint col; + + g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); + + col = gtk_tree_model_get_n_columns (combo_box->priv->model); + g_return_if_fail (row_span >= 0 && row_span < col); + + if (row_span != combo_box->priv->row_column) + { + combo_box->priv->row_column = row_span; + + gtk_combo_box_relayout (combo_box); + + g_object_notify (G_OBJECT (combo_box), "row_span_column"); + } +} + +/** + * gtk_combo_box_set_column_span_column: + * @combo_box: A #GtkComboBox. + * @column_span: A column in the model passed during construction. + * + * Sets the column with column span information for @combo_box to be + * @column_span. The column span column contains integers which indicate + * how many columns an item should span. + * + * Since: 2.4 + */ +void +gtk_combo_box_set_column_span_column (GtkComboBox *combo_box, + gint column_span) +{ + gint col; + + g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); + + col = gtk_tree_model_get_n_columns (combo_box->priv->model); + g_return_if_fail (column_span >= 0 && column_span < col); + + if (column_span != combo_box->priv->col_column) + { + combo_box->priv->col_column = column_span; + + gtk_combo_box_relayout (combo_box); + + g_object_notify (G_OBJECT (combo_box), "column_span_column"); + } +} + +/** + * gtk_combo_box_get_active: + * @combo_box: A #GtkComboBox. + * + * Returns the index of the currently active item, or -1 if there's no + * active item. + * + * Return value: An integer which is the index of the currently active item, or + * -1 if there's no active item. + * + * Since: 2.4 + */ +gint +gtk_combo_box_get_active (GtkComboBox *combo_box) +{ + g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), 0); + + return combo_box->priv->active_item; +} + +/** + * gtk_combo_box_set_active: + * @combo_box: A #GtkComboBox. + * @index_: An index in the model passed during construction, or -1 to have + * no active item. + * + * Sets the active item of @combo_box to be the item at @index. + * + * Since: 2.4 + */ +void +gtk_combo_box_set_active (GtkComboBox *combo_box, + gint index_) +{ + g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); + /* -1 means "no item selected" */ + g_return_if_fail (index_ >= -1); + + if (combo_box->priv->active_item == index_) + return; + + gtk_combo_box_set_active_internal (combo_box, index_); +} + +static void +gtk_combo_box_set_active_internal (GtkComboBox *combo_box, + gint index) +{ + GtkTreePath *path; + + combo_box->priv->active_item = index; + + if (index == -1) + { + if (combo_box->priv->tree_view) + gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view))); + else + { + GtkMenu *menu = GTK_MENU (combo_box->priv->popup_widget); + + if (GTK_IS_MENU (menu)) + gtk_menu_set_active (menu, -1); + } + + if (combo_box->priv->cell_view) + gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (combo_box->priv->cell_view), NULL); + } + else + { +#if GTK_CHECK_VERSION(2,2,0) + path = gtk_tree_path_new_from_indices (index, -1); +#else + char buf[32]; + g_snprintf(buf, sizeof(buf), "%d", index); + path = gtk_tree_path_new_from_string(buf); +#endif + + if (combo_box->priv->tree_view) + gtk_tree_view_set_cursor (GTK_TREE_VIEW (combo_box->priv->tree_view), path, NULL, FALSE); + else + { + GtkMenu *menu = GTK_MENU (combo_box->priv->popup_widget); + + if (GTK_IS_MENU (menu)) + gtk_menu_set_active (GTK_MENU (menu), index); + } + + if (combo_box->priv->cell_view) + gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (combo_box->priv->cell_view), path); + + gtk_tree_path_free (path); + } + + g_signal_emit_by_name (combo_box, "changed", NULL, NULL); +} + + +/** + * gtk_combo_box_get_active_iter: + * @combo_box: A #GtkComboBox + * @iter: The uninitialized #GtkTreeIter. + * + * Sets @iter to point to the current active item, if it exists. + * + * Return value: %TRUE, if @iter was set + * + * Since: 2.4 + **/ +gboolean +gtk_combo_box_get_active_iter (GtkComboBox *combo_box, + GtkTreeIter *iter) +{ + GtkTreePath *path; + gint active; + gboolean retval; +#if !GTK_CHECK_VERSION(2,2,0) + char buf[32]; +#endif + + g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE); + + active = gtk_combo_box_get_active (combo_box); + if (active < 0) + return FALSE; + +#if GTK_CHECK_VERSION(2,2,0) + path = gtk_tree_path_new_from_indices (active, -1); +#else + g_snprintf(buf, sizeof(buf), "%d", active); + path = gtk_tree_path_new_from_string(buf); +#endif + retval = gtk_tree_model_get_iter (gtk_combo_box_get_model (combo_box), + iter, path); + gtk_tree_path_free (path); + + return retval; +} + +/** + * gtk_combo_box_set_active_iter: + * @combo_box: A #GtkComboBox + * @iter: The #GtkTreeIter. + * + * Sets the current active item to be the one referenced by @iter. + * @iter must correspond to a path of depth one. + * + * Since: 2.4 + **/ +void +gtk_combo_box_set_active_iter (GtkComboBox *combo_box, + GtkTreeIter *iter) +{ + GtkTreePath *path; + + g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); + + path = gtk_tree_model_get_path (gtk_combo_box_get_model (combo_box), iter); + g_return_if_fail (path != NULL); + g_return_if_fail (gtk_tree_path_get_depth (path) == 1); + + gtk_combo_box_set_active (combo_box, gtk_tree_path_get_indices (path)[0]); + gtk_tree_path_free (path); +} + +/** + * gtk_combo_box_set_model: + * @combo_box: A #GtkComboBox. + * @model: A #GtkTreeModel. + * + * Sets the model used by @combo_box to be @model. Will unset a previously set + * model (if applicable). If @model is %NULL, then it will unset the model. + * + * Note that this function does not clear the cell renderers, you have to + * call gtk_combo_box_cell_layout_clear() yourself if you need to set up + * different cell renderers for the new model. + * + * Since: 2.4 + */ +void +gtk_combo_box_set_model (GtkComboBox *combo_box, + GtkTreeModel *model) +{ + g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); + + if (!model) + { + gtk_combo_box_unset_model (combo_box); + return; + } + + g_return_if_fail (GTK_IS_TREE_MODEL (model)); + + if (model == combo_box->priv->model) + return; + + if (combo_box->priv->model) + gtk_combo_box_unset_model (combo_box); + + combo_box->priv->model = model; + g_object_ref (G_OBJECT (combo_box->priv->model)); + + combo_box->priv->inserted_id = + g_signal_connect (combo_box->priv->model, "row_inserted", + G_CALLBACK (gtk_combo_box_model_row_inserted), + combo_box); + combo_box->priv->deleted_id = + g_signal_connect (combo_box->priv->model, "row_deleted", + G_CALLBACK (gtk_combo_box_model_row_deleted), + combo_box); + combo_box->priv->reordered_id = + g_signal_connect (combo_box->priv->model, "rows_reordered", + G_CALLBACK (gtk_combo_box_model_rows_reordered), + combo_box); + combo_box->priv->changed_id = + g_signal_connect (combo_box->priv->model, "row_changed", + G_CALLBACK (gtk_combo_box_model_row_changed), + combo_box); + + if (combo_box->priv->tree_view) + { + /* list mode */ + gtk_tree_view_set_model (GTK_TREE_VIEW (combo_box->priv->tree_view), + combo_box->priv->model); + } + else + { + /* menu mode */ + if (combo_box->priv->popup_widget) + gtk_combo_box_menu_fill (combo_box); + + } + + if (combo_box->priv->cell_view) + gtk_cell_view_set_model (GTK_CELL_VIEW (combo_box->priv->cell_view), + combo_box->priv->model); +} + +/** + * gtk_combo_box_get_model + * @combo_box: A #GtkComboBox. + * + * Returns the #GtkTreeModel which is acting as data source for @combo_box. + * + * Return value: A #GtkTreeModel which was passed during construction. + * + * Since: 2.4 + */ +GtkTreeModel * +gtk_combo_box_get_model (GtkComboBox *combo_box) +{ + g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL); + + return combo_box->priv->model; +} + + +/* convenience API for simple text combos */ + +/** + * gtk_combo_box_new_text: + * + * Convenience function which constructs a new text combo box, which is a + * #GtkComboBox just displaying strings. If you use this function to create + * a text combo box, you should only manipulate its data source with the + * following convenience functions: gtk_combo_box_append_text(), + * gtk_combo_box_insert_text(), gtk_combo_box_prepend_text() and + * gtk_combo_box_remove_text(). + * + * Return value: A new text combo box. + * + * Since: 2.4 + */ +GtkWidget * +gtk_combo_box_new_text (void) +{ + GtkWidget *combo_box; + GtkCellRenderer *cell; + GtkListStore *store; + + store = gtk_list_store_new (1, G_TYPE_STRING); + combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); + g_object_unref (store); + + cell = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell, + "text", 0, + NULL); + + return combo_box; +} + +/** + * gtk_combo_box_append_text: + * @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text(). + * @text: A string. + * + * Appends @string to the list of strings stored in @combo_box. Note that + * you can only use this function with combo boxes constructed with + * gtk_combo_box_new_text(). + * + * Since: 2.4 + */ +void +gtk_combo_box_append_text (GtkComboBox *combo_box, + const gchar *text) +{ + GtkTreeIter iter; + GtkListStore *store; + + g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); + g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model)); + g_return_if_fail (text != NULL); + + store = GTK_LIST_STORE (combo_box->priv->model); + + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, 0, text, -1); +} + +/** + * gtk_combo_box_insert_text: + * @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text(). + * @position: An index to insert @text. + * @text: A string. + * + * Inserts @string at @position in the list of strings stored in @combo_box. + * Note that you can only use this function with combo boxes constructed + * with gtk_combo_box_new_text(). + * + * Since: 2.4 + */ +void +gtk_combo_box_insert_text (GtkComboBox *combo_box, + gint position, + const gchar *text) +{ + GtkTreeIter iter; + GtkListStore *store; + + g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); + g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model)); + g_return_if_fail (position >= 0); + g_return_if_fail (text != NULL); + + store = GTK_LIST_STORE (combo_box->priv->model); + + gtk_list_store_insert (store, &iter, position); + gtk_list_store_set (store, &iter, 0, text, -1); +} + +/** + * gtk_combo_box_prepend_text: + * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text(). + * @text: A string. + * + * Prepends @string to the list of strings stored in @combo_box. Note that + * you can only use this function with combo boxes constructed with + * gtk_combo_box_new_text(). + * + * Since: 2.4 + */ +void +gtk_combo_box_prepend_text (GtkComboBox *combo_box, + const gchar *text) +{ + GtkTreeIter iter; + GtkListStore *store; + + g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); + g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model)); + g_return_if_fail (text != NULL); + + store = GTK_LIST_STORE (combo_box->priv->model); + + gtk_list_store_prepend (store, &iter); + gtk_list_store_set (store, &iter, 0, text, -1); +} + +/** + * gtk_combo_box_remove_text: + * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text(). + * @position: Index of the item to remove. + * + * Removes the string at @position from @combo_box. Note that you can only use + * this function with combo boxes constructed with gtk_combo_box_new_text(). + * + * Since: 2.4 + */ +void +gtk_combo_box_remove_text (GtkComboBox *combo_box, + gint position) +{ + GtkTreeIter iter; + GtkListStore *store; + + g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); + g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model)); + g_return_if_fail (position >= 0); + + store = GTK_LIST_STORE (combo_box->priv->model); + + if (gtk_tree_model_iter_nth_child (combo_box->priv->model, &iter, + NULL, position)) + gtk_list_store_remove (store, &iter); +} + +static gboolean +gtk_combo_box_mnemonic_activate (GtkWidget *widget, + gboolean group_cycling) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (widget); + + gtk_widget_grab_focus (combo_box->priv->button); + + return TRUE; +} + +static void +gtk_combo_box_destroy (GtkObject *object) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (object); + + gtk_combo_box_popdown (combo_box); + + combo_box->priv->destroying = 1; + + GTK_OBJECT_CLASS (parent_class)->destroy (object); + combo_box->priv->cell_view = NULL; + + combo_box->priv->destroying = 0; +} + +static void +gtk_combo_box_finalize (GObject *object) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (object); + GSList *i; + + if (GTK_IS_MENU (combo_box->priv->popup_widget)) + { + gtk_combo_box_menu_destroy (combo_box); + gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget)); + combo_box->priv->popup_widget = NULL; + } + + if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view)) + gtk_combo_box_list_destroy (combo_box); + + if (combo_box->priv->popup_window) + gtk_widget_destroy (combo_box->priv->popup_window); + + gtk_combo_box_unset_model (combo_box); + + for (i = combo_box->priv->cells; i; i = i->next) + { + ComboCellInfo *info = (ComboCellInfo *)i->data; + GSList *list = info->attributes; + + if (info->destroy) + info->destroy (info->func_data); + + while (list && list->next) + { + g_free (list->data); + list = list->next->next; + } + g_slist_free (info->attributes); + + g_object_unref (G_OBJECT (info->cell)); + g_free (info); + } + g_slist_free (combo_box->priv->cells); + + g_free (combo_box->priv); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + + +/** + * Code below this point has been pulled in from gtkmenu.c in 2.4.14 + * and is needed to provide gtk_menu_attach() + */ + +typedef struct +{ + gint left_attach; + gint right_attach; + gint top_attach; + gint bottom_attach; + gint effective_left_attach; + gint effective_right_attach; + gint effective_top_attach; + gint effective_bottom_attach; +} AttachInfo; + +#define ATTACH_INFO_KEY "gtk-menu-child-attach-info-key" + +static AttachInfo * +get_attach_info (GtkWidget *child) +{ + GObject *object = G_OBJECT (child); + AttachInfo *ai = g_object_get_data (object, ATTACH_INFO_KEY); + + if (!ai) + { + ai = g_new0 (AttachInfo, 1); + g_object_set_data_full (object, ATTACH_INFO_KEY, ai, g_free); + } + + return ai; +} + +/** + * gtk_menu_attach: + * @menu: a #GtkMenu. + * @child: a #GtkMenuItem. + * @left_attach: The column number to attach the left side of the item to. + * @right_attach: The column number to attach the right side of the item to. + * @top_attach: The row number to attach the top of the item to. + * @bottom_attach: The row number to attach the bottom of the item to. + * + * Adds a new #GtkMenuItem to a (table) menu. The number of 'cells' that + * an item will occupy is specified by @left_attach, @right_attach, + * @top_attach and @bottom_attach. These each represent the leftmost, + * rightmost, uppermost and lower column and row numbers of the table. + * (Columns and rows are indexed from zero). + * + * Note that this function is not related to gtk_menu_detach(). + * + * Since: 2.4 + **/ +static void +gtk_menu_attach (GtkMenu *menu, + GtkWidget *child, + guint left_attach, + guint right_attach, + guint top_attach, + guint bottom_attach) +{ + GtkMenuShell *menu_shell; + + g_return_if_fail (GTK_IS_MENU (menu)); + g_return_if_fail (GTK_IS_MENU_ITEM (child)); + g_return_if_fail (child->parent == NULL || + child->parent == GTK_WIDGET (menu)); + g_return_if_fail (left_attach < right_attach); + g_return_if_fail (top_attach < bottom_attach); + + menu_shell = GTK_MENU_SHELL (menu); + + if (!child->parent) + { + AttachInfo *ai = get_attach_info (child); + + ai->left_attach = left_attach; + ai->right_attach = right_attach; + ai->top_attach = top_attach; + ai->bottom_attach = bottom_attach; + + menu_shell->children = g_list_append (menu_shell->children, child); + + gtk_widget_set_parent (child, GTK_WIDGET (menu)); + + /* + menu_queue_resize (menu); + */ + } + else + { + gtk_container_child_set (GTK_CONTAINER (child->parent), child, + "left_attach", left_attach, + "right_attach", right_attach, + "top_attach", top_attach, + "bottom_attach", bottom_attach, + NULL); + } +} +#endif /* Gtk 2.4 */ + +gchar * +gtk_combo_box_get_active_text (GtkComboBox *combo_box) +{ + GtkTreeIter iter; + gchar *text = NULL; + + /* g_return_val_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model), NULL); */ + + if (gtk_combo_box_get_active_iter (combo_box, &iter)) + gtk_tree_model_get (gtk_combo_box_get_model(combo_box), &iter, + 0, &text, -1); + return text; +} + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pidgin/pidgincombobox.h Mon Mar 19 06:35:51 2007 +0000 @@ -0,0 +1,114 @@ +/* gtkcombobox.h + * Copyright (C) 2002, 2003 Kristian Rietveld <kris@gtk.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __PIDGIN_COMBO_BOX_H__ +#define __PIDGIN_COMBO_BOX_H__ + +#ifndef __GTK_COMBO_BOX_H__ +#define __GTK_COMBO_BOX_H__ + +#include <gtk/gtkbin.h> +#include <gtk/gtktreemodel.h> +#include <gtk/gtktreeview.h> + +G_BEGIN_DECLS + +#define GTK_TYPE_COMBO_BOX (gtk_combo_box_get_type ()) +#define GTK_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COMBO_BOX, GtkComboBox)) +#define GTK_COMBO_BOX_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), GTK_TYPE_COMBO_BOX, GtkComboBoxClass)) +#define GTK_IS_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COMBO_BOX)) +#define GTK_IS_COMBO_BOX_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), GTK_TYPE_COMBO_BOX)) +#define GTK_COMBO_BOX_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), GTK_TYPE_COMBO_BOX, GtkComboBoxClass)) + +typedef struct _GtkComboBox GtkComboBox; +typedef struct _GtkComboBoxClass GtkComboBoxClass; +typedef struct _GtkComboBoxPrivate GtkComboBoxPrivate; + +struct _GtkComboBox +{ + GtkBin parent_instance; + + /*< private >*/ + GtkComboBoxPrivate *priv; +}; + +struct _GtkComboBoxClass +{ + GtkBinClass parent_class; + + /* signals */ + void (* changed) (GtkComboBox *combo_box); + + /* Padding for future expansion */ + void (*_gtk_reserved0) (void); + void (*_gtk_reserved1) (void); + void (*_gtk_reserved2) (void); + void (*_gtk_reserved3) (void); +}; + + +/* construction */ +GType gtk_combo_box_get_type (void); +GtkWidget *gtk_combo_box_new (void); +GtkWidget *gtk_combo_box_new_with_model (GtkTreeModel *model); + +/* grids */ +void gtk_combo_box_set_wrap_width (GtkComboBox *combo_box, + gint width); +void gtk_combo_box_set_row_span_column (GtkComboBox *combo_box, + gint row_span); +void gtk_combo_box_set_column_span_column (GtkComboBox *combo_box, + gint column_span); + +/* get/set active item */ +gint gtk_combo_box_get_active (GtkComboBox *combo_box); +void gtk_combo_box_set_active (GtkComboBox *combo_box, + gint index_); +gboolean gtk_combo_box_get_active_iter (GtkComboBox *combo_box, + GtkTreeIter *iter); +void gtk_combo_box_set_active_iter (GtkComboBox *combo_box, + GtkTreeIter *iter); + +/* getters and setters */ +void gtk_combo_box_set_model (GtkComboBox *combo_box, + GtkTreeModel *model); +GtkTreeModel *gtk_combo_box_get_model (GtkComboBox *combo_box); + +/* convenience -- text */ +GtkWidget *gtk_combo_box_new_text (void); +void gtk_combo_box_append_text (GtkComboBox *combo_box, + const gchar *text); +void gtk_combo_box_insert_text (GtkComboBox *combo_box, + gint position, + const gchar *text); +void gtk_combo_box_prepend_text (GtkComboBox *combo_box, + const gchar *text); +void gtk_combo_box_remove_text (GtkComboBox *combo_box, + gint position); +/* programmatic control */ +void gtk_combo_box_popup (GtkComboBox *combo_box); +void gtk_combo_box_popdown (GtkComboBox *combo_box); + +G_END_DECLS + +#endif /* __GTK_COMBO_BOX_H__ */ + +gchar *gtk_combo_box_get_active_text (GtkComboBox *combo_box); + +#endif /* __PIDGIN_COMBOX_BOX_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pidgin/pidginstock.c Mon Mar 19 06:35:51 2007 +0000 @@ -0,0 +1,346 @@ +/** + * @file gaimstock.c GTK+ Stock resources + * @ingroup gtkui + * + * gaim + * + * Gaim 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 + * 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 "internal.h" +#include "pidgin.h" + +#include "pidginstock.h" + +static struct StockIcon +{ + const char *name; + const char *dir; + const char *filename; + +} const stock_icons[] = +{ + { PIDGIN_STOCK_ABOUT, "buttons", "about_menu.png" }, + { PIDGIN_STOCK_ACTION, NULL, GTK_STOCK_EXECUTE }, +#if GTK_CHECK_VERSION(2,6,0) + { PIDGIN_STOCK_ALIAS, NULL, GTK_STOCK_EDIT }, +#else + { PIDGIN_STOCK_ALIAS, "buttons", "edit.png" }, +#endif + { PIDGIN_STOCK_BLOCK, NULL, GTK_STOCK_STOP }, + { PIDGIN_STOCK_UNBLOCK, NULL, GTK_STOCK_STOP /* XXX: */ }, + { PIDGIN_STOCK_CHAT, NULL, GTK_STOCK_JUMP_TO }, + { PIDGIN_STOCK_CLEAR, NULL, GTK_STOCK_CLEAR }, + { PIDGIN_STOCK_CLOSE_TABS, NULL, GTK_STOCK_CLOSE }, +#if GTK_CHECK_VERSION(2,6,0) + { PIDGIN_STOCK_CONNECT, NULL, GTK_STOCK_CONNECT }, +#else + { PIDGIN_STOCK_CONNECT, "icons", "stock_connect_16.png" }, +#endif + { PIDGIN_STOCK_DEBUG, NULL, GTK_STOCK_PROPERTIES }, + { PIDGIN_STOCK_DOWNLOAD, NULL, GTK_STOCK_GO_DOWN }, +#if GTK_CHECK_VERSION(2,6,0) + { PIDGIN_STOCK_DISCONNECT, NULL, GTK_STOCK_DISCONNECT }, +#else + { PIDGIN_STOCK_DISCONNECT, "icons", "stock_disconnect_16.png" }, +#endif + { PIDGIN_STOCK_FGCOLOR, "buttons", "change-fgcolor-small.png" }, +#if GTK_CHECK_VERSION(2,6,0) + { PIDGIN_STOCK_EDIT, NULL, GTK_STOCK_EDIT }, +#else + { PIDGIN_STOCK_EDIT, "buttons", "edit.png" }, +#endif + { PIDGIN_STOCK_FILE_CANCELED, NULL, GTK_STOCK_CANCEL }, + { PIDGIN_STOCK_FILE_DONE, NULL, GTK_STOCK_APPLY }, + { PIDGIN_STOCK_FILE_TRANSFER, NULL, GTK_STOCK_REVERT_TO_SAVED }, + { PIDGIN_STOCK_IGNORE, NULL, GTK_STOCK_DIALOG_ERROR }, + { PIDGIN_STOCK_INVITE, NULL, GTK_STOCK_JUMP_TO }, + { PIDGIN_STOCK_MODIFY, NULL, GTK_STOCK_PREFERENCES }, +#if GTK_CHECK_VERSION(2,6,0) + { PIDGIN_STOCK_PAUSE, NULL, GTK_STOCK_MEDIA_PAUSE }, +#else + { PIDGIN_STOCK_PAUSE, "buttons", "pause.png" }, +#endif + { PIDGIN_STOCK_POUNCE, NULL, GTK_STOCK_REDO }, + { PIDGIN_STOCK_OPEN_MAIL, NULL, GTK_STOCK_JUMP_TO }, + { PIDGIN_STOCK_SIGN_ON, NULL, GTK_STOCK_EXECUTE }, + { PIDGIN_STOCK_SIGN_OFF, NULL, GTK_STOCK_CLOSE }, + { PIDGIN_STOCK_TYPED, "gaim", "typed.png" }, + { PIDGIN_STOCK_UPLOAD, NULL, GTK_STOCK_GO_UP }, +}; + +static const GtkStockItem stock_items[] = +{ + { PIDGIN_STOCK_ALIAS, N_("_Alias"), 0, 0, NULL }, + { PIDGIN_STOCK_CHAT, N_("_Join"), 0, 0, NULL }, + { PIDGIN_STOCK_CLOSE_TABS, N_("Close _tabs"), 0, 0, NULL }, + { PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW, N_("I_M"), 0, 0, NULL }, + { PIDGIN_STOCK_TOOLBAR_USER_INFO, N_("_Get Info"), 0, 0, NULL }, + { PIDGIN_STOCK_INVITE, N_("_Invite"), 0, 0, NULL }, + { PIDGIN_STOCK_MODIFY, N_("_Modify"), 0, 0, NULL }, + { PIDGIN_STOCK_OPEN_MAIL, N_("_Open Mail"), 0, 0, NULL }, + { PIDGIN_STOCK_PAUSE, N_("_Pause"), 0, 0, NULL }, +}; + +static struct SizedStockIcon { + const char *name; + const char *dir; + const char *filename; + gboolean extra_small; + gboolean small; + gboolean medium; + gboolean large; + gboolean huge; + gboolean rtl; +} const sized_stock_icons [] = { + { PIDGIN_STOCK_STATUS_AVAILABLE, "status", "available.png", TRUE, TRUE, TRUE, TRUE, FALSE, FALSE }, + { PIDGIN_STOCK_STATUS_AVAILABLE_I, "status", "available_i.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_STATUS_AWAY, "status", "away.png", TRUE, TRUE, TRUE, TRUE, FALSE, FALSE }, + { PIDGIN_STOCK_STATUS_AWAY_I, "status", "away_i.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_STATUS_BUSY, "status", "busy.png", TRUE, TRUE, TRUE, TRUE, FALSE, FALSE }, + { PIDGIN_STOCK_STATUS_BUSY_I, "status", "busy_i.png", TRUE, FALSE, FALSE, FALSE, FALSE,FALSE }, + { PIDGIN_STOCK_STATUS_CHAT, "status", "chat.png", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE }, + { PIDGIN_STOCK_STATUS_XA, "status", "extended-away.png", TRUE, TRUE, TRUE, TRUE, FALSE, TRUE }, + { PIDGIN_STOCK_STATUS_XA_I, "status", "extended-away_i.png",TRUE, FALSE, FALSE, FALSE, FALSE, TRUE }, + { PIDGIN_STOCK_STATUS_LOGIN, "status", "log-in.png", TRUE, TRUE, TRUE, TRUE, FALSE, FALSE }, + { PIDGIN_STOCK_STATUS_LOGOUT, "status", "log-out.png", TRUE, TRUE, TRUE, TRUE, FALSE, FALSE }, + { PIDGIN_STOCK_STATUS_OFFLINE, "status", "offline.png", TRUE, TRUE, TRUE, TRUE, FALSE, FALSE }, + { PIDGIN_STOCK_STATUS_PERSON, "status", "person.png", TRUE, TRUE, TRUE, TRUE, FALSE, FALSE }, + { PIDGIN_STOCK_STATUS_MESSAGE, "status", "message-pending.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + + { PIDGIN_STOCK_STATUS_IGNORED, "emblems", "blocked.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_STATUS_FOUNDER, "emblems", "founder.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_STATUS_OPERATOR, "emblems", "operator.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_STATUS_HALFOP, "emblems", "half-operator.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_STATUS_VOICE, "emblems", "voice.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + + { PIDGIN_STOCK_DIALOG_AUTH, "dialogs", "auth.png", TRUE, FALSE, FALSE, FALSE, TRUE, FALSE }, + { PIDGIN_STOCK_DIALOG_COOL, "dialogs", "cool.png", FALSE, FALSE, FALSE, FALSE, TRUE, FALSE }, + { PIDGIN_STOCK_DIALOG_ERROR, "dialogs", "error.png", TRUE, FALSE, FALSE, FALSE, TRUE, FALSE }, + { PIDGIN_STOCK_DIALOG_INFO, "dialogs", "info.png", TRUE, FALSE, FALSE, FALSE, TRUE, FALSE }, + { PIDGIN_STOCK_DIALOG_MAIL, "dialogs", "mail.png", TRUE, FALSE, FALSE, FALSE, TRUE, FALSE }, + { PIDGIN_STOCK_DIALOG_QUESTION, "dialogs", "question.png", TRUE, FALSE, FALSE, FALSE, TRUE, FALSE }, + { PIDGIN_STOCK_DIALOG_WARNING, "dialogs", "warning.png", FALSE, FALSE, FALSE, FALSE, TRUE, FALSE }, + + { PIDGIN_STOCK_ANIMATION_CONNECT0, "animations", "connect0.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_ANIMATION_CONNECT1, "animations", "connect1.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_ANIMATION_CONNECT2, "animations", "connect2.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_ANIMATION_CONNECT3, "animations", "connect3.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_ANIMATION_CONNECT4, "animations", "connect4.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_ANIMATION_CONNECT5, "animations", "connect5.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_ANIMATION_CONNECT6, "animations", "connect6.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_ANIMATION_CONNECT7, "animations", "connect7.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_ANIMATION_CONNECT8, "animations", "connect8.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_ANIMATION_TYPING0, "animations", "typing0.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_ANIMATION_TYPING1, "animations", "typing1.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_ANIMATION_TYPING2, "animations", "typing2.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_ANIMATION_TYPING3, "animations", "typing3.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_ANIMATION_TYPING4, "animations", "typing4.png",TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + + { PIDGIN_STOCK_TOOLBAR_ACCOUNTS, "toolbar", "accounts.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_TOOLBAR_BGCOLOR, "toolbar", "change-bgcolor.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_TOOLBAR_FGCOLOR, "toolbar", "change-fgcolor.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_TOOLBAR_SMILEY, "toolbar", "emote-select.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_TOOLBAR_TEXT_SMALLER, "toolbar", "font-size-down.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_TOOLBAR_TEXT_LARGER, "toolbar", "font-size-up.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE, "toolbar", "insert-image.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_TOOLBAR_INSERT_LINK, "toolbar", "insert-link.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW, "toolbar", "message-new.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_TOOLBAR_PLUGINS, "toolbar", "plugins.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_TOOLBAR_TYPING, "toolbar", "typing.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_TOOLBAR_PENDING, "status", "message-pending.png", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }, + + { PIDGIN_STOCK_TRAY_AVAILABLE, "tray", "tray-online.png", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_TRAY_AWAY, "tray", "tray-away.png", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_TRAY_BUSY, "tray", "tray-busy.png", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_TRAY_XA, "tray", "tray-extended-away.png", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_TRAY_OFFLINE, "tray", "tray-offline.png", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_TRAY_CONNECT, "tray", "tray-connecting.png", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE }, + { PIDGIN_STOCK_TRAY_PENDING, "tray", "tray-message.png", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE } +}; + +static gchar * +find_file(const char *dir, const char *base) +{ + char *filename; + + if (base == NULL) + return NULL; + + if (!strcmp(dir, "gaim")) + filename = g_build_filename(DATADIR, "pixmaps", "gaim", base, NULL); + else + { + filename = g_build_filename(DATADIR, "pixmaps", "gaim", dir, + base, NULL); + } + + return filename; +} + +static void +add_sized_icon(GtkIconSet *iconset, GtkIconSize sizeid, const char *dir, + gboolean rtl, const char *size, const char *file) +{ + char *filename; + GtkIconSource *source; + + filename = g_build_filename(DATADIR, "pixmaps", "pidgin", dir, size, file, NULL); + source = gtk_icon_source_new(); + gtk_icon_source_set_filename(source, filename); + gtk_icon_source_set_direction(source, GTK_TEXT_DIR_LTR); + gtk_icon_source_set_direction_wildcarded(source, !rtl); + gtk_icon_source_set_size(source, sizeid); + gtk_icon_source_set_size_wildcarded(source, FALSE); + gtk_icon_source_set_state_wildcarded(source, TRUE); + gtk_icon_set_add_source(iconset, source); + gtk_icon_source_free(source); + + if (sizeid == gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL)) { + source = gtk_icon_source_new(); + gtk_icon_source_set_filename(source, filename); + gtk_icon_source_set_direction_wildcarded(source, TRUE); + gtk_icon_source_set_size(source, GTK_ICON_SIZE_MENU); + gtk_icon_source_set_size_wildcarded(source, FALSE); + gtk_icon_source_set_state_wildcarded(source, TRUE); + gtk_icon_set_add_source(iconset, source); + gtk_icon_source_free(source); + } + g_free(filename); + + if (rtl) { + filename = g_build_filename(DATADIR, "pixmaps", "pidgin", dir, size, "rtl", file, NULL); + source = gtk_icon_source_new(); + gtk_icon_source_set_filename(source, filename); + gtk_icon_source_set_direction(source, GTK_TEXT_DIR_RTL); + gtk_icon_source_set_size(source, sizeid); + gtk_icon_source_set_size_wildcarded(source, FALSE); + gtk_icon_source_set_state_wildcarded(source, TRUE); + gtk_icon_set_add_source(iconset, source); + g_free(filename); + gtk_icon_source_free(source); + } + + +} + +void +pidgin_stock_init(void) +{ + static gboolean stock_initted = FALSE; + GtkIconFactory *icon_factory; + size_t i; + GtkWidget *win; + GtkIconSize extra_small, small, medium, large, huge; + + if (stock_initted) + return; + + stock_initted = TRUE; + + /* Setup the icon factory. */ + icon_factory = gtk_icon_factory_new(); + + gtk_icon_factory_add_default(icon_factory); + + /* Er, yeah, a hack, but it works. :) */ + win = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_widget_realize(win); + + for (i = 0; i < G_N_ELEMENTS(stock_icons); i++) + { + GtkIconSource *source; + GtkIconSet *iconset; + gchar *filename; + + if (stock_icons[i].dir == NULL) + { + /* GTK+ Stock icon */ + iconset = gtk_style_lookup_icon_set(gtk_widget_get_style(win), + stock_icons[i].filename); + } + else + { + filename = find_file(stock_icons[i].dir, stock_icons[i].filename); + + if (filename == NULL) + continue; + + source = gtk_icon_source_new(); + gtk_icon_source_set_filename(source, filename); + gtk_icon_source_set_direction_wildcarded(source, TRUE); + gtk_icon_source_set_size_wildcarded(source, TRUE); + gtk_icon_source_set_state_wildcarded(source, TRUE); + + + iconset = gtk_icon_set_new(); + gtk_icon_set_add_source(iconset, source); + + gtk_icon_source_free(source); + g_free(filename); + } + + gtk_icon_factory_add(icon_factory, stock_icons[i].name, iconset); + + gtk_icon_set_unref(iconset); + } + + /* register custom icon sizes */ + extra_small = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL, 16, 16); + small = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_SMALL, 22, 22); + medium = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_MEDIUM, 32, 32); + large = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_LARGE, 48, 48); + huge = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_HUGE, 64, 64); + + for (i = 0; i < G_N_ELEMENTS(sized_stock_icons); i++) + { + GtkIconSet *iconset; + + iconset = gtk_icon_set_new(); + if (sized_stock_icons[i].extra_small) + add_sized_icon(iconset, extra_small, + sized_stock_icons[i].dir, sized_stock_icons[i].rtl, + "16", sized_stock_icons[i].filename); + if (sized_stock_icons[i].small) + add_sized_icon(iconset, small, + sized_stock_icons[i].dir, sized_stock_icons[i].rtl, + "22", sized_stock_icons[i].filename); + if (sized_stock_icons[i].medium) + add_sized_icon(iconset, medium, + sized_stock_icons[i].dir, sized_stock_icons[i].rtl, + "32", sized_stock_icons[i].filename); + if (sized_stock_icons[i].large) + add_sized_icon(iconset, large, + sized_stock_icons[i].dir, sized_stock_icons[i].rtl, + "48", sized_stock_icons[i].filename); + if (sized_stock_icons[i].huge) + add_sized_icon(iconset, huge, + sized_stock_icons[i].dir, sized_stock_icons[i].rtl, + "64", sized_stock_icons[i].filename); + + gtk_icon_factory_add(icon_factory, sized_stock_icons[i].name, iconset); + gtk_icon_set_unref(iconset); + } + + gtk_widget_destroy(win); + g_object_unref(G_OBJECT(icon_factory)); + + /* Register the stock items. */ + gtk_stock_add_static(stock_items, G_N_ELEMENTS(stock_items)); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pidgin/pidginstock.h Mon Mar 19 06:35:51 2007 +0000 @@ -0,0 +1,152 @@ +/** + * @file gtkstock.h GTK+ Stock resources + * @ingroup gtkui + * + * gaim + * + * 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 + * 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 <gtk/gtkstock.h> + +#ifndef _PIDGIN_STOCK_H_ +#define _PIDGIN_STOCK_H_ + +/**************************************************************************/ +/** @name Stock images */ +/**************************************************************************/ +/*@{*/ +#define PIDGIN_STOCK_ABOUT "pidgin-about" +#define PIDGIN_STOCK_ACTION "pidgin-action" +#define PIDGIN_STOCK_ALIAS "pidgin-alias" +#define PIDGIN_STOCK_AWAY "pidgin-away" +#define PIDGIN_STOCK_BLOCK "pidgin-block" +#define PIDGIN_STOCK_UNBLOCK "pidgin-unblock" +#define PIDGIN_STOCK_CHAT "pidgin-chat" +#define PIDGIN_STOCK_CLEAR "pidgin-clear" +#define PIDGIN_STOCK_CLOSE_TABS "pidgin-close-tab" +#define PIDGIN_STOCK_CONNECT "pidgin-connect" +#define PIDGIN_STOCK_DEBUG "pidgin-debug" +#define PIDGIN_STOCK_DISCONNECT "pidgin-disconnect" +#define PIDGIN_STOCK_DOWNLOAD "pidgin-download" +#define PIDGIN_STOCK_EDIT "pidgin-edit" +#define PIDGIN_STOCK_FGCOLOR "pidgin-fgcolor" +#define PIDGIN_STOCK_FILE_CANCELED "pidgin-file-canceled" +#define PIDGIN_STOCK_FILE_DONE "pidgin-file-done" +#define PIDGIN_STOCK_FILE_TRANSFER "pidgin-file-transfer" +#define PIDGIN_STOCK_IGNORE "pidgin-ignore" +#define PIDGIN_STOCK_INVITE "pidgin-invite" +#define PIDGIN_STOCK_MODIFY "pidgin-modify" +#define PIDGIN_STOCK_OPEN_MAIL "pidgin-stock-open-mail" +#define PIDGIN_STOCK_PAUSE "pidgin-pause" +#define PIDGIN_STOCK_POUNCE "pidgin-pounce" +#define PIDGIN_STOCK_SIGN_OFF "pidgin-sign-off" +#define PIDGIN_STOCK_SIGN_ON "pidgin-sign-on" +#define PIDGIN_STOCK_TEXT_NORMAL "pidgin-text-normal" +#define PIDGIN_STOCK_TYPED "pidgin-typed" +#define PIDGIN_STOCK_UPLOAD "pidgin-upload" + +/* Status icons */ +#define PIDGIN_STOCK_STATUS_AVAILABLE "pidgin-status-available" +#define PIDGIN_STOCK_STATUS_AVAILABLE_I "pidgin-status-available-i" +#define PIDGIN_STOCK_STATUS_AWAY "pidgin-status-away" +#define PIDGIN_STOCK_STATUS_AWAY_I "pidgin-status-away-i" +#define PIDGIN_STOCK_STATUS_BUSY "pidgin-status-busy" +#define PIDGIN_STOCK_STATUS_BUSY_I "pidgin-status-busy-i" +#define PIDGIN_STOCK_STATUS_CHAT "pidgin-status-chat" +#define PIDGIN_STOCK_STATUS_XA "pidgin-status-xa" +#define PIDGIN_STOCK_STATUS_XA_I "pidgin-status-xa-i" +#define PIDGIN_STOCK_STATUS_LOGIN "pidgin-status-login" +#define PIDGIN_STOCK_STATUS_LOGOUT "pidgin-status-logout" +#define PIDGIN_STOCK_STATUS_OFFLINE "pidgin-status-offline" +#define PIDGIN_STOCK_STATUS_PERSON "pidgin-status-person" +#define PIDGIN_STOCK_STATUS_MESSAGE "pidgin-status-message" + +/* Chat room emblems */ +#define PIDGIN_STOCK_STATUS_IGNORED "pidgin-status-ignored" +#define PIDGIN_STOCK_STATUS_FOUNDER "pidgin-status-founder" +#define PIDGIN_STOCK_STATUS_OPERATOR "pidgin-status-operator" +#define PIDGIN_STOCK_STATUS_HALFOP "pidgin-status-halfop" +#define PIDGIN_STOCK_STATUS_VOICE "pidgin-status-voice" + +/* Dialog icons */ +#define PIDGIN_STOCK_DIALOG_AUTH "pidgin-dialog-auth" +#define PIDGIN_STOCK_DIALOG_ERROR "pidgin-dialog-error" +#define PIDGIN_STOCK_DIALOG_INFO "pidgin-dialog-info" +#define PIDGIN_STOCK_DIALOG_MAIL "pidgin-dialog-mail" +#define PIDGIN_STOCK_DIALOG_QUESTION "pidgin-dialog-question" +#define PIDGIN_STOCK_DIALOG_COOL "pidgin-dialog-cool" +#define PIDGIN_STOCK_DIALOG_WARNING "pidgin-dialog-warning" + +/* StatusBox Animations */ +#define PIDGIN_STOCK_ANIMATION_CONNECT0 "pidgin-anim-connect0" +#define PIDGIN_STOCK_ANIMATION_CONNECT1 "pidgin-anim-connect1" +#define PIDGIN_STOCK_ANIMATION_CONNECT2 "pidgin-anim-connect2" +#define PIDGIN_STOCK_ANIMATION_CONNECT3 "pidgin-anim-connect3" +#define PIDGIN_STOCK_ANIMATION_CONNECT4 "pidgin-anim-connect4" +#define PIDGIN_STOCK_ANIMATION_CONNECT5 "pidgin-anim-connect5" +#define PIDGIN_STOCK_ANIMATION_CONNECT6 "pidgin-anim-connect6" +#define PIDGIN_STOCK_ANIMATION_CONNECT7 "pidgin-anim-connect7" +#define PIDGIN_STOCK_ANIMATION_CONNECT8 "pidgin-anim-connect8" +#define PIDGIN_STOCK_ANIMATION_TYPING0 "pidgin-anim-typing0" +#define PIDGIN_STOCK_ANIMATION_TYPING1 "pidgin-anim-typing1" +#define PIDGIN_STOCK_ANIMATION_TYPING2 "pidgin-anim-typing2" +#define PIDGIN_STOCK_ANIMATION_TYPING3 "pidgin-anim-typing3" +#define PIDGIN_STOCK_ANIMATION_TYPING4 "pidgin-anim-typing4" + +/* Toolbar (and menu) icons */ +#define PIDGIN_STOCK_TOOLBAR_ACCOUNTS "pidgin-accounts" +#define PIDGIN_STOCK_TOOLBAR_BGCOLOR "pidgin-bgcolor" +#define PIDGIN_STOCK_TOOLBAR_FGCOLOR "pidgin-fgcolor" +#define PIDGIN_STOCK_TOOLBAR_SMILEY "pidgin-smiley" +#define PIDGIN_STOCK_TOOLBAR_TEXT_SMALLER "pidgin-text-smaller" +#define PIDGIN_STOCK_TOOLBAR_TEXT_LARGER "pidgin-text-larger" +#define PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE "pidgin-insert-image" +#define PIDGIN_STOCK_TOOLBAR_INSERT_LINK "pidgin-insert-link" +#define PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW "pidgin-message-new" +#define PIDGIN_STOCK_TOOLBAR_PLUGINS "pidgin-plugins" +#define PIDGIN_STOCK_TOOLBAR_TYPING "pidgin-typing" +#define PIDGIN_STOCK_TOOLBAR_USER_INFO "pidgin-info" +#define PIDGIN_STOCK_TOOLBAR_PENDING "pidgin-pending" + +/* Tray icons */ +#define PIDGIN_STOCK_TRAY_AVAILABLE "pidgin-tray-available" +#define PIDGIN_STOCK_TRAY_AWAY "pidgin-tray-away" +#define PIDGIN_STOCK_TRAY_BUSY "pidgin-tray-busy" +#define PIDGIN_STOCK_TRAY_XA "pidgin-tray-xa" +#define PIDGIN_STOCK_TRAY_OFFLINE "pidgin-tray-offline" +#define PIDGIN_STOCK_TRAY_CONNECT "pidgin-tray-connect" +#define PIDGIN_STOCK_TRAY_PENDING "pidgin-tray-pending" + + +/*@}*/ + +/** + * For using icons that aren't one of the default GTK_ICON_SIZEs + */ +#define PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL "pidgin-icon-size-tango-extra-small" +#define PIDGIN_ICON_SIZE_TANGO_SMALL "pidgin-icon-size-tango-small" +#define PIDGIN_ICON_SIZE_TANGO_MEDIUM "pidgin-icon-size-tango-medium" +#define PIDGIN_ICON_SIZE_TANGO_LARGE "pidgin-icon-size-tango-large" +#define PIDGIN_ICON_SIZE_TANGO_HUGE "pidgin-icon-size-tango-huge" +/** + * Sets up the gaim stock repository. + */ +void pidgin_stock_init(void); + +#endif /* _PIDGIN_STOCK_H_ */
--- a/pidgin/plugins/convcolors.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/plugins/convcolors.c Mon Mar 19 06:35:51 2007 +0000 @@ -259,8 +259,8 @@ GtkWidget *frame; int i; - ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); - gtk_container_set_border_width(GTK_CONTAINER(ret), GAIM_HIG_BORDER); + ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); + gtk_container_set_border_width(GTK_CONTAINER(ret), PIDGIN_HIG_BORDER); for (i = 0; formats[i].prefix; i++) { @@ -272,10 +272,10 @@ f = gaim_prefs_get_int(tmp); frame = pidgin_make_frame(ret, _(formats[i].text)); - vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(frame), vbox, FALSE, FALSE, 0); - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); button = pidgin_pixbuf_button_from_stock(" Color", GTK_STOCK_SELECT_COLOR,
--- a/pidgin/plugins/gaimrc.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/plugins/gaimrc.c Mon Mar 19 06:35:51 2007 +0000 @@ -439,15 +439,15 @@ GtkSizeGroup *labelsg = NULL, *widgetsg = NULL; GtkWidget *ret = NULL, *frame = NULL, *hbox = NULL, *vbox = NULL; - ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); - gtk_container_set_border_width(GTK_CONTAINER(ret), GAIM_HIG_BORDER); + ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); + gtk_container_set_border_width(GTK_CONTAINER(ret), PIDGIN_HIG_BORDER); labelsg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); widgetsg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); frame = pidgin_make_frame(ret, _("General")); /* interface font */ - hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); check = pidgin_prefs_checkbox(_("GTK+ Interface Font"), @@ -467,7 +467,7 @@ G_CALLBACK(gaimrc_set_font_special), NULL); /* key theme name */ - hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); check = pidgin_prefs_checkbox(_("GTK+ Text Shortcut Theme"), @@ -487,7 +487,7 @@ G_CALLBACK(pidgin_toggle_sensitive), widget); for (i = 0; i < G_N_ELEMENTS(widget_bool_prefs); i++) { - hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); check = pidgin_prefs_checkbox(_(widget_bool_names[i]), @@ -508,7 +508,7 @@ frame = pidgin_make_frame(ret, _("Interface colors")); /* imhtml stuff */ for (i = 0; i < G_N_ELEMENTS(color_prefs); i++) { - hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); check = pidgin_prefs_checkbox(_(color_names[i]), @@ -532,7 +532,7 @@ frame = pidgin_make_frame(ret, _("Widget Sizes")); /* widget size stuff */ for (i = 0; i < G_N_ELEMENTS(widget_size_prefs); i++) { - hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); check = pidgin_prefs_checkbox(_(widget_size_names[i]), @@ -553,7 +553,7 @@ frame = pidgin_make_frame(ret, _("Fonts")); /* imhtml font stuff */ for (i = 0; i < G_N_ELEMENTS(font_prefs); i++) { - hbox = gtk_hbox_new(FALSE, GAIM_HIG_CAT_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); check = pidgin_prefs_checkbox(_(font_names[i]), @@ -575,7 +575,7 @@ frame = pidgin_make_frame(ret, _("Tools")); - vbox = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); + vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); gtk_box_pack_start(GTK_BOX(frame), vbox, FALSE, FALSE, 0); tmp = g_strdup_printf(_("Write settings to %s%sgtkrc-2.0"), gaim_user_dir(), G_DIR_SEPARATOR_S);
--- a/pidgin/plugins/spellchk.c Mon Mar 19 06:34:51 2007 +0000 +++ b/pidgin/plugins/spellchk.c Mon Mar 19 06:35:51 2007 +0000 @@ -2174,8 +2174,8 @@ GtkWidget *hbox2; GtkWidget *vbox3; - ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); - gtk_container_set_border_width (GTK_CONTAINER(ret), GAIM_HIG_BORDER); + ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); + gtk_container_set_border_width (GTK_CONTAINER(ret), PIDGIN_HIG_BORDER); vbox = pidgin_make_frame(ret, _("Text Replacements")); gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); @@ -2268,10 +2268,10 @@ vbox = pidgin_make_frame(ret, _("Add a new text replacement")); - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0); gtk_widget_show(hbox); - vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); + vbox2 = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0); gtk_widget_show(vbox2);