Mercurial > pidgin
changeset 29087:2dcff225172e
Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Sun, 23 Aug 2009 05:04:15 +0000 |
parents | e2c8fe39a2f1 |
children | 886a0dfaa625 |
files | pidgin/gtkstatusbox.c pidgin/gtkutils.c pidgin/gtkutils.h pidgin/gtkwhiteboard.c pidgin/minidialog.c pidgin/pidgin.h |
diffstat | 6 files changed, 25 insertions(+), 609 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtkstatusbox.c Sun Aug 23 02:37:12 2009 +0000 +++ b/pidgin/gtkstatusbox.c Sun Aug 23 05:04:15 2009 +0000 @@ -1169,7 +1169,6 @@ return FALSE; } -#if GTK_CHECK_VERSION(2,6,0) static gboolean dropdown_store_row_separator_func(GtkTreeModel *model, GtkTreeIter *iter, gpointer data) @@ -1183,7 +1182,6 @@ return FALSE; } -#endif static void cache_pixbufs(PidginStatusBox *status_box) @@ -1293,11 +1291,9 @@ static void pidgin_status_box_list_position (PidginStatusBox *status_box, int *x, int *y, int *width, int *height) { -#if GTK_CHECK_VERSION(2,2,0) GdkScreen *screen; gint monitor_num; GdkRectangle monitor; -#endif GtkRequisition popup_req; GtkPolicyType hpolicy, vpolicy; @@ -1323,7 +1319,6 @@ *height = popup_req.height; -#if GTK_CHECK_VERSION(2,2,0) screen = gtk_widget_get_screen (GTK_WIDGET (status_box)); monitor_num = gdk_screen_get_monitor_at_window (screen, GTK_WIDGET (status_box)->window); @@ -1356,7 +1351,6 @@ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (status_box->scrolled_window), hpolicy, vpolicy); } -#endif } static gboolean @@ -1364,29 +1358,20 @@ guint32 activate_time, gboolean grab_keyboard) { - if ((gdk_pointer_grab (window, TRUE, + if ((gdk_pointer_grab (window, TRUE, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK, NULL, NULL, activate_time) == 0)) - { - if (!grab_keyboard || - gdk_keyboard_grab (window, TRUE, - activate_time) == 0) - return TRUE; - else { -#if GTK_CHECK_VERSION(2,2,0) - gdk_display_pointer_ungrab (gdk_drawable_get_display (window), - activate_time); -#else - gdk_pointer_ungrab(activate_time); - gdk_keyboard_ungrab(activate_time); -#endif - return FALSE; + if (!grab_keyboard || gdk_keyboard_grab (window, TRUE, activate_time) == 0) + return TRUE; + else { + gdk_display_pointer_ungrab (gdk_drawable_get_display (window), activate_time); + return FALSE; + } } - } - - return FALSE; + + return FALSE; } @@ -1781,9 +1766,7 @@ gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->vsep, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->arrow, FALSE, FALSE, 0); gtk_widget_show_all(status_box->toggle_button); -#if GTK_CHECK_VERSION(2,4,0) gtk_button_set_focus_on_click(GTK_BUTTON(status_box->toggle_button), FALSE); -#endif text_rend = gtk_cell_renderer_text_new(); icon_rend = gtk_cell_renderer_pixbuf_new(); @@ -1797,14 +1780,10 @@ } gtk_window_set_resizable (GTK_WINDOW (status_box->popup_window), FALSE); -#if GTK_CHECK_VERSION(2,10,0) gtk_window_set_type_hint (GTK_WINDOW (status_box->popup_window), GDK_WINDOW_TYPE_HINT_POPUP_MENU); -#endif -#if GTK_CHECK_VERSION(2,2,0) gtk_window_set_screen (GTK_WINDOW (status_box->popup_window), gtk_widget_get_screen (GTK_WIDGET (status_box))); -#endif status_box->popup_frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (status_box->popup_frame), GTK_SHADOW_ETCHED_IN); @@ -1831,10 +1810,8 @@ gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (status_box->tree_view), FALSE); -#if GTK_CHECK_VERSION(2,6,0) gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (status_box->tree_view), TRUE); -#endif gtk_tree_view_set_model (GTK_TREE_VIEW (status_box->tree_view), GTK_TREE_MODEL(status_box->dropdown_store)); status_box->column = gtk_tree_view_column_new (); @@ -1852,9 +1829,7 @@ gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(status_box->tree_view), pidgin_tree_view_search_equal_func, NULL, NULL); -#if GTK_CHECK_VERSION(2, 6, 0) g_object_set(text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); -#endif status_box->icon_rend = gtk_cell_renderer_pixbuf_new(); status_box->text_rend = gtk_cell_renderer_text_new(); @@ -1865,9 +1840,7 @@ gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "stock-id", ICON_STOCK_COLUMN, NULL); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), emblem_rend, "pixbuf", EMBLEM_COLUMN, "visible", EMBLEM_VISIBLE_COLUMN, NULL); -#if GTK_CHECK_VERSION(2, 6, 0) g_object_set(status_box->text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); -#endif status_box->vbox = gtk_vbox_new(0, FALSE); status_box->sw = pidgin_create_imhtml(FALSE, &status_box->imhtml, NULL, NULL); @@ -1912,9 +1885,7 @@ g_signal_connect(G_OBJECT(status_box->tree_view), "cursor-changed", G_CALLBACK(treeview_cursor_changed_cb), status_box->dropdown_store); -#if GTK_CHECK_VERSION(2,6,0) gtk_tree_view_set_row_separator_func(GTK_TREE_VIEW(status_box->tree_view), dropdown_store_row_separator_func, NULL, NULL); -#endif status_box->token_status_account = check_active_accounts_for_identical_statuses(); @@ -2198,14 +2169,12 @@ { /* Don't do anything unless GTK actually supports * gtk_combo_box_set_row_separator_func */ -#if GTK_CHECK_VERSION(2,6,0) GtkTreeIter iter; gtk_list_store_append(status_box->dropdown_store, &iter); gtk_list_store_set(status_box->dropdown_store, &iter, TYPE_COLUMN, PIDGIN_STATUS_BOX_TYPE_SEPARATOR, -1); -#endif } void @@ -2229,7 +2198,6 @@ static void pixbuf_size_prepared_cb(GdkPixbufLoader *loader, int width, int height, gpointer data) { -#if GTK_CHECK_VERSION(2,2,0) int w, h; GtkIconSize icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_MEDIUM); gtk_icon_size_lookup(icon_size, &w, &h); @@ -2238,7 +2206,6 @@ else if (width > height) h = height * w / width; gdk_pixbuf_loader_set_size(loader, w, h); -#endif } static void
--- a/pidgin/gtkutils.c Sun Aug 23 02:37:12 2009 +0000 +++ b/pidgin/gtkutils.c Sun Aug 23 05:04:15 2009 +0000 @@ -1261,7 +1261,6 @@ gboolean *push_in, gpointer data) { -#if GTK_CHECK_VERSION(2,2,0) GtkWidget *widget; GtkRequisition requisition; GdkScreen *screen; @@ -1402,7 +1401,6 @@ { *y = monitor.y; } -#endif } @@ -1639,7 +1637,6 @@ char key[64]; const char *itemname = NULL; -#if GTK_CHECK_VERSION(2,6,0) const char * const *langs; int i; langs = g_get_language_names(); @@ -1648,15 +1645,7 @@ itemname = purple_desktop_item_get_string(item, key); break; } -#else - const char *lang = g_getenv("LANG"); - char *dot; - dot = strchr(lang, '.'); - if (dot) - *dot = '\0'; - g_snprintf(key, sizeof(key), "Name[%s]", lang); - itemname = purple_desktop_item_get_string(item, key); -#endif + if (!itemname) itemname = purple_desktop_item_get_string(item, "Name"); @@ -1673,10 +1662,13 @@ purple_desktop_item_get_string(item, "URL"), itemname); break; default: - /* I don't know if we really want to do anything here. Most of the desktop item types are crap like - * "MIME Type" (I have no clue how that would be a desktop item) and "Comment"... nothing we can really - * send. The only logical one is "Application," but do we really want to send a binary and nothing else? - * Probably not. I'll just give an error and return. */ + /* I don't know if we really want to do anything here. Most of + * the desktop item types are crap like "MIME Type" (I have no + * clue how that would be a desktop item) and "Comment"... + * nothing we can really send. The only logical one is + * "Application," but do we really want to send a binary and + * nothing else? Probably not. I'll just give an error and + * return. */ /* The original patch sent the icon used by the launcher. That's probably wrong */ purple_notify_error(NULL, NULL, _("Cannot send launcher"), _("You dragged a desktop launcher. Most " @@ -1865,10 +1857,6 @@ return menuitem; } -#if GTK_CHECK_VERSION(2,3,0) -# define NEW_STYLE_COMPLETION -#endif - typedef struct { GtkWidget *entry; @@ -1877,97 +1865,9 @@ PidginFilterBuddyCompletionEntryFunc filter_func; gpointer filter_func_user_data; -#ifdef NEW_STYLE_COMPLETION GtkListStore *store; -#else - GCompletion *completion; - gboolean completion_started; - GList *log_items; -#endif /* NEW_STYLE_COMPLETION */ } PidginCompletionData; -#ifndef NEW_STYLE_COMPLETION -static gboolean -completion_entry_event(GtkEditable *entry, GdkEventKey *event, - PidginCompletionData *data) -{ - int pos, end_pos; - - if (event->type == GDK_KEY_PRESS && event->keyval == GDK_Tab) - { - gtk_editable_get_selection_bounds(entry, &pos, &end_pos); - - if (data->completion_started && - pos != end_pos && pos > 1 && - end_pos == strlen(gtk_entry_get_text(GTK_ENTRY(entry)))) - { - gtk_editable_select_region(entry, 0, 0); - gtk_editable_set_position(entry, -1); - - return TRUE; - } - } - else if (event->type == GDK_KEY_PRESS && event->length > 0) - { - char *prefix, *nprefix; - - gtk_editable_get_selection_bounds(entry, &pos, &end_pos); - - if (data->completion_started && - pos != end_pos && pos > 1 && - end_pos == strlen(gtk_entry_get_text(GTK_ENTRY(entry)))) - { - char *temp; - - temp = gtk_editable_get_chars(entry, 0, pos); - prefix = g_strconcat(temp, event->string, NULL); - g_free(temp); - } - else if (pos == end_pos && pos > 1 && - end_pos == strlen(gtk_entry_get_text(GTK_ENTRY(entry)))) - { - prefix = g_strconcat(gtk_entry_get_text(GTK_ENTRY(entry)), - event->string, NULL); - } - else - return FALSE; - - pos = strlen(prefix); - nprefix = NULL; - - g_completion_complete(data->completion, prefix, &nprefix); - - if (nprefix != NULL) - { - gtk_entry_set_text(GTK_ENTRY(entry), nprefix); - gtk_editable_set_position(entry, pos); - gtk_editable_select_region(entry, pos, -1); - - data->completion_started = TRUE; - - g_free(nprefix); - g_free(prefix); - - return TRUE; - } - - g_free(prefix); - } - - return FALSE; -} - -static void -destroy_completion_data(GtkWidget *w, PidginCompletionData *data) -{ - g_list_foreach(data->completion->items, (GFunc)g_free, NULL); - g_completion_free(data->completion); - - g_free(data); -} -#endif /* !NEW_STYLE_COMPLETION */ - -#ifdef NEW_STYLE_COMPLETION static gboolean buddyname_completion_match_func(GtkEntryCompletion *completion, const gchar *key, GtkTreeIter *iter, gpointer user_data) { @@ -2101,7 +2001,6 @@ g_free(normalized_buddyname); } -#endif /* NEW_STYLE_COMPLETION */ static void get_log_set_name(PurpleLogSet *set, gpointer value, PidginCompletionData *data) { @@ -2116,14 +2015,8 @@ entry.entry.logged_buddy = set; if (filter_func(&entry, user_data)) { -#ifdef NEW_STYLE_COMPLETION add_buddyname_autocomplete_entry(data->store, NULL, NULL, set->account, set->name); -#else - /* Steal the name for the GCompletion. */ - data->log_items = g_list_append(data->log_items, set->name); - set->name = set->normalized_name = NULL; -#endif /* NEW_STYLE_COMPLETION */ } } } @@ -2136,14 +2029,7 @@ gpointer user_data = data->filter_func_user_data; GHashTable *sets; -#ifdef NEW_STYLE_COMPLETION gtk_list_store_clear(data->store); -#else - GList *item = g_list_append(NULL, NULL); - - g_list_foreach(data->completion->items, (GFunc)g_free, NULL); - g_completion_clear_items(data->completion); -#endif /* NEW_STYLE_COMPLETION */ for (gnode = purple_get_blist()->root; gnode != NULL; gnode = gnode->next) { @@ -2162,35 +2048,21 @@ entry.entry.buddy = (PurpleBuddy *) bnode; if (filter_func(&entry, user_data)) { -#ifdef NEW_STYLE_COMPLETION add_buddyname_autocomplete_entry(data->store, ((PurpleContact *)cnode)->alias, purple_buddy_get_contact_alias(entry.entry.buddy), entry.entry.buddy->account, entry.entry.buddy->name ); -#else - item->data = g_strdup(entry.entry.buddy->name); - g_completion_add_items(data->completion, item); -#endif /* NEW_STYLE_COMPLETION */ } } } } -#ifndef NEW_STYLE_COMPLETION - g_list_free(item); - data->log_items = NULL; -#endif /* NEW_STYLE_COMPLETION */ - sets = purple_log_get_log_sets(); g_hash_table_foreach(sets, (GHFunc)get_log_set_name, data); g_hash_table_destroy(sets); -#ifndef NEW_STYLE_COMPLETION - g_completion_add_items(data->completion, data->log_items); - g_list_free(data->log_items); -#endif /* NEW_STYLE_COMPLETION */ } static void @@ -2211,7 +2083,6 @@ { PidginCompletionData *data; -#ifdef NEW_STYLE_COMPLETION /* * Store the displayed completion value, the buddy name, the UTF-8 * normalized & casefolded buddy name, the UTF-8 normalized & @@ -2255,33 +2126,6 @@ gtk_entry_completion_set_text_column(completion, 0); -#else /* !NEW_STYLE_COMPLETION */ - - data = g_new0(PidginCompletionData, 1); - - data->entry = entry; - data->accountopt = accountopt; - if (filter_func == NULL) { - data->filter_func = pidgin_screenname_autocomplete_default_filter; - data->filter_func_user_data = NULL; - } else { - data->filter_func = filter_func; - data->filter_func_user_data = user_data; - } - data->completion = g_completion_new(NULL); - data->completion_started = FALSE; - - add_completion_list(data); - - g_completion_set_compare(data->completion, g_ascii_strncasecmp); - - g_signal_connect(G_OBJECT(entry), "event", - G_CALLBACK(completion_entry_event), data); - g_signal_connect(G_OBJECT(entry), "destroy", - G_CALLBACK(destroy_completion_data), data); - -#endif /* !NEW_STYLE_COMPLETION */ - purple_signal_connect(purple_connections_get_handle(), "signed-on", entry, PURPLE_CALLBACK(repopulate_autocomplete), data); purple_signal_connect(purple_connections_get_handle(), "signed-off", entry, @@ -2325,11 +2169,7 @@ gdk_window_set_cursor(widget->window, cursor); gdk_cursor_unref(cursor); -#if GTK_CHECK_VERSION(2,4,0) gdk_display_flush(gdk_drawable_get_display(GDK_DRAWABLE(widget->window))); -#else - gdk_flush(); -#endif } void pidgin_clear_cursor(GtkWidget *widget) @@ -2350,23 +2190,6 @@ gpointer data; }; -#if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ -static void -icon_filesel_delete_cb(GtkWidget *w, struct _icon_chooser *dialog) -{ - if (dialog->icon_filesel != NULL) - gtk_widget_destroy(dialog->icon_filesel); - - if (dialog->callback) - dialog->callback(NULL, dialog->data); - - g_free(dialog); -} -#endif /* FILECHOOSER */ - - - -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ static void icon_filesel_choose_cb(GtkWidget *widget, gint response, struct _icon_chooser *dialog) { @@ -2390,33 +2213,7 @@ g_free(current_folder); } -#else /* FILECHOOSER */ -static void -icon_filesel_choose_cb(GtkWidget *w, struct _icon_chooser *dialog) -{ - char *filename, *current_folder; - - filename = g_strdup(gtk_file_selection_get_filename( - GTK_FILE_SELECTION(dialog->icon_filesel))); - - /* If they typed in a directory, change there */ - if (pidgin_check_if_dir(filename, - GTK_FILE_SELECTION(dialog->icon_filesel))) - { - g_free(filename); - return; - } - - current_folder = g_path_get_dirname(filename); - if (current_folder != NULL) { - purple_prefs_set_path(PIDGIN_PREFS_ROOT "/filelocations/last_icon_folder", current_folder); - g_free(current_folder); - } - -#endif /* FILECHOOSER */ -#if 0 /* mismatched curly braces */ - } -#endif + if (dialog->callback) dialog->callback(filename, dialog->data); gtk_widget_destroy(dialog->icon_filesel); @@ -2426,11 +2223,7 @@ static void -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ icon_preview_change_cb(GtkFileChooser *widget, struct _icon_chooser *dialog) -#else /* FILECHOOSER */ -icon_preview_change_cb(GtkTreeSelection *sel, struct _icon_chooser *dialog) -#endif /* FILECHOOSER */ { GdkPixbuf *pixbuf, *scale; int height, width; @@ -2438,13 +2231,8 @@ struct stat st; char *filename; -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ filename = gtk_file_chooser_get_preview_filename( GTK_FILE_CHOOSER(dialog->icon_filesel)); -#else /* FILECHOOSER */ - filename = g_strdup(gtk_file_selection_get_filename( - GTK_FILE_SELECTION(dialog->icon_filesel))); -#endif /* FILECHOOSER */ if (!filename || g_stat(filename, &st) || !(pixbuf = gdk_pixbuf_new_from_file(filename, NULL))) { @@ -2480,20 +2268,13 @@ GtkWidget *pidgin_buddy_icon_chooser_new(GtkWindow *parent, void(*callback)(const char *, gpointer), gpointer data) { struct _icon_chooser *dialog = g_new0(struct _icon_chooser, 1); -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ GtkWidget *vbox; -#else - GtkWidget *hbox; - GtkWidget *tv; - GtkTreeSelection *sel; -#endif /* FILECHOOSER */ const char *current_folder; dialog->callback = callback; dialog->data = data; current_folder = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/filelocations/last_icon_folder"); -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ dialog->icon_filesel = gtk_file_chooser_dialog_new(_("Buddy Icon"), parent, @@ -2524,39 +2305,6 @@ g_signal_connect(G_OBJECT(dialog->icon_filesel), "response", G_CALLBACK(icon_filesel_choose_cb), dialog); icon_preview_change_cb(NULL, dialog); -#else /* FILECHOOSER */ - dialog->icon_filesel = gtk_file_selection_new(_("Buddy Icon")); - dialog->icon_preview = gtk_image_new(); - dialog->icon_text = gtk_label_new(NULL); - if ((current_folder != NULL) && (*current_folder != '\0')) - gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog->icon_filesel), - current_folder); - - gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview),-1, 50); - 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); - gtk_box_pack_end(GTK_BOX(hbox), dialog->icon_preview, - FALSE, FALSE, 0); - gtk_box_pack_end(GTK_BOX(hbox), dialog->icon_text, FALSE, FALSE, 0); - - tv = GTK_FILE_SELECTION(dialog->icon_filesel)->file_list; - sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); - - g_signal_connect(G_OBJECT(sel), "changed", - G_CALLBACK(icon_preview_change_cb), dialog); - g_signal_connect( - G_OBJECT(GTK_FILE_SELECTION(dialog->icon_filesel)->ok_button), - "clicked", - G_CALLBACK(icon_filesel_choose_cb), dialog); - g_signal_connect( - G_OBJECT(GTK_FILE_SELECTION(dialog->icon_filesel)->cancel_button), - "clicked", - G_CALLBACK(icon_filesel_delete_cb), dialog); - g_signal_connect(G_OBJECT(dialog->icon_filesel), "destroy", - G_CALLBACK(icon_filesel_delete_cb), dialog); -#endif /* FILECHOOSER */ #ifdef _WIN32 g_signal_connect(G_OBJECT(dialog->icon_filesel), "show", @@ -2567,7 +2315,6 @@ } -#if GTK_CHECK_VERSION(2,2,0) static gboolean str_array_match(char **a, char **b) { @@ -2581,22 +2328,16 @@ return TRUE; return FALSE; } -#endif gpointer pidgin_convert_buddy_icon(PurplePlugin *plugin, const char *path, size_t *len) { PurplePluginProtocolInfo *prpl_info; -#if GTK_CHECK_VERSION(2,2,0) char **prpl_formats; int width, height; char **pixbuf_formats = NULL; GdkPixbufFormat *format; GdkPixbuf *pixbuf; -#if !GTK_CHECK_VERSION(2,4,0) - GdkPixbufLoader *loader; -#endif -#endif gchar *contents; gsize length; @@ -2605,22 +2346,8 @@ g_return_val_if_fail(prpl_info->icon_spec.format != NULL, NULL); -#if GTK_CHECK_VERSION(2,2,0) -#if GTK_CHECK_VERSION(2,4,0) format = gdk_pixbuf_get_file_info(path, &width, &height); -#else - loader = gdk_pixbuf_loader_new(); - if (g_file_get_contents(path, &contents, &length, NULL)) { - gdk_pixbuf_loader_write(loader, contents, length, NULL); - g_free(contents); - } - gdk_pixbuf_loader_close(loader, NULL); - pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); - width = gdk_pixbuf_get_width(pixbuf); - height = gdk_pixbuf_get_height(pixbuf); - format = gdk_pixbuf_loader_get_format(loader); - g_object_unref(G_OBJECT(loader)); -#endif + if (format == NULL) return NULL; @@ -2632,25 +2359,18 @@ prpl_info->icon_spec.max_width >= width && prpl_info->icon_spec.min_height <= height && prpl_info->icon_spec.max_height >= height))) /* The icon is the correct size */ -#endif { -#if GTK_CHECK_VERSION(2,2,0) g_strfreev(prpl_formats); g_strfreev(pixbuf_formats); -#endif + /* We don't need to scale the image. */ - contents = NULL; if (!g_file_get_contents(path, &contents, &length, NULL)) { g_free(contents); -#if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0) - g_object_unref(G_OBJECT(pixbuf)); -#endif return NULL; } } -#if GTK_CHECK_VERSION(2,2,0) else { int i; @@ -2771,156 +2491,8 @@ if (len) *len = length; return contents; -#else - /* - * The chosen icon wasn't the right size, and we're using - * GTK+ 2.0 so we can't scale it. - */ - return NULL; -#endif } -#if !GTK_CHECK_VERSION(2,6,0) -static void -_gdk_file_scale_size_prepared_cb (GdkPixbufLoader *loader, - int width, - int height, - gpointer data) -{ - struct { - gint width; - gint height; - gboolean preserve_aspect_ratio; - } *info = data; - - g_return_if_fail (width > 0 && height > 0); - - if (info->preserve_aspect_ratio && - (info->width > 0 || info->height > 0)) { - if (info->width < 0) - { - width = width * (double)info->height/(double)height; - height = info->height; - } - else if (info->height < 0) - { - height = height * (double)info->width/(double)width; - width = info->width; - } - else if ((double)height * (double)info->width > - (double)width * (double)info->height) { - width = 0.5 + (double)width * (double)info->height / (double)height; - height = info->height; - } else { - height = 0.5 + (double)height * (double)info->width / (double)width; - width = info->width; - } - } else { - if (info->width > 0) - width = info->width; - if (info->height > 0) - height = info->height; - } - -#if GTK_CHECK_VERSION(2,2,0) /* 2.0 users are going to have very strangely sized things */ - gdk_pixbuf_loader_set_size (loader, width, height); -#else -#warning nosnilmot could not be bothered to fix this properly for you -#warning ... good luck ... your images may end up strange sizes -#endif -} - -GdkPixbuf * -gdk_pixbuf_new_from_file_at_scale(const char *filename, int width, int height, - gboolean preserve_aspect_ratio, - GError **error) -{ - GdkPixbufLoader *loader; - GdkPixbuf *pixbuf; - guchar buffer [4096]; - int length; - FILE *f; - struct { - gint width; - gint height; - gboolean preserve_aspect_ratio; - } info; - GdkPixbufAnimation *animation; - GdkPixbufAnimationIter *iter; - gboolean has_frame; - - g_return_val_if_fail (filename != NULL, NULL); - g_return_val_if_fail (width > 0 || width == -1, NULL); - g_return_val_if_fail (height > 0 || height == -1, NULL); - - f = g_fopen (filename, "rb"); - if (!f) { - gint save_errno = errno; - gchar *display_name = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL); - g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (save_errno), - _("Failed to open file '%s': %s"), - display_name ? display_name : "(unknown)", - g_strerror (save_errno)); - g_free (display_name); - return NULL; - } - - loader = gdk_pixbuf_loader_new (); - - info.width = width; - info.height = height; - info.preserve_aspect_ratio = preserve_aspect_ratio; - - g_signal_connect (loader, "size-prepared", G_CALLBACK (_gdk_file_scale_size_prepared_cb), &info); - - has_frame = FALSE; - while (!has_frame && !feof (f) && !ferror (f)) { - length = fread (buffer, 1, sizeof (buffer), f); - if (length > 0) - if (!gdk_pixbuf_loader_write (loader, buffer, length, error)) { - gdk_pixbuf_loader_close (loader, NULL); - fclose (f); - g_object_unref (loader); - return NULL; - } - - animation = gdk_pixbuf_loader_get_animation (loader); - if (animation) { - iter = gdk_pixbuf_animation_get_iter (animation, 0); - if (!gdk_pixbuf_animation_iter_on_currently_loading_frame (iter)) { - has_frame = TRUE; - } - g_object_unref (iter); - } - } - - fclose (f); - - if (!gdk_pixbuf_loader_close (loader, error) && !has_frame) { - g_object_unref (loader); - return NULL; - } - - pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); - - if (!pixbuf) { - gchar *display_name = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL); - g_object_unref (loader); - g_set_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_FAILED, - _("Failed to load image '%s': reason not known, probably a corrupt image file"), - display_name ? display_name : "(unknown)"); - g_free (display_name); - return NULL; - } - - g_object_ref (pixbuf); - - g_object_unref (loader); - - return pixbuf; -} -#endif /* ! Gtk 2.6.0 */ - void pidgin_set_custom_buddy_icon(PurpleAccount *account, const char *who, const char *filename) { PurpleBuddy *buddy; @@ -2953,34 +2525,9 @@ void pidgin_set_urgent(GtkWindow *window, gboolean urgent) { -#if GTK_CHECK_VERSION(2,8,0) gtk_window_set_urgency_hint(window, urgent); -#elif defined _WIN32 +#if defined _WIN32 winpidgin_window_flash(window, urgent); -#elif defined GDK_WINDOWING_X11 - GdkWindow *gdkwin; - XWMHints *hints; - - g_return_if_fail(window != NULL); - - gdkwin = GTK_WIDGET(window)->window; - - g_return_if_fail(gdkwin != NULL); - - hints = XGetWMHints(GDK_WINDOW_XDISPLAY(gdkwin), - GDK_WINDOW_XWINDOW(gdkwin)); - if(!hints) - hints = XAllocWMHints(); - - if (urgent) - hints->flags |= XUrgencyHint; - else - hints->flags &= ~XUrgencyHint; - XSetWMHints(GDK_WINDOW_XDISPLAY(gdkwin), - GDK_WINDOW_XWINDOW(gdkwin), hints); - XFree(hints); -#else - /* do something else? */ #endif } @@ -3289,31 +2836,6 @@ return dim_grey_string; } -#if !GTK_CHECK_VERSION(2,2,0) -GtkTreePath * -gtk_tree_path_new_from_indices (gint first_index, ...) -{ - int arg; - va_list args; - GtkTreePath *path; - - path = gtk_tree_path_new (); - - va_start (args, first_index); - arg = first_index; - - while (arg != -1) - { - gtk_tree_path_append_index (path, arg); - arg = va_arg (args, gint); - } - - va_end (args); - - return path; -} -#endif - static void combo_box_changed_cb(GtkComboBox *combo_box, GtkEntry *entry) { @@ -3459,7 +2981,6 @@ return FALSE; #endif #else -#if GTK_CHECK_VERSION(2,4,0) /* This finds the currently active window and makes that the parent window. */ GList *windows = NULL; GtkWidget *parent = NULL; @@ -3502,7 +3023,6 @@ gtk_window_set_transient_for(GTK_WINDOW(widget), GTK_WINDOW(parent)); return TRUE; } -#endif return FALSE; #endif } @@ -3699,13 +3219,10 @@ gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); /* Open Containing Directory */ -#if GTK_CHECK_VERSION(2,6,0) img = gtk_image_new_from_stock(GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU); item = gtk_image_menu_item_new_with_mnemonic(_("Open _Containing Directory")); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img); -#else - item = gtk_menu_item_new_with_mnemonic(_("Open _Containing Directory")); -#endif + g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(open_containing_cb), (gpointer)url); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); @@ -3771,13 +3288,10 @@ url = gtk_imhtml_link_get_url(link); /* Play Sound */ -#if GTK_CHECK_VERSION(2,6,0) img = gtk_image_new_from_stock(GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_MENU); item = gtk_image_menu_item_new_with_mnemonic(_("_Play Sound")); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img); -#else - item = gtk_menu_item_new_with_mnemonic(_("_Play Sound")); -#endif + g_signal_connect_swapped(G_OBJECT(item), "activate", G_CALLBACK(gtk_imhtml_link_activate), link); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
--- a/pidgin/gtkutils.h Sun Aug 23 02:37:12 2009 +0000 +++ b/pidgin/gtkutils.h Sun Aug 23 05:04:15 2009 +0000 @@ -648,17 +648,6 @@ */ gpointer pidgin_convert_buddy_icon(PurplePlugin *plugin, const char *path, size_t *len); -#if !GTK_CHECK_VERSION(2,6,0) -/** - * Creates a new pixbuf by loading an image from a file. The image will - * be scaled to fit in the requested size, optionally preserving the image's - * aspect ratio. - */ -GdkPixbuf *gdk_pixbuf_new_from_file_at_scale(const char *filename, int width, int height, - gboolean preserve_aspect_ratio, - GError **error); -#endif - #if !(defined PIDGIN_DISABLE_DEPRECATED) || (defined _PIDGIN_GTKUTILS_C_) /** * Set or unset a custom buddyicon for a user. @@ -760,20 +749,6 @@ */ const char *pidgin_get_dim_grey_string(GtkWidget *widget); -#if !GTK_CHECK_VERSION(2,2,0) -/** - * This is copied from Gtk to support Gtk 2.0 - * - * Creates a new path with @a first_index and the varargs as indices. - * - * @param first_index first integer - * @param ... list of integers terminated by -1 - * - * @return A newly created GtkTreePath. - */ -GtkTreePath *gtk_tree_path_new_from_indices (gint first_index, ...); -#endif - /** * Create a simple text GtkComboBoxEntry equivalent *
--- a/pidgin/gtkwhiteboard.c Sun Aug 23 02:37:12 2009 +0000 +++ b/pidgin/gtkwhiteboard.c Sun Aug 23 05:04:15 2009 +0000 @@ -757,7 +757,6 @@ int result; -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ dialog = gtk_file_chooser_dialog_new (_("Save File"), GTK_WINDOW(gtkwb->window), GTK_FILE_CHOOSER_ACTION_SAVE, @@ -776,21 +775,15 @@ else gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), filename_for_existing_document); */ -#else - dialog = gtk_file_selection_new(_("Save File")); - gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog), "whiteboard.jpg"); -#endif + result = gtk_dialog_run(GTK_DIALOG(dialog)); if(result == GTK_RESPONSE_ACCEPT) { char *filename; -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); -#else - filename = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(dialog))); -#endif + gtk_widget_destroy(dialog); /* Makes an icon from the whiteboard's canvas 'image' */
--- a/pidgin/minidialog.c Sun Aug 23 02:37:12 2009 +0000 +++ b/pidgin/minidialog.c Sun Aug 23 05:04:15 2009 +0000 @@ -339,26 +339,20 @@ param_spec = g_param_spec_string("title", "title", "String specifying the mini-dialog's title", NULL, -#if GTK_CHECK_VERSION(2,8,0) G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | -#endif G_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_TITLE, param_spec); param_spec = g_param_spec_string("description", "description", "Description text for the mini-dialog, if desired", NULL, -#if GTK_CHECK_VERSION(2,8,0) G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | -#endif G_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_DESCRIPTION, param_spec); param_spec = g_param_spec_string("icon-name", "icon-name", "String specifying the Gtk stock name of the dialog's icon", NULL, -#if GTK_CHECK_VERSION(2,8,0) G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | -#endif G_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_ICON_NAME, param_spec); }
--- a/pidgin/pidgin.h Sun Aug 23 02:37:12 2009 +0000 +++ b/pidgin/pidgin.h Sun Aug 23 05:04:15 2009 +0000 @@ -57,33 +57,6 @@ #endif /* - * This is backwards-compatibility code for older versions of GTK+ (< 2.4.x) - * It defines the new wrap behavior (unknown in earlier versions) - * as the old (slightly buggy) wrap behavior. - * It also includes our back-ported GtkExpander - */ -/** @cond */ -#if (!GTK_CHECK_VERSION(2,4,0)) -# define GTK_WRAP_WORD_CHAR GTK_WRAP_WORD -# include "gtkexpander.h" -#endif -/** @endcond */ - -/* - * We include the sources for GtkComboBox and GtkCellView because - * they don't exist in older versions of GTK+, and we use them - * in a few places. - */ -#if !GTK_CHECK_VERSION(2,6,0) -# include "gtkcellview.h" -# include "gtkcellviewmenuitem.h" -# include "pidgincombobox.h" -# if !GTK_CHECK_VERSION(2,4,0) -# include "gtkcelllayout.h" -# endif /* Less than GTK+ 2.4 */ -#endif /* Less than GTK+ 2.6 */ - -/* * Spacings between components, as defined by the * GNOME Human Interface Guidelines. */