changeset 11780:8cb75ba77f9d

[gaim-migrate @ 14071] I've been time travelling, I bumped into Gtk 2.0 on my way. Gaim now works with Gtk 2.0 again. Next stop: gtk 1.2 ... erm. what? ... NO! PS. resiak: I won! committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Mon, 24 Oct 2005 00:31:41 +0000
parents 80af53b5b3c5
children 10317f1a2de2
files src/gtkcombobox.c src/gtkconv.c src/gtklog.c src/gtkrequest.c src/gtksavedstatuses.c src/gtkutils.c src/mime.c src/util.c
diffstat 8 files changed, 93 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkcombobox.c	Mon Oct 24 00:18:37 2005 +0000
+++ b/src/gtkcombobox.c	Mon Oct 24 00:31:41 2005 +0000
@@ -43,6 +43,7 @@
 */
 #include <gtk/gtkvseparator.h>
 #include <gtk/gtkwindow.h>
+#include <gtk/gtkversion.h>
 
 #include <gdk/gdkkeysyms.h>
 
@@ -233,6 +234,7 @@
 
 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,
@@ -248,6 +250,7 @@
                                                     gint             *y,
                                                     gint             *push_in,
                                                     gpointer          user_data);
+#endif
 
 static gint     gtk_combo_box_calc_requested_width (GtkComboBox      *combo_box,
                                                     GtkTreePath      *path);
@@ -292,11 +295,13 @@
 						    gpointer          data);
 
 /* list */
+#if GTK_CHECK_VERSION(2,2,0)
 static void     gtk_combo_box_list_position        (GtkComboBox      *combo_box, 
 						    gint             *x, 
 						    gint             *y, 
 						    gint             *width,
 						    gint             *height);
+#endif
 static void     gtk_combo_box_list_setup           (GtkComboBox      *combo_box);
 static void     gtk_combo_box_list_destroy         (GtkComboBox      *combo_box);
 
@@ -909,8 +914,10 @@
         {
           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),
@@ -929,6 +936,7 @@
     }
 }
 
+#if GTK_CHECK_VERSION(2,2,0)
 static void
 gtk_combo_box_menu_position_below (GtkMenu  *menu,
 				   gint     *x,
@@ -1133,6 +1141,7 @@
   else
     *y -= *height;
 } 
+#endif /* Gtk 2.2 */
 
 /**
  * gtk_combo_box_popup:
@@ -1148,7 +1157,10 @@
 void
 gtk_combo_box_popup (GtkComboBox *combo_box)
 {
-  gint x, y, width, height;
+  gint x, y, width;
+#if GTK_CHECK_VERSION(2,2,0)
+  gint height;
+#endif
   
   g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
 
@@ -1173,13 +1185,19 @@
       
       gtk_menu_popup (GTK_MENU (combo_box->priv->popup_widget),
 		      NULL, NULL,
-		      gtk_combo_box_menu_position, combo_box,
-		      0, 0);
+#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);
+#if GTK_CHECK_VERSION(2,2,0)
   gtk_combo_box_list_position (combo_box, &x, &y, &width, &height);
+#endif
 
   gtk_widget_set_size_request (combo_box->priv->popup_window, width, -1);  
   gtk_window_move (GTK_WINDOW (combo_box->priv->popup_window), x, y);
@@ -1278,7 +1296,11 @@
 
   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,
@@ -1745,8 +1767,13 @@
   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",
@@ -1983,8 +2010,12 @@
 
       gtk_menu_popup (GTK_MENU (combo_box->priv->popup_widget),
                       NULL, NULL,
-                      gtk_combo_box_menu_position, combo_box,
-                      event->button, event->time);
+#if GTK_CHECK_VERSION(2,2,0)
+                      gtk_combo_box_menu_position,
+#else
+		      NULL,
+#endif
+		      combo_box, event->button, event->time);
 
       return TRUE;
     }
@@ -2291,7 +2322,13 @@
     {
       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),
@@ -3195,7 +3232,13 @@
     }
   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);
@@ -3235,6 +3278,9 @@
   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);
 
@@ -3242,7 +3288,12 @@
   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);
--- a/src/gtkconv.c	Mon Oct 24 00:18:37 2005 +0000
+++ b/src/gtkconv.c	Mon Oct 24 00:31:41 2005 +0000
@@ -1791,7 +1791,11 @@
 			case GDK_period:
 				gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook),
 						gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv),
+#if GTK_CHECK_VERSION(2,2,0)
 						(curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook)));
+#else
+						(curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children));
+#endif
 				break;
 
 		} /* End of switch */
@@ -5246,7 +5250,12 @@
 	horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP ||
 			gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM);
 
+#if GTK_CHECK_VERSION(2,2,0)
 	count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook));
+#else
+	/* this is hacky, but it's only for Gtk 2.0.0... */
+	count = g_list_length(GTK_NOTEBOOK(notebook)->children);
+#endif
 
 	for (i = 0; i < count; i++) {
 
--- a/src/gtklog.c	Mon Oct 24 00:18:37 2005 +0000
+++ b/src/gtklog.c	Mon Oct 24 00:31:41 2005 +0000
@@ -287,7 +287,9 @@
 	GtkCellRenderer *rend;
 	GtkTreeViewColumn *col;
 	GtkTreeSelection *sel;
+#if GTK_CHECK_VERSION(2,2,0)
 	GtkTreePath *path_to_first_log;
+#endif
 	GtkWidget *vbox;
 	GtkWidget *frame;
 	GtkWidget *hbox;
@@ -423,6 +425,7 @@
 	g_signal_connect(GTK_BUTTON(button), "activate", G_CALLBACK(search_cb), lv);
 	g_signal_connect(GTK_BUTTON(button), "clicked", G_CALLBACK(search_cb), lv);
 
+#if GTK_CHECK_VERSION(2,2,0)
 	/* Show most recent log **********/
 	path_to_first_log = gtk_tree_path_new_from_string("0:0");
 	if (path_to_first_log)
@@ -431,6 +434,7 @@
 		gtk_tree_selection_select_path(sel, path_to_first_log);
 		gtk_tree_path_free(path_to_first_log);
 	}
+#endif
 
 	gtk_widget_show_all(lv->window);
 
--- a/src/gtkrequest.c	Mon Oct 24 00:18:37 2005 +0000
+++ b/src/gtkrequest.c	Mon Oct 24 00:31:41 2005 +0000
@@ -26,6 +26,7 @@
 #include "gtkgaim.h"
 
 #include "prefs.h"
+#include "util.h"
 
 #include "gtkimhtml.h"
 #include "gtkimhtmltoolbar.h"
@@ -741,7 +742,7 @@
 
 	gtk_tree_model_get_value(model, iter, 2, &val1);
 	tmp = g_value_get_string(&val1);
-	if (tmp != NULL && g_str_has_prefix(tmp, key))
+	if (tmp != NULL && gaim_str_has_prefix(tmp, key))
 	{
 		g_value_unset(&val1);
 		return TRUE;
@@ -750,7 +751,7 @@
 
 	gtk_tree_model_get_value(model, iter, 3, &val2);
 	tmp = g_value_get_string(&val2);
-	if (tmp != NULL && g_str_has_prefix(tmp, key))
+	if (tmp != NULL && gaim_str_has_prefix(tmp, key))
 	{
 		g_value_unset(&val2);
 		return TRUE;
--- a/src/gtksavedstatuses.c	Mon Oct 24 00:18:37 2005 +0000
+++ b/src/gtksavedstatuses.c	Mon Oct 24 00:31:41 2005 +0000
@@ -206,6 +206,15 @@
 	gaim_gtk_status_window_hide();
 }
 
+#if !GTK_CHECK_VERSION(2,2,0)
+static void
+get_selected_helper(GtkTreeModel *model, GtkTreePath *path,
+					GtkTreeIter *iter, gpointer user_data)
+{
+	*((gboolean *)user_data) = TRUE;
+}
+#endif
+
 static void
 status_selected_cb(GtkTreeSelection *sel, gpointer user_data)
 {
--- a/src/gtkutils.c	Mon Oct 24 00:18:37 2005 +0000
+++ b/src/gtkutils.c	Mon Oct 24 00:31:41 2005 +0000
@@ -1549,7 +1549,7 @@
 
 #ifndef _WIN32
 		/* Are we trying to send a .desktop file? */
-		else if (g_str_has_suffix(basename, ".desktop") && (item = gaim_desktop_item_new_from_file(filename))) {
+		else if (gaim_str_has_suffix(basename, ".desktop") && (item = gaim_desktop_item_new_from_file(filename))) {
 			GaimDesktopItemType dtype;
 			char key[64];
 			const char *itemname = NULL;
--- a/src/mime.c	Mon Oct 24 00:18:37 2005 +0000
+++ b/src/mime.c	Mon Oct 24 00:31:41 2005 +0000
@@ -431,7 +431,7 @@
 
   {
     const char *ct = fields_get(&doc->fields, "content-type");
-    if(ct && g_str_has_prefix(ct, "multipart")) {
+    if(ct && gaim_str_has_prefix(ct, "multipart")) {
       char *bd = strrchr(ct, '=');
       if(bd++) {
 	doc_parts_load(doc, bd, b, n);
@@ -457,7 +457,7 @@
 
   {
     const char *ct = fields_get(&doc->fields, "content-type");
-    if(ct && g_str_has_prefix(ct, "multipart")) {
+    if(ct && gaim_str_has_prefix(ct, "multipart")) {
       char *b = strrchr(ct, '=');
       if(b++) bd = b;
     }
--- a/src/util.c	Mon Oct 24 00:18:37 2005 +0000
+++ b/src/util.c	Mon Oct 24 00:31:41 2005 +0000
@@ -2388,21 +2388,29 @@
 gboolean
 gaim_str_has_prefix(const char *s, const char *p)
 {
+#if GLIB_CHECK_VERSION(2,2,0)
+	return g_str_has_prefix(s, p);
+#else
 	if (!strncmp(s, p, strlen(p)))
 		return TRUE;
 
 	return FALSE;
+#endif
 }
 
 gboolean
 gaim_str_has_suffix(const char *s, const char *x)
 {
+#if GLIB_CHECK_VERSION(2,2,0)
+	return g_str_has_suffix(s, x);
+#else
 	int off = strlen(s) - strlen(x);
 
 	if (off >= 0 && !strcmp(s + off, x))
 		return TRUE;
 
 	return FALSE;
+#endif
 }
 
 char *