comparison pidgin/gtkstatusbox.c @ 29481: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 6e1a582ae629
children e3206d6da6c7
comparison
equal deleted inserted replaced
29480:e2c8fe39a2f1 29481:2dcff225172e
1167 status_box->typing = purple_timeout_add_seconds(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box); 1167 status_box->typing = purple_timeout_add_seconds(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box);
1168 1168
1169 return FALSE; 1169 return FALSE;
1170 } 1170 }
1171 1171
1172 #if GTK_CHECK_VERSION(2,6,0)
1173 static gboolean 1172 static gboolean
1174 dropdown_store_row_separator_func(GtkTreeModel *model, 1173 dropdown_store_row_separator_func(GtkTreeModel *model,
1175 GtkTreeIter *iter, gpointer data) 1174 GtkTreeIter *iter, gpointer data)
1176 { 1175 {
1177 PidginStatusBoxItemType type; 1176 PidginStatusBoxItemType type;
1181 if (type == PIDGIN_STATUS_BOX_TYPE_SEPARATOR) 1180 if (type == PIDGIN_STATUS_BOX_TYPE_SEPARATOR)
1182 return TRUE; 1181 return TRUE;
1183 1182
1184 return FALSE; 1183 return FALSE;
1185 } 1184 }
1186 #endif
1187 1185
1188 static void 1186 static void
1189 cache_pixbufs(PidginStatusBox *status_box) 1187 cache_pixbufs(PidginStatusBox *status_box)
1190 { 1188 {
1191 GtkIconSize icon_size; 1189 GtkIconSize icon_size;
1291 #endif 1289 #endif
1292 1290
1293 static void 1291 static void
1294 pidgin_status_box_list_position (PidginStatusBox *status_box, int *x, int *y, int *width, int *height) 1292 pidgin_status_box_list_position (PidginStatusBox *status_box, int *x, int *y, int *width, int *height)
1295 { 1293 {
1296 #if GTK_CHECK_VERSION(2,2,0)
1297 GdkScreen *screen; 1294 GdkScreen *screen;
1298 gint monitor_num; 1295 gint monitor_num;
1299 GdkRectangle monitor; 1296 GdkRectangle monitor;
1300 #endif
1301 GtkRequisition popup_req; 1297 GtkRequisition popup_req;
1302 GtkPolicyType hpolicy, vpolicy; 1298 GtkPolicyType hpolicy, vpolicy;
1303 1299
1304 gdk_window_get_origin (GTK_WIDGET(status_box)->window, x, y); 1300 gdk_window_get_origin (GTK_WIDGET(status_box)->window, x, y);
1305 1301
1321 gtk_widget_size_request (status_box->popup_frame, &popup_req); 1317 gtk_widget_size_request (status_box->popup_frame, &popup_req);
1322 } 1318 }
1323 1319
1324 *height = popup_req.height; 1320 *height = popup_req.height;
1325 1321
1326 #if GTK_CHECK_VERSION(2,2,0)
1327 screen = gtk_widget_get_screen (GTK_WIDGET (status_box)); 1322 screen = gtk_widget_get_screen (GTK_WIDGET (status_box));
1328 monitor_num = gdk_screen_get_monitor_at_window (screen, 1323 monitor_num = gdk_screen_get_monitor_at_window (screen,
1329 GTK_WIDGET (status_box)->window); 1324 GTK_WIDGET (status_box)->window);
1330 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); 1325 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
1331 1326
1354 vpolicy = GTK_POLICY_ALWAYS; 1349 vpolicy = GTK_POLICY_ALWAYS;
1355 1350
1356 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (status_box->scrolled_window), 1351 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (status_box->scrolled_window),
1357 hpolicy, vpolicy); 1352 hpolicy, vpolicy);
1358 } 1353 }
1359 #endif
1360 } 1354 }
1361 1355
1362 static gboolean 1356 static gboolean
1363 popup_grab_on_window (GdkWindow *window, 1357 popup_grab_on_window (GdkWindow *window,
1364 guint32 activate_time, 1358 guint32 activate_time,
1365 gboolean grab_keyboard) 1359 gboolean grab_keyboard)
1366 { 1360 {
1367 if ((gdk_pointer_grab (window, TRUE, 1361 if ((gdk_pointer_grab (window, TRUE,
1368 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | 1362 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
1369 GDK_POINTER_MOTION_MASK, 1363 GDK_POINTER_MOTION_MASK,
1370 NULL, NULL, activate_time) == 0)) 1364 NULL, NULL, activate_time) == 0))
1371 { 1365 {
1372 if (!grab_keyboard || 1366 if (!grab_keyboard || gdk_keyboard_grab (window, TRUE, activate_time) == 0)
1373 gdk_keyboard_grab (window, TRUE, 1367 return TRUE;
1374 activate_time) == 0) 1368 else {
1375 return TRUE; 1369 gdk_display_pointer_ungrab (gdk_drawable_get_display (window), activate_time);
1376 else 1370 return FALSE;
1377 { 1371 }
1378 #if GTK_CHECK_VERSION(2,2,0) 1372 }
1379 gdk_display_pointer_ungrab (gdk_drawable_get_display (window), 1373
1380 activate_time); 1374 return FALSE;
1381 #else
1382 gdk_pointer_ungrab(activate_time);
1383 gdk_keyboard_ungrab(activate_time);
1384 #endif
1385 return FALSE;
1386 }
1387 }
1388
1389 return FALSE;
1390 } 1375 }
1391 1376
1392 1377
1393 static void 1378 static void
1394 pidgin_status_box_popup(PidginStatusBox *box) 1379 pidgin_status_box_popup(PidginStatusBox *box)
1779 gtk_container_add(GTK_CONTAINER(status_box->toggle_button), status_box->hbox); 1764 gtk_container_add(GTK_CONTAINER(status_box->toggle_button), status_box->hbox);
1780 gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->cell_view, TRUE, TRUE, 0); 1765 gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->cell_view, TRUE, TRUE, 0);
1781 gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->vsep, FALSE, FALSE, 0); 1766 gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->vsep, FALSE, FALSE, 0);
1782 gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->arrow, FALSE, FALSE, 0); 1767 gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->arrow, FALSE, FALSE, 0);
1783 gtk_widget_show_all(status_box->toggle_button); 1768 gtk_widget_show_all(status_box->toggle_button);
1784 #if GTK_CHECK_VERSION(2,4,0)
1785 gtk_button_set_focus_on_click(GTK_BUTTON(status_box->toggle_button), FALSE); 1769 gtk_button_set_focus_on_click(GTK_BUTTON(status_box->toggle_button), FALSE);
1786 #endif
1787 1770
1788 text_rend = gtk_cell_renderer_text_new(); 1771 text_rend = gtk_cell_renderer_text_new();
1789 icon_rend = gtk_cell_renderer_pixbuf_new(); 1772 icon_rend = gtk_cell_renderer_pixbuf_new();
1790 emblem_rend = gtk_cell_renderer_pixbuf_new(); 1773 emblem_rend = gtk_cell_renderer_pixbuf_new();
1791 status_box->popup_window = gtk_window_new (GTK_WINDOW_POPUP); 1774 status_box->popup_window = gtk_window_new (GTK_WINDOW_POPUP);
1795 gtk_window_set_transient_for (GTK_WINDOW (status_box->popup_window), 1778 gtk_window_set_transient_for (GTK_WINDOW (status_box->popup_window),
1796 GTK_WINDOW (toplevel)); 1779 GTK_WINDOW (toplevel));
1797 } 1780 }
1798 1781
1799 gtk_window_set_resizable (GTK_WINDOW (status_box->popup_window), FALSE); 1782 gtk_window_set_resizable (GTK_WINDOW (status_box->popup_window), FALSE);
1800 #if GTK_CHECK_VERSION(2,10,0)
1801 gtk_window_set_type_hint (GTK_WINDOW (status_box->popup_window), 1783 gtk_window_set_type_hint (GTK_WINDOW (status_box->popup_window),
1802 GDK_WINDOW_TYPE_HINT_POPUP_MENU); 1784 GDK_WINDOW_TYPE_HINT_POPUP_MENU);
1803 #endif
1804 #if GTK_CHECK_VERSION(2,2,0)
1805 gtk_window_set_screen (GTK_WINDOW (status_box->popup_window), 1785 gtk_window_set_screen (GTK_WINDOW (status_box->popup_window),
1806 gtk_widget_get_screen (GTK_WIDGET (status_box))); 1786 gtk_widget_get_screen (GTK_WIDGET (status_box)));
1807 #endif
1808 status_box->popup_frame = gtk_frame_new (NULL); 1787 status_box->popup_frame = gtk_frame_new (NULL);
1809 gtk_frame_set_shadow_type (GTK_FRAME (status_box->popup_frame), 1788 gtk_frame_set_shadow_type (GTK_FRAME (status_box->popup_frame),
1810 GTK_SHADOW_ETCHED_IN); 1789 GTK_SHADOW_ETCHED_IN);
1811 gtk_container_add (GTK_CONTAINER (status_box->popup_window), 1790 gtk_container_add (GTK_CONTAINER (status_box->popup_window),
1812 status_box->popup_frame); 1791 status_box->popup_frame);
1829 status_box->tree_view = gtk_tree_view_new (); 1808 status_box->tree_view = gtk_tree_view_new ();
1830 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (status_box->tree_view)); 1809 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (status_box->tree_view));
1831 gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE); 1810 gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE);
1832 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (status_box->tree_view), 1811 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (status_box->tree_view),
1833 FALSE); 1812 FALSE);
1834 #if GTK_CHECK_VERSION(2,6,0)
1835 gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (status_box->tree_view), 1813 gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (status_box->tree_view),
1836 TRUE); 1814 TRUE);
1837 #endif
1838 gtk_tree_view_set_model (GTK_TREE_VIEW (status_box->tree_view), 1815 gtk_tree_view_set_model (GTK_TREE_VIEW (status_box->tree_view),
1839 GTK_TREE_MODEL(status_box->dropdown_store)); 1816 GTK_TREE_MODEL(status_box->dropdown_store));
1840 status_box->column = gtk_tree_view_column_new (); 1817 status_box->column = gtk_tree_view_column_new ();
1841 gtk_tree_view_append_column (GTK_TREE_VIEW (status_box->tree_view), 1818 gtk_tree_view_append_column (GTK_TREE_VIEW (status_box->tree_view),
1842 status_box->column); 1819 status_box->column);
1850 gtk_widget_show(status_box->tree_view); 1827 gtk_widget_show(status_box->tree_view);
1851 gtk_tree_view_set_search_column(GTK_TREE_VIEW(status_box->tree_view), TEXT_COLUMN); 1828 gtk_tree_view_set_search_column(GTK_TREE_VIEW(status_box->tree_view), TEXT_COLUMN);
1852 gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(status_box->tree_view), 1829 gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(status_box->tree_view),
1853 pidgin_tree_view_search_equal_func, NULL, NULL); 1830 pidgin_tree_view_search_equal_func, NULL, NULL);
1854 1831
1855 #if GTK_CHECK_VERSION(2, 6, 0)
1856 g_object_set(text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); 1832 g_object_set(text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
1857 #endif
1858 1833
1859 status_box->icon_rend = gtk_cell_renderer_pixbuf_new(); 1834 status_box->icon_rend = gtk_cell_renderer_pixbuf_new();
1860 status_box->text_rend = gtk_cell_renderer_text_new(); 1835 status_box->text_rend = gtk_cell_renderer_text_new();
1861 emblem_rend = gtk_cell_renderer_pixbuf_new(); 1836 emblem_rend = gtk_cell_renderer_pixbuf_new();
1862 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE); 1837 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE);
1863 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE); 1838 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE);
1864 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), emblem_rend, FALSE); 1839 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), emblem_rend, FALSE);
1865 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "stock-id", ICON_STOCK_COLUMN, NULL); 1840 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "stock-id", ICON_STOCK_COLUMN, NULL);
1866 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); 1841 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL);
1867 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), emblem_rend, "pixbuf", EMBLEM_COLUMN, "visible", EMBLEM_VISIBLE_COLUMN, NULL); 1842 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), emblem_rend, "pixbuf", EMBLEM_COLUMN, "visible", EMBLEM_VISIBLE_COLUMN, NULL);
1868 #if GTK_CHECK_VERSION(2, 6, 0)
1869 g_object_set(status_box->text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); 1843 g_object_set(status_box->text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
1870 #endif
1871 1844
1872 status_box->vbox = gtk_vbox_new(0, FALSE); 1845 status_box->vbox = gtk_vbox_new(0, FALSE);
1873 status_box->sw = pidgin_create_imhtml(FALSE, &status_box->imhtml, NULL, NULL); 1846 status_box->sw = pidgin_create_imhtml(FALSE, &status_box->imhtml, NULL, NULL);
1874 gtk_imhtml_set_editable(GTK_IMHTML(status_box->imhtml), TRUE); 1847 gtk_imhtml_set_editable(GTK_IMHTML(status_box->imhtml), TRUE);
1875 1848
1910 g_signal_connect(G_OBJECT(status_box->popup_window), "button_release_event", G_CALLBACK(treeview_button_release_cb), status_box); 1883 g_signal_connect(G_OBJECT(status_box->popup_window), "button_release_event", G_CALLBACK(treeview_button_release_cb), status_box);
1911 g_signal_connect(G_OBJECT(status_box->popup_window), "key_press_event", G_CALLBACK(treeview_key_press_event), status_box); 1884 g_signal_connect(G_OBJECT(status_box->popup_window), "key_press_event", G_CALLBACK(treeview_key_press_event), status_box);
1912 g_signal_connect(G_OBJECT(status_box->tree_view), "cursor-changed", 1885 g_signal_connect(G_OBJECT(status_box->tree_view), "cursor-changed",
1913 G_CALLBACK(treeview_cursor_changed_cb), status_box->dropdown_store); 1886 G_CALLBACK(treeview_cursor_changed_cb), status_box->dropdown_store);
1914 1887
1915 #if GTK_CHECK_VERSION(2,6,0)
1916 gtk_tree_view_set_row_separator_func(GTK_TREE_VIEW(status_box->tree_view), dropdown_store_row_separator_func, NULL, NULL); 1888 gtk_tree_view_set_row_separator_func(GTK_TREE_VIEW(status_box->tree_view), dropdown_store_row_separator_func, NULL, NULL);
1917 #endif
1918 1889
1919 status_box->token_status_account = check_active_accounts_for_identical_statuses(); 1890 status_box->token_status_account = check_active_accounts_for_identical_statuses();
1920 1891
1921 cache_pixbufs(status_box); 1892 cache_pixbufs(status_box);
1922 pidgin_status_box_regenerate(status_box); 1893 pidgin_status_box_regenerate(status_box);
2196 void 2167 void
2197 pidgin_status_box_add_separator(PidginStatusBox *status_box) 2168 pidgin_status_box_add_separator(PidginStatusBox *status_box)
2198 { 2169 {
2199 /* Don't do anything unless GTK actually supports 2170 /* Don't do anything unless GTK actually supports
2200 * gtk_combo_box_set_row_separator_func */ 2171 * gtk_combo_box_set_row_separator_func */
2201 #if GTK_CHECK_VERSION(2,6,0)
2202 GtkTreeIter iter; 2172 GtkTreeIter iter;
2203 2173
2204 gtk_list_store_append(status_box->dropdown_store, &iter); 2174 gtk_list_store_append(status_box->dropdown_store, &iter);
2205 gtk_list_store_set(status_box->dropdown_store, &iter, 2175 gtk_list_store_set(status_box->dropdown_store, &iter,
2206 TYPE_COLUMN, PIDGIN_STATUS_BOX_TYPE_SEPARATOR, 2176 TYPE_COLUMN, PIDGIN_STATUS_BOX_TYPE_SEPARATOR,
2207 -1); 2177 -1);
2208 #endif
2209 } 2178 }
2210 2179
2211 void 2180 void
2212 pidgin_status_box_set_network_available(PidginStatusBox *status_box, gboolean available) 2181 pidgin_status_box_set_network_available(PidginStatusBox *status_box, gboolean available)
2213 { 2182 {
2227 } 2196 }
2228 2197
2229 static void 2198 static void
2230 pixbuf_size_prepared_cb(GdkPixbufLoader *loader, int width, int height, gpointer data) 2199 pixbuf_size_prepared_cb(GdkPixbufLoader *loader, int width, int height, gpointer data)
2231 { 2200 {
2232 #if GTK_CHECK_VERSION(2,2,0)
2233 int w, h; 2201 int w, h;
2234 GtkIconSize icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_MEDIUM); 2202 GtkIconSize icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_MEDIUM);
2235 gtk_icon_size_lookup(icon_size, &w, &h); 2203 gtk_icon_size_lookup(icon_size, &w, &h);
2236 if (height > width) 2204 if (height > width)
2237 w = width * h / height; 2205 w = width * h / height;
2238 else if (width > height) 2206 else if (width > height)
2239 h = height * w / width; 2207 h = height * w / width;
2240 gdk_pixbuf_loader_set_size(loader, w, h); 2208 gdk_pixbuf_loader_set_size(loader, w, h);
2241 #endif
2242 } 2209 }
2243 2210
2244 static void 2211 static void
2245 pidgin_status_box_redisplay_buddy_icon(PidginStatusBox *status_box) 2212 pidgin_status_box_redisplay_buddy_icon(PidginStatusBox *status_box)
2246 { 2213 {