comparison gtk/gtkstatusbox.c @ 15084:8fc4d62b14ad

[gaim-migrate @ 17869] A few tweaks to new statusbox look and feel. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Fri, 01 Dec 2006 23:34:40 +0000
parents 32814a36f363
children 072987463f90
comparison
equal deleted inserted replaced
15083:133af8458cbd 15084:8fc4d62b14ad
765 765
766 g_free(name); 766 g_free(name);
767 break; 767 break;
768 } 768 }
769 g_free(name); 769 g_free(name);
770 } 770
771 else if ((type == GTK_GAIM_STATUS_BOX_TYPE_POPULAR) && 771 } else if ((type == GTK_GAIM_STATUS_BOX_TYPE_POPULAR) &&
772 (GPOINTER_TO_INT(data) == gaim_savedstatus_get_creation_time(saved_status))) 772 (GPOINTER_TO_INT(data) == gaim_savedstatus_get_creation_time(saved_status)))
773 { 773 {
774 /* Found! */ 774 /* Found! */
775 // gtk_combo_box_set_active_iter(GTK_COMBO_BOX(status_box), &iter); 775 // gtk_combo_box_set_active_iter(GTK_COMBO_BOX(status_box), &iter);
776 break; 776 break;
1250 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (status_box->scrolled_window), 1250 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (status_box->scrolled_window),
1251 hpolicy, vpolicy); 1251 hpolicy, vpolicy);
1252 } 1252 }
1253 } 1253 }
1254 1254
1255 popup_grab_on_window (GdkWindow *window,
1256 guint32 activate_time,
1257 gboolean grab_keyboard)
1258 {
1259 if ((gdk_pointer_grab (window, TRUE,
1260 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
1261 GDK_POINTER_MOTION_MASK,
1262 NULL, NULL, activate_time) == 0))
1263 {
1264 if (!grab_keyboard ||
1265 gdk_keyboard_grab (window, TRUE,
1266 activate_time) == 0)
1267 return TRUE;
1268 else
1269 {
1270 gdk_display_pointer_ungrab (gdk_drawable_get_display (window),
1271 activate_time);
1272 return FALSE;
1273 }
1274 }
1275
1276 return FALSE;
1277 }
1278
1279
1255 static void 1280 static void
1256 gaim_gtk_status_box_popup(GtkGaimStatusBox *box) 1281 gaim_gtk_status_box_popup(GtkGaimStatusBox *box)
1257 { 1282 {
1258 int width, height, x, y; 1283 int width, height, x, y;
1259 gtk_gaim_status_box_list_position (box, &x, &y, &width, &height); 1284 gtk_gaim_status_box_list_position (box, &x, &y, &width, &height);
1260 1285
1261 gtk_widget_set_size_request (box->popup_window, width, height); 1286 gtk_widget_set_size_request (box->popup_window, width, height);
1262 gtk_window_move (GTK_WINDOW (box->popup_window), x, y); 1287 gtk_window_move (GTK_WINDOW (box->popup_window), x, y);
1263 gtk_widget_show(box->popup_window); 1288 gtk_widget_show(box->popup_window);
1289 gtk_widget_grab_focus (box->tree_view);
1290 if (!popup_grab_on_window (box->popup_window->window,
1291 GDK_CURRENT_TIME, TRUE)) {
1292 gtk_widget_hide (box->popup_window);
1293 return;
1294 }
1295 gtk_grab_add (box->popup_window);
1264 box->popup_in_progress = TRUE; 1296 box->popup_in_progress = TRUE;
1297 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (box->toggle_button),
1298 TRUE);
1299
1265 } 1300 }
1266 1301
1267 static void 1302 static void
1268 gaim_gtk_status_box_popdown(GtkGaimStatusBox *box) { 1303 gaim_gtk_status_box_popdown(GtkGaimStatusBox *box) {
1269 gtk_widget_hide(box->popup_window); 1304 gtk_widget_hide(box->popup_window);
1270 box->popup_in_progress = FALSE; 1305 box->popup_in_progress = FALSE;
1271 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (box->toggle_button), 1306 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (box->toggle_button),
1272 FALSE); 1307 FALSE);
1273 1308 gtk_grab_remove (box->popup_window);
1274 } 1309 }
1275 1310
1276 1311
1277 static void 1312 static void
1278 toggled_cb(GtkWidget *widget, GtkGaimStatusBox *box) 1313 toggled_cb(GtkWidget *widget, GtkGaimStatusBox *box)
1364 1399
1365 static gboolean 1400 static gboolean
1366 treeview_button_release_cb(GtkWidget *widget, GdkEventButton *event, GtkGaimStatusBox *status_box) 1401 treeview_button_release_cb(GtkWidget *widget, GdkEventButton *event, GtkGaimStatusBox *status_box)
1367 { 1402 {
1368 GtkTreePath *path = NULL; 1403 GtkTreePath *path = NULL;
1369 int ret = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (status_box->tree_view), 1404 int ret;
1405 GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event);
1406
1407 if (ewidget != status_box->tree_view) {
1408 if (ewidget == status_box->toggle_button &&
1409 !status_box->popup_in_progress &&
1410 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (status_box->toggle_button))) {
1411 gaim_gtk_status_box_popdown (status_box);
1412 return TRUE;
1413 }
1414
1415 /* released outside treeview */
1416 if (ewidget != status_box->toggle_button)
1417 {
1418 gaim_gtk_status_box_popdown (status_box);
1419 return TRUE;
1420 }
1421
1422 return FALSE;
1423 }
1424
1425 ret = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (status_box->tree_view),
1370 event->x, event->y, 1426 event->x, event->y,
1371 &path, 1427 &path,
1372 NULL, NULL, NULL); 1428 NULL, NULL, NULL);
1429
1373 1430
1374 if (!ret) 1431 if (!ret)
1375 return TRUE; /* clicked outside window? */ 1432 return TRUE; /* clicked outside window? */
1376 1433
1377 if (status_box->active_row) 1434 if (status_box->active_row)
1522 gtk_box_pack_start(GTK_BOX(status_box->vbox), status_box->sw, TRUE, TRUE, 0); 1579 gtk_box_pack_start(GTK_BOX(status_box->vbox), status_box->sw, TRUE, TRUE, 0);
1523 1580
1524 g_signal_connect(G_OBJECT(status_box), "scroll_event", G_CALLBACK(combo_box_scroll_event_cb), NULL); 1581 g_signal_connect(G_OBJECT(status_box), "scroll_event", G_CALLBACK(combo_box_scroll_event_cb), NULL);
1525 g_signal_connect(G_OBJECT(status_box->imhtml), "scroll_event", 1582 g_signal_connect(G_OBJECT(status_box->imhtml), "scroll_event",
1526 G_CALLBACK(imhtml_scroll_event_cb), status_box->imhtml); 1583 G_CALLBACK(imhtml_scroll_event_cb), status_box->imhtml);
1527 g_signal_connect(G_OBJECT(status_box->tree_view), "button_release_event", G_CALLBACK(treeview_button_release_cb), status_box); 1584 g_signal_connect(G_OBJECT(status_box->popup_window), "button_release_event", G_CALLBACK(treeview_button_release_cb), status_box);
1528 1585
1529 #if GTK_CHECK_VERSION(2,6,0) 1586 #if GTK_CHECK_VERSION(2,6,0)
1530 gtk_tree_view_set_row_separator_func(GTK_TREE_VIEW(status_box->tree_view), dropdown_store_row_separator_func, NULL, NULL); 1587 gtk_tree_view_set_row_separator_func(GTK_TREE_VIEW(status_box->tree_view), dropdown_store_row_separator_func, NULL, NULL);
1531 #endif 1588 #endif
1532 1589
1569 requisition->height = MAX(requisition->height, 30 + (border_width*2)); 1626 requisition->height = MAX(requisition->height, 30 + (border_width*2));
1570 1627
1571 /* If the gtkimhtml is visible, then add some additional padding */ 1628 /* If the gtkimhtml is visible, then add some additional padding */
1572 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req); 1629 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req);
1573 if (box_req.height > 1) 1630 if (box_req.height > 1)
1574 requisition->height += box_req.height + 3; 1631 requisition->height += box_req.height + border_width;
1575 1632
1576 requisition->width = 1; 1633 requisition->width = 1;
1577 } 1634 }
1578 1635
1579 /* From gnome-panel */ 1636 /* From gnome-panel */