[yast-commit] r62814 - in /trunk/gtk: ChangeLog src/pkg/ygtkpkgfilterview.cc src/pkg/ygtkpkgfilterview.h src/ygtktreeview.c
Author: rpmcruz Date: Wed Nov 10 19:05:07 2010 New Revision: 62814 URL: http://svn.opensuse.org/viewcvs/yast?rev=62814&view=rev Log: * src/pkg/ygtkpkgfilterview.cc: use bold for "all packages" or "all patches" row. * src/ygtktreeview.c: when pressing the context-menu key, show the popup menu next to the selected row, not under the mouse cursor. Modified: trunk/gtk/ChangeLog trunk/gtk/src/pkg/ygtkpkgfilterview.cc trunk/gtk/src/pkg/ygtkpkgfilterview.h trunk/gtk/src/ygtktreeview.c Modified: trunk/gtk/ChangeLog URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=62814&r1=62813&r2=62814&view=diff ============================================================================== --- trunk/gtk/ChangeLog (original) +++ trunk/gtk/ChangeLog Wed Nov 10 19:05:07 2010 @@ -1,3 +1,12 @@ +2010-11-10 Ricardo Cruz <rpmcruz@alunos.dcc.fc.up.pt> + + * src/pkg/ygtkpkgfilterview.cc: use bold for "all + packages" or "all patches" row. + + * src/ygtktreeview.c: when pressing the context-menu + key, show the popup menu next to the selected row, not + under the mouse cursor. + 2010-11-01 Ricardo Cruz <rpmcruz@alunos.dcc.fc.up.pt> * src/pkg/YGPackageSelector.cc: show header bar. Modified: trunk/gtk/src/pkg/ygtkpkgfilterview.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/pkg/ygtkpkgfilterview.cc?rev=62814&r1=62813&r2=62814&view=diff ============================================================================== --- trunk/gtk/src/pkg/ygtkpkgfilterview.cc (original) +++ trunk/gtk/src/pkg/ygtkpkgfilterview.cc Wed Nov 10 19:05:07 2010 @@ -41,7 +41,7 @@ : impl (new Impl()) { GtkListStore *store = gtk_list_store_new (TOTAL_COLUMNS, GDK_TYPE_PIXBUF, - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_INT, G_TYPE_POINTER); impl->model = GTK_TREE_MODEL (store); @@ -119,12 +119,16 @@ pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default(), icon, 32, GtkIconLookupFlags (0), NULL); + int weight = PANGO_WEIGHT_NORMAL; + if (firstRowIsAll() && gtk_tree_model_iter_n_children (impl->model, NULL) == 0) + weight = PANGO_WEIGHT_BOLD; + GtkTreeIter iter; GtkListStore *store = GTK_LIST_STORE (impl->model); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, ICON_COLUMN, pixbuf, TEXT_COLUMN, text, COUNT_NUMBER_COLUMN, "", ENABLED_COLUMN, enabled, VISIBLE_COLUMN, defaultVisible, - DATA_COLUMN, data, -1); + DATA_COLUMN, data, WEIGHT_COLUMN, weight, -1); if (pixbuf) g_object_unref (pixbuf); } @@ -644,7 +648,8 @@ renderer = ygtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes ( NULL, renderer, "markup", YGtkPkgFilterModel::TEXT_COLUMN, - "sensitive", YGtkPkgFilterModel::ENABLED_COLUMN, NULL); + "sensitive", YGtkPkgFilterModel::ENABLED_COLUMN, + "weight", YGtkPkgFilterModel::WEIGHT_COLUMN, NULL); g_object_set (G_OBJECT (renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_tree_view_column_set_expand (column, TRUE); ygtk_tree_view_append_column (YGTK_TREE_VIEW (view), column); @@ -652,7 +657,8 @@ renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes ( NULL, renderer, "text", YGtkPkgFilterModel::COUNT_NUMBER_COLUMN, - "sensitive", YGtkPkgFilterModel::ENABLED_COLUMN, NULL); + "sensitive", YGtkPkgFilterModel::ENABLED_COLUMN, + "weight", YGtkPkgFilterModel::WEIGHT_COLUMN, NULL); g_object_set (G_OBJECT (renderer), "xalign", 1.0, "scale", PANGO_SCALE_SMALL, "foreground", "#8c8c8c", NULL); ygtk_tree_view_append_column (YGTK_TREE_VIEW (view), column); Modified: trunk/gtk/src/pkg/ygtkpkgfilterview.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/pkg/ygtkpkgfilterview.h?rev=62814&r1=62813&r2=62814&view=diff ============================================================================== --- trunk/gtk/src/pkg/ygtkpkgfilterview.h (original) +++ trunk/gtk/src/pkg/ygtkpkgfilterview.h Wed Nov 10 19:05:07 2010 @@ -21,7 +21,7 @@ struct YGtkPkgFilterModel // abstract { enum Column { ICON_COLUMN, TEXT_COLUMN, COUNT_NUMBER_COLUMN, - VISIBLE_COLUMN, ENABLED_COLUMN, DATA_COLUMN, TOTAL_COLUMNS }; + VISIBLE_COLUMN, ENABLED_COLUMN, WEIGHT_COLUMN, DATA_COLUMN, TOTAL_COLUMNS }; YGtkPkgFilterModel(); virtual ~YGtkPkgFilterModel(); Modified: trunk/gtk/src/ygtktreeview.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtktreeview.c?rev=62814&r1=62813&r2=62814&view=diff ============================================================================== --- trunk/gtk/src/ygtktreeview.c (original) +++ trunk/gtk/src/ygtktreeview.c Wed Nov 10 19:05:07 2010 @@ -35,6 +35,21 @@ static void _gtk_widget_destroy (gpointer widget) { gtk_widget_destroy (GTK_WIDGET (widget)); } +static guint32 _popup_time = 0; +static gint _popup_x = 0, _popup_y = 0; + +static void _ygtk_tree_view_menu_position_func ( + GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data) +{ + GtkWidget *widget = (GtkWidget *) user_data; + gtk_tree_view_convert_bin_window_to_widget_coords ( + GTK_TREE_VIEW (widget), _popup_x, _popup_y, x, y); + + gint root_x, root_y; + gdk_window_get_origin (widget->window, &root_x, &root_y); + *x += root_x; *y += root_y; +} + void ygtk_tree_view_popup_menu (YGtkTreeView *view, GtkWidget *menu) { GtkWidget *widget = GTK_WIDGET (view); @@ -42,34 +57,35 @@ // emitted signals yet -- destroy it when replaced or the widget destroyed g_object_set_data_full (G_OBJECT (view), "popup", menu, _gtk_widget_destroy); - guint32 time = gtk_get_current_event_time(); gtk_menu_attach_to_widget (GTK_MENU (menu), widget, NULL); - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 3, time); + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, + _ygtk_tree_view_menu_position_func, widget, 3, _popup_time); gtk_widget_show_all (menu); } static gboolean ygtk_tree_view_button_press_event (GtkWidget *widget, GdkEventButton *event) { - // workaround (based on gedit): we want the tree view to receive this press in order - // to select the row, but we can't use connect_after, so we throw a dummy mouse press - if (event->type == GDK_BUTTON_PRESS && event->button == 3) { - static gboolean safeguard = FALSE; - if (safeguard) return FALSE; - safeguard = TRUE; - + if (event->button == 3) { GtkTreeView *view = GTK_TREE_VIEW (widget); - GtkTreeSelection *selection = gtk_tree_view_get_selection (view); - + GtkTreePath *path; gboolean outreach; - outreach = !gtk_tree_view_get_path_at_pos (view, event->x, event->y, 0, 0, 0, 0); - if (gtk_tree_selection_count_selected_rows (selection) <= 1) { - // if there is a selection, let it be - event->button = 1; - if (!gtk_widget_event (widget, (GdkEvent *) event)) - return FALSE; + outreach = gtk_tree_view_get_path_at_pos (view, event->x, event->y, &path, NULL, NULL, NULL); + if (outreach) { // select row if it is not + GtkTreeSelection *selection = gtk_tree_view_get_selection (view); + GtkTreeModel *model = gtk_tree_view_get_model (view); + GtkTreeIter iter; + gtk_tree_model_get_iter (model, &iter, path); + + if (!gtk_tree_selection_iter_is_selected (selection, &iter)) + gtk_tree_view_set_cursor (view, path, NULL, FALSE); + gtk_tree_path_free (path); } + + _popup_time = event->time; + _popup_x = event->x; _popup_y = event->y; + + gtk_widget_grab_focus (widget); g_signal_emit (widget, right_click_signal, 0, outreach); - safeguard = FALSE; return TRUE; } return GTK_WIDGET_CLASS (ygtk_tree_view_parent_class)->button_press_event (widget, event); @@ -81,6 +97,25 @@ GtkTreeSelection *selection = gtk_tree_view_get_selection (view); gboolean outreach = gtk_tree_selection_count_selected_rows (selection) == 0; + _popup_time = gtk_get_current_event_time(); + if (outreach) + _popup_x = (_popup_y = 0); + else { + GList *rows = gtk_tree_selection_get_selected_rows (selection, NULL); + GtkTreePath *path = (GtkTreePath *) g_list_last (rows)->data; + + // in case that path is not visible: + gtk_tree_view_scroll_to_cell (view, path, NULL, FALSE, 0, 0); + + GdkRectangle rect; + gtk_tree_view_get_cell_area (view, path, NULL, &rect); + _popup_x = 0; + _popup_y = rect.y + rect.height; + + g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL); + g_list_free (rows); + } + g_signal_emit (widget, right_click_signal, 0, outreach); return TRUE; } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
rpmcruz@svn2.opensuse.org