static GtkTreePath* get_drop_path(FmFolderView* fv, gint x, gint y) { GtkTreePath* tp = NULL; gboolean droppable = TRUE; switch(fv->mode) { case FM_FV_LIST_VIEW: { GtkTreeViewDropPosition pos; GtkTreeViewColumn* col; gtk_tree_view_convert_widget_to_bin_window_coords(GTK_TREE_VIEW(fv->view), x, y, &x, &y); /* if(gtk_tree_view_get_dest_row_at_pos((GtkTreeView*)fv->view, x, y, &tp, NULL)) */ if(gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(fv->view), x, y, &tp, &col, NULL, NULL)) { if(gtk_tree_view_column_get_sort_column_id(col)!=COL_FILE_NAME) { gtk_tree_path_free(tp); tp = NULL; } } gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW(fv->view), tp, GTK_TREE_VIEW_DROP_INTO_OR_AFTER); break; } case FM_FV_ICON_VIEW: case FM_FV_COMPACT_VIEW: case FM_FV_THUMBNAIL_VIEW: { tp = exo_icon_view_get_path_at_pos((const struct ExoIconView *)(const struct ExoIconView *)fv->view, x, y); exo_icon_view_set_drag_dest_item(EXO_ICON_VIEW(fv->view), tp, EXO_ICON_VIEW_DROP_INTO); break; } } return tp; }
/* * shows a tooltip for a file name */ static gboolean on_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, gpointer user_data) { gboolean show = FALSE; int bx, by; GtkTreePath *tpath = NULL; GtkTreeViewColumn *column = NULL; gtk_tree_view_convert_widget_to_bin_window_coords(GTK_TREE_VIEW(widget), x, y, &bx, &by); if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bx, by, &tpath, &column, NULL, NULL)) { if (1 == gtk_tree_path_get_depth(tpath) && column == gtk_tree_view_get_column(GTK_TREE_VIEW(widget), FILEPATH)) { GtkTreeIter iter; gchar *path = NULL; gtk_tree_model_get_iter(model, &iter, tpath); gtk_tree_model_get(model, &iter, FILEPATH, &path, -1); gtk_tooltip_set_text(tooltip, path); gtk_tree_view_set_tooltip_row(GTK_TREE_VIEW(widget), tooltip, tpath); show = TRUE; } gtk_tree_path_free(tpath); } return show; }
static VALUE rg_convert_widget_to_bin_window_coords(VALUE self, VALUE wx, VALUE wy) { gint bx, by; gtk_tree_view_convert_widget_to_bin_window_coords(_SELF(self), NUM2INT(wx), NUM2INT(wy), &bx, &by); return rb_ary_new3(2, INT2NUM(bx), INT2NUM(by)); }
static gboolean treeview_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_tip, GtkTooltip *tooltip, gpointer data) { GtkTreeIter iter; GtkTreeView *tree_view = GTK_TREE_VIEW (widget); GtkTreeModel *model = gtk_tree_view_get_model (tree_view); GtkTreePath *path = NULL; gpointer *tab; gchar *tip; if (keyboard_tip) { gtk_tree_view_get_cursor (tree_view, &path, NULL); if (path == NULL) { return FALSE; } } else { gint bin_x, bin_y; gtk_tree_view_convert_widget_to_bin_window_coords (tree_view, x, y, &bin_x, &bin_y); if (!gtk_tree_view_get_path_at_pos (tree_view, bin_x, bin_y, &path, NULL, NULL, NULL)) { return FALSE; } } gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get (model, &iter, TAB_COLUMN, &tab, -1); tip = _pluma_tab_get_tooltips (PLUMA_TAB (tab)); gtk_tooltip_set_markup (tooltip, tip); g_free (tip); gtk_tree_path_free (path); return TRUE; }
static void cv_tree_focus (chan *ch) { GtkTreeView *tree = ((treeview *)ch->cv)->tree; GtkTreeModel *model = gtk_tree_view_get_model (tree); GtkTreePath *path; GtkTreeIter parent; GdkRectangle cell_rect; GdkRectangle vis_rect; gint dest_y; /* expand the parent node */ if (gtk_tree_model_iter_parent (model, &parent, &ch->iter)) { path = gtk_tree_model_get_path (model, &parent); if (path) { /*if (!gtk_tree_view_row_expanded (tree, path)) { gtk_tree_path_free (path); return; }*/ gtk_tree_view_expand_row (tree, path, FALSE); gtk_tree_path_free (path); } } path = gtk_tree_model_get_path (model, &ch->iter); if (path) { /* This full section does what * gtk_tree_view_scroll_to_cell (tree, path, NULL, TRUE, 0.5, 0.5); * does, except it only scrolls the window if the provided cell is * not visible. Basic algorithm taken from gtktreeview.c */ /* obtain information to see if the cell is visible */ gtk_tree_view_get_background_area (tree, path, NULL, &cell_rect); gtk_tree_view_get_visible_rect (tree, &vis_rect); /* The cordinates aren't offset correctly */ gtk_tree_view_convert_widget_to_bin_window_coords ( tree, cell_rect.x, cell_rect.y, NULL, &cell_rect.y ); /* only need to scroll if out of bounds */ if (cell_rect.y < vis_rect.y || cell_rect.y + cell_rect.height > vis_rect.y + vis_rect.height) { dest_y = cell_rect.y - ((vis_rect.height - cell_rect.height) * 0.5); if (dest_y < 0) dest_y = 0; gtk_tree_view_scroll_to_point (tree, -1, dest_y); } /* theft done, now make it focused like */ gtk_tree_view_set_cursor (tree, path, NULL, FALSE); gtk_tree_path_free (path); } }
/* Scroll function taken/adapted from gtktreeview.c */ static gint scroll_row_timeout (gpointer data) { GtkTreeView *tree_view = data; GdkRectangle visible_rect; gint y, x; gint offset; gfloat value; GtkAdjustment* vadj; RbTreeDndData *priv_data; GDK_THREADS_ENTER (); priv_data = g_object_get_data (G_OBJECT (tree_view), RB_TREE_DND_STRING); g_return_val_if_fail(priv_data != NULL, TRUE); gdk_window_get_pointer (gtk_tree_view_get_bin_window (tree_view), &x, &y, NULL); gtk_tree_view_convert_widget_to_bin_window_coords (tree_view, x, y, &x, &y); gtk_tree_view_convert_bin_window_to_tree_coords (tree_view, x, y, &x, &y); gtk_tree_view_get_visible_rect (tree_view, &visible_rect); /* see if we are near the edge. */ if (x < visible_rect.x && x > visible_rect.x + visible_rect.width) { GDK_THREADS_LEAVE (); priv_data->scroll_timeout = 0; return FALSE; } offset = y - (visible_rect.y + 2 * SCROLL_EDGE_SIZE); if (offset > 0) { offset = y - (visible_rect.y + visible_rect.height - 2 * SCROLL_EDGE_SIZE); if (offset < 0) { GDK_THREADS_LEAVE (); priv_data->scroll_timeout = 0; return FALSE; } } vadj = gtk_tree_view_get_vadjustment (tree_view); value = CLAMP (vadj->value + offset, vadj->lower, vadj->upper - vadj->page_size); gtk_adjustment_set_value (vadj, value); /* don't remove it if we're on the edge and not scrolling */ if (ABS (vadj->value - value) > 0.0001) remove_select_on_drag_timeout(tree_view); GDK_THREADS_LEAVE (); return TRUE; }
SteadyflowCoreIDownloadFile* steadyflow_file_list_controller_get_file_at_widget_pos (SteadyflowFileListController* self, gint x, gint y) { SteadyflowCoreIDownloadFile* result = NULL; gint bx = 0; gint by = 0; GtkTreeView* _tmp0_; gint _tmp1_; gint _tmp2_; gint _tmp3_ = 0; gint _tmp4_ = 0; GtkTreePath* path = NULL; GtkTreeIter iter = {0}; GtkTreeView* _tmp5_; gint _tmp6_; gint _tmp7_; GtkTreePath* _tmp8_ = NULL; gboolean _tmp9_ = FALSE; g_return_val_if_fail (self != NULL, NULL); _tmp0_ = self->priv->tree; _tmp1_ = x; _tmp2_ = y; gtk_tree_view_convert_widget_to_bin_window_coords (_tmp0_, _tmp1_, _tmp2_, &_tmp3_, &_tmp4_); bx = _tmp3_; by = _tmp4_; _tmp5_ = self->priv->tree; _tmp6_ = bx; _tmp7_ = by; _tmp9_ = gtk_tree_view_get_path_at_pos (_tmp5_, _tmp6_, _tmp7_, &_tmp8_, NULL, NULL, NULL); _gtk_tree_path_free0 (path); path = _tmp8_; if (_tmp9_) { GtkListStore* _tmp10_; GtkTreePath* _tmp11_; GtkTreeIter _tmp12_ = {0}; gboolean _tmp13_ = FALSE; _tmp10_ = self->priv->model; _tmp11_ = path; _tmp13_ = gtk_tree_model_get_iter ((GtkTreeModel*) _tmp10_, &_tmp12_, _tmp11_); iter = _tmp12_; if (_tmp13_) { GtkTreeIter _tmp14_; SteadyflowCoreIDownloadFile* _tmp15_ = NULL; _tmp14_ = iter; _tmp15_ = steadyflow_file_list_controller_file_from_iter (self, &_tmp14_); result = _tmp15_; _gtk_tree_path_free0 (path); return result; } } result = NULL; _gtk_tree_path_free0 (path); return result; }
static gboolean gossip_cell_renderer_expander_activate (GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path_string, const GdkRectangle *background_area, const GdkRectangle *cell_area, GtkCellRendererState flags) { GossipCellRendererExpanderPriv *priv; GtkTreePath *path; gboolean in_cell; int mouse_x; int mouse_y; priv = GET_PRIV (cell); if (!GTK_IS_TREE_VIEW (widget) || !priv->activatable) return FALSE; path = gtk_tree_path_new_from_string (path_string); gtk_widget_get_pointer (widget, &mouse_x, &mouse_y); gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW (widget), mouse_x, mouse_y, &mouse_x, &mouse_y); /* check if click is within the cell */ if (mouse_x - cell_area->x >= 0 && mouse_x - cell_area->x <= cell_area->width) { in_cell = TRUE; } else { in_cell = FALSE; } if (! in_cell) { gtk_tree_path_free (path); return FALSE; } if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (widget), path)) { gtk_tree_view_collapse_row (GTK_TREE_VIEW (widget), path); priv->style_flags &= ~(GTK_STATE_FLAG_ACTIVE); } else { gtk_tree_view_expand_row (GTK_TREE_VIEW (widget), path, FALSE); priv->style_flags |= ~(GTK_STATE_FLAG_ACTIVE); } gtk_tree_path_free (path); return TRUE; }
void qtcTreeViewSetup(GtkWidget *widget) { QTC_DEF_WIDGET_PROPS(props, widget); if (widget && !qtcWidgetProps(props)->treeViewHacked) { QtCTreeView *tv = qtcTreeViewLookupHash(widget, true); GtkTreeView *treeView = GTK_TREE_VIEW(widget); GtkWidget *parent = gtk_widget_get_parent(widget); if (tv) { qtcWidgetProps(props)->treeViewHacked = true; int x, y; #if GTK_CHECK_VERSION(2, 90, 0) /* Gtk3:TODO !!! */ tv->fullWidth = true; #else gtk_widget_style_get(widget, "row_ending_details", &tv->fullWidth, NULL); #endif gdk_window_get_pointer(gtk_widget_get_window(widget), &x, &y, 0L); gtk_tree_view_convert_widget_to_bin_window_coords(treeView, x, y, &x, &y); qtcTreeViewUpdatePosition(widget, x, y); qtcConnectToProp(props, treeViewDestroy, "destroy-event", qtcTreeViewDestroy, NULL); qtcConnectToProp(props, treeViewUnrealize, "unrealize", qtcTreeViewDestroy, NULL); qtcConnectToProp(props, treeViewStyleSet, "style-set", qtcTreeViewStyleSet, NULL); qtcConnectToProp(props, treeViewMotion, "motion-notify-event", qtcTreeViewMotion, NULL); qtcConnectToProp(props, treeViewLeave, "leave-notify-event", qtcTreeViewLeave, NULL); } if (!gtk_tree_view_get_show_expanders(treeView)) gtk_tree_view_set_show_expanders(treeView, true); if (gtk_tree_view_get_enable_tree_lines(treeView)) gtk_tree_view_set_enable_tree_lines(treeView, false); if (GTK_IS_SCROLLED_WINDOW(parent) && gtk_scrolled_window_get_shadow_type(GTK_SCROLLED_WINDOW(parent)) != GTK_SHADOW_IN) { gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(parent), GTK_SHADOW_IN); } } }
static gboolean on_item_list_view_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, GtkTreeViewColumn *headline_column) { GtkTreeView *view = GTK_TREE_VIEW (widget); GtkTreeModel *model; GtkTreePath *path; GtkTreeIter iter; gboolean ret = FALSE; if (gtk_tree_view_get_tooltip_context (view, &x, &y, keyboard_mode, &model, &path, &iter)) { GtkTreeViewColumn *column; gint bx, by; gtk_tree_view_convert_widget_to_bin_window_coords (view, x, y, &bx, &by); gtk_tree_view_get_path_at_pos (view, x, y, NULL, &column, NULL, NULL); if (column == headline_column) { GtkCellRenderer *cell; GList *renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); cell = GTK_CELL_RENDERER (renderers->data); g_list_free (renderers); gchar *text; gint weight; gtk_tree_model_get (model, &iter, IS_LABEL, &text, ITEMSTORE_UNREAD, &weight, -1); gint full_width = get_cell_renderer_width (widget, cell, text, weight); gint column_width = gtk_tree_view_column_get_width (column); if (full_width > column_width) { gtk_tooltip_set_text (tooltip, text); ret = TRUE; } g_free (text); } gtk_tree_view_set_tooltip_row (view, tooltip, path); gtk_tree_path_free (path); } return ret; }
static gboolean gossip_cell_renderer_expander_activate (GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path_string, const GdkRectangle *background_area, const GdkRectangle *cell_area, GtkCellRendererState flags) { GossipCellRendererExpander *expander; GossipCellRendererExpanderPriv *priv; GtkTreePath *path; GtkSettings *settings; gboolean animate = FALSE; gboolean expanding; gboolean in_cell; int mouse_x; int mouse_y; expander = GOSSIP_CELL_RENDERER_EXPANDER (cell); priv = GET_PRIV (cell); if (!GTK_IS_TREE_VIEW (widget) || !priv->activatable) return FALSE; path = gtk_tree_path_new_from_string (path_string); gtk_widget_get_pointer (widget, &mouse_x, &mouse_y); gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW (widget), mouse_x, mouse_y, &mouse_x, &mouse_y); /* check if click is within the cell */ if (mouse_x - cell_area->x >= 0 && mouse_x - cell_area->x <= cell_area->width) { in_cell = TRUE; } else { in_cell = FALSE; } if (! in_cell) { return FALSE; } #if 0 if (gtk_tree_path_get_depth (path) > 1) { gtk_tree_path_free (path); return TRUE; } #endif settings = gtk_widget_get_settings (GTK_WIDGET (widget)); if (g_object_class_find_property (G_OBJECT_GET_CLASS (settings), "gtk-enable-animations")) { g_object_get (settings, "gtk-enable-animations", &animate, NULL); } if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (widget), path)) { gtk_tree_view_collapse_row (GTK_TREE_VIEW (widget), path); expanding = FALSE; } else { gtk_tree_view_expand_row (GTK_TREE_VIEW (widget), path, FALSE); expanding = TRUE; } if (animate) { gossip_cell_renderer_expander_start_animation (expander, GTK_TREE_VIEW (widget), path, expanding, background_area); } gtk_tree_path_free (path); return TRUE; }
gint drag_received (GtkWidget* widget, GdkDragContext* drag_context, gint x, gint y, GtkSelectionData* data, guint info, guint time, gpointer user_data) { // this receives drops for the whole window. if(!data || data->length < 0){ perr("no data!\n"); return -1; } dbg(1, "%s", data->data); if(g_str_has_prefix((char*)data->data, "colour:")){ char* colour_string = (char*)data->data + 7; unsigned colour_index = atoi(colour_string) ? atoi(colour_string) - 1 : 0; // which row are we on? GtkTreePath* path; GtkTreeIter iter; gint tx, treeview_top; gdk_window_get_position(app->libraryview->widget->window, &tx, &treeview_top); dbg(2, "treeview_top=%i", y); #ifdef HAVE_GTK_2_12 gint bx, by; gtk_tree_view_convert_widget_to_bin_window_coords(GTK_TREE_VIEW(app->libraryview->widget), x, y - treeview_top, &bx, &by); dbg(2, "coords: %dx%d => %dx%d", x, y, bx, by); #else gint by = y - treeview_top - 20; #endif #ifdef USE_GDL GdkWindow* top_window = gdk_window_get_toplevel(gtk_widget_get_toplevel(app->libraryview->widget)->window); GdkWindow* window = app->libraryview->widget->window; while((window = gdk_window_get_parent(window)) != top_window){ gint x0, y0; gdk_window_get_position(window, &x0, &y0); by -= y0; } #endif if(gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(app->libraryview->widget), x, by, &path, NULL, NULL, NULL)){ gtk_tree_model_get_iter(GTK_TREE_MODEL(samplecat.store), &iter, path); gchar* path_str = gtk_tree_model_get_string_from_iter(GTK_TREE_MODEL(samplecat.store), &iter); dbg(2, "path=%s y=%i final_y=%i", path_str, y, y - treeview_top); listview_item_set_colour(path, colour_index); gtk_tree_path_free(path); } else dbg(0, "path not found."); return FALSE; } if(info == GPOINTER_TO_INT(GDK_SELECTION_TYPE_STRING)) printf(" type=string.\n"); if(info == GPOINTER_TO_INT(TARGET_URI_LIST)){ dbg(1, "type=uri_list. len=%i", data->length); GList* list = uri_list_to_glist((char*)data->data); if(g_list_length(list) < 1) pwarn("drag drop: uri list parsing found no uri's.\n"); int i = 0; ScanResults result = {0,}; GList* l = list; #ifdef __APPLE__ gdk_threads_enter(); #endif for(;l;l=l->next){ char* u = l->data; gchar* method_string; vfs_get_method_string(u, &method_string); dbg(2, "%i: %s method=%s", i, u, method_string); if(!strcmp(method_string, "file")){ //we could probably better use g_filename_from_uri() here //http://10.0.0.151/man/glib-2.0/glib-Character-Set-Conversion.html#g-filename-from-uri //-or perhaps get_local_path() from rox/src/support.c char* uri_unescaped = vfs_unescape_string(u + strlen(method_string) + 1, NULL); char* uri = (strstr(uri_unescaped, "///") == uri_unescaped) ? uri_unescaped + 2 : uri_unescaped; if(do_progress(0,0)) break; if(is_dir(uri)) application_add_dir(uri, &result); else application_add_file(uri, &result); g_free(uri_unescaped); } else pwarn("drag drop: unknown format: '%s'. Ignoring.\n", u); i++; } hide_progress(); #ifdef __APPLE__ gdk_threads_leave(); #endif statusbar_print(1, "import complete. %i files added", result.n_added); uri_list_free(list); } return FALSE; }
static gboolean treeview_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_tip, GtkTooltip *tooltip, GeditDocumentsPanel *panel) { GtkTreeIter iter; GtkTreeView *tree_view = GTK_TREE_VIEW (widget); GtkTreeModel *model = gtk_tree_view_get_model (tree_view); GtkTreePath *path = NULL; GeditNotebook *notebook; GeditTab *tab; gchar *tip; gedit_debug (DEBUG_PANEL); if (keyboard_tip) { gtk_tree_view_get_cursor (tree_view, &path, NULL); if (path == NULL) { return FALSE; } } else { gint bin_x, bin_y; gtk_tree_view_convert_widget_to_bin_window_coords (tree_view, x, y, &bin_x, &bin_y); if (!gtk_tree_view_get_path_at_pos (tree_view, bin_x, bin_y, &path, NULL, NULL, NULL)) { return FALSE; } } gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get (model, &iter, NOTEBOOK_COLUMN, ¬ebook, TAB_COLUMN, &tab, -1); if (tab != NULL) { tip = _gedit_tab_get_tooltip (tab); g_object_unref (tab); } else { tip = notebook_get_tooltip (panel->priv->mnb, notebook); } gtk_tooltip_set_markup (tooltip, tip); g_object_unref (notebook); g_free (tip); gtk_tree_path_free (path); return TRUE; }
static gboolean on_log_view_query_tooltip (GtkWidget *log_view, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, GitLogPane *self) { gboolean ret; GtkTreeViewColumn *ref_icon_column; gint bin_x; gint bin_y; GtkTreeViewColumn *current_column; GtkTreePath *path; GtkTreeModel *model; GtkTreeIter iter; GitRevision *revision; gchar *sha; GList *ref_list; GList *current_ref; GString *tooltip_string; gchar *ref_name; GitRefType ref_type; ret = FALSE; ref_icon_column = gtk_tree_view_get_column (GTK_TREE_VIEW (log_view), 0); gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW (log_view), x, y, &bin_x, &bin_y); if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (log_view), bin_x, bin_y, &path, ¤t_column, NULL, NULL)) { /* We need to be in the ref icon column */ if (current_column == ref_icon_column) { model = gtk_tree_view_get_model (GTK_TREE_VIEW (log_view)); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get (model, &iter, LOG_COL_REVISION, &revision, -1); sha = git_revision_get_sha (revision); g_object_unref (revision); ref_list = g_hash_table_lookup (self->priv->refs, sha); g_free (sha); if (ref_list) { current_ref = ref_list; tooltip_string = g_string_new (""); while (current_ref) { ref_name = git_ref_get_name (GIT_REF (current_ref->data)); ref_type = git_ref_get_ref_type (GIT_REF (current_ref->data)); if (tooltip_string->len > 0) g_string_append (tooltip_string, "\n"); switch (ref_type) { case GIT_REF_TYPE_BRANCH: g_string_append_printf (tooltip_string, _("<b>Branch:</b> %s"), ref_name ); break; case GIT_REF_TYPE_TAG: g_string_append_printf (tooltip_string, _("<b>Tag:</b> %s"), ref_name); break; case GIT_REF_TYPE_REMOTE: g_string_append_printf (tooltip_string, _("<b>Remote:</b> %s"), ref_name); break; default: break; } g_free (ref_name); current_ref = g_list_next (current_ref); } gtk_tooltip_set_markup (tooltip, tooltip_string->str); g_string_free (tooltip_string, TRUE); ret = TRUE; } } gtk_tree_path_free (path); } return ret; }
static gboolean _dtv_query_tooltip (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip) { int bin_x, bin_y; GtkTreePath *path = NULL; GtkTreeViewColumn *column; GtkTreeIter iter; GtkTreeModel *model; GdkRectangle cell_area; GString *markup; gboolean had_info = FALSE; gtk_tree_view_convert_widget_to_bin_window_coords ( GTK_TREE_VIEW (widget), x, y, &bin_x, &bin_y); if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), bin_x, bin_y, &path, &column, NULL, NULL)) { model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); if (gtk_tree_model_get_iter (model, &iter, path)) { /* show some useful information */ Diagram *diagram; Layer *layer; DiaObject *object; gtk_tree_model_get (model, &iter, DIAGRAM_COLUMN, &diagram, -1); gtk_tree_model_get (model, &iter, LAYER_COLUMN, &layer, -1); gtk_tree_model_get (model, &iter, OBJECT_COLUMN, &object, -1); markup = g_string_new (NULL); if (diagram) { gchar *em = g_markup_printf_escaped ("<b>%s</b>: %s\n", _("Diagram"), diagram->filename); g_string_append (markup, em); g_free (em); } if (layer) { gchar *name = layer_get_name (layer); gchar *em = g_markup_printf_escaped ("<b>%s</b>: %s\n", _("Layer"), name); g_string_append (markup, em); g_free (em); g_free (name); } else if (diagram) { int layers = data_layer_count (DIA_DIAGRAM_DATA (diagram)); g_string_append_printf (markup, g_dngettext (GETTEXT_PACKAGE, "%d Layer", "%d Layers", layers), layers); } if (object) { gchar *em = g_markup_printf_escaped ("<b>%s</b>: %s\n", _("Type"), object->type->name); g_string_append (markup, em); g_free (em); g_string_append_printf (markup, "<b>%s</b>: %g,%g\n", Q_("object|Position"), object->position.x, object->position.y); g_string_append_printf (markup, "%d %s", g_list_length (object->children), _("Children")); /* and some dia_object_get_meta ? */ } else if (layer) { int objects = layer_object_count (layer); g_string_append_printf (markup, g_dngettext (GETTEXT_PACKAGE, "%d Object", "%d Objects", objects), objects); } if (markup->len > 0) { gtk_tree_view_get_cell_area (GTK_TREE_VIEW (widget), path, column, &cell_area); gtk_tree_view_convert_bin_window_to_widget_coords (GTK_TREE_VIEW (widget), cell_area.x, cell_area.y, &cell_area.x, &cell_area.y); gtk_tooltip_set_tip_area (tooltip, &cell_area); gtk_tooltip_set_markup (tooltip, markup->str); had_info = TRUE; } /* drop references */ if (diagram) g_object_unref (diagram); g_string_free (markup, TRUE); } gtk_tree_path_free (path); if (had_info) return TRUE; } return GTK_WIDGET_CLASS (_dtv_parent_class)->query_tooltip (widget, x, y, keyboard_mode, tooltip); }
static gboolean icon_sources_query_tooltip (GtkWidget * widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip * tooltip, GladeEPropIconSources * eprop_sources) { GtkTreePath *path = NULL; GtkTreeIter iter; GtkTreeViewColumn *column = NULL; gint bin_x = x, bin_y = y, col; gchar *icon_name = NULL; gboolean show_now = FALSE; if (keyboard_mode) return FALSE; gtk_tree_view_convert_widget_to_bin_window_coords (eprop_sources->view, x, y, &bin_x, &bin_y); if (gtk_tree_view_get_path_at_pos (eprop_sources->view, bin_x, bin_y, &path, &column, NULL, NULL)) { if (gtk_tree_model_get_iter (GTK_TREE_MODEL (eprop_sources->store), &iter, path)) { col = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (column), "column-id")); gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->store), &iter, COLUMN_ICON_NAME, &icon_name, -1); /* no tooltips on the parent rows */ if (icon_name) { gchar *tooltip_text = NULL; show_now = TRUE; switch (col) { case COLUMN_TEXT: tooltip_text = g_strdup_printf (_ ("Enter a filename or a relative or full path for this " "source of '%s' (Glade will only ever load them in " "the runtime from your project directory)."), icon_name); break; case COLUMN_DIRECTION_ACTIVE: tooltip_text = g_strdup_printf (_ ("Set whether you want to specify a text direction " "for this source of '%s'"), icon_name); break; case COLUMN_DIRECTION: tooltip_text = g_strdup_printf (_ ("Set the text direction for this source of '%s'"), icon_name); break; case COLUMN_SIZE_ACTIVE: tooltip_text = g_strdup_printf (_ ("Set whether you want to specify an icon size " "for this source of '%s'"), icon_name); break; case COLUMN_SIZE: tooltip_text = g_strdup_printf (_ ("Set the icon size for this source of '%s'"), icon_name); break; case COLUMN_STATE_ACTIVE: tooltip_text = g_strdup_printf (_ ("Set whether you want to specify a state " "for this source of '%s'"), icon_name); break; case COLUMN_STATE: tooltip_text = g_strdup_printf (_ ("Set the state for this source of '%s'"), icon_name); default: break; } gtk_tooltip_set_text (tooltip, tooltip_text); g_free (tooltip_text); g_free (icon_name); gtk_tree_view_set_tooltip_cell (eprop_sources->view, tooltip, path, column, NULL); } } gtk_tree_path_free (path); } return show_now; }