static void real_queue_resize (GtkWidget *widget, GtkQueueResizeFlags flags) { GtkWidget *container; _gtk_widget_set_alloc_needed (widget, TRUE); _gtk_size_request_cache_clear (_gtk_widget_peek_request_cache (widget)); container = gtk_widget_get_parent (widget); if (!container && gtk_widget_is_toplevel (widget) && GTK_IS_CONTAINER (widget)) container = widget; if (container) { if (flags & GTK_QUEUE_RESIZE_INVALIDATE_ONLY) _gtk_container_resize_invalidate (GTK_CONTAINER (container)); else _gtk_container_queue_resize (GTK_CONTAINER (container)); } }
GtkWidget * create_widget_factory_content (void) { GError *error = NULL; GtkBuilder *builder; GtkWidget *result; builder = gtk_builder_new (); gtk_builder_add_from_file (builder, "../demos/widget-factory/widget-factory.ui", &error); if (error != NULL) g_error ("Failed to create widgets: %s", error->message); result = GTK_WIDGET (gtk_builder_get_object (builder, "box1")); g_object_ref (result); gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (result)), result); g_object_unref (builder); return result; }
static void gbp_terminal_page_set_needs_attention (IdeTerminalPage *self, gboolean needs_attention) { GtkWidget *parent; g_assert (IDE_IS_TERMINAL_PAGE (self)); parent = gtk_widget_get_parent (GTK_WIDGET (self)); if (GTK_IS_STACK (parent) && !gtk_widget_in_destruction (GTK_WIDGET (self)) && !gtk_widget_in_destruction (parent)) { if (!gtk_widget_in_destruction (GTK_WIDGET (self->terminal_top))) self->needs_attention = !!needs_attention; gtk_container_child_set (GTK_CONTAINER (parent), GTK_WIDGET (self), "needs-attention", needs_attention, NULL); } }
static void security_combo_changed (GtkComboBox *combo, gpointer user_data) { CEPageSecurity *page = CE_PAGE_SECURITY (user_data); GtkWidget *vbox; GList *l, *children; WirelessSecurity *sec; wsec_size_group_clear (page->group); vbox = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "vbox")); children = gtk_container_get_children (GTK_CONTAINER (vbox)); for (l = children; l; l = l->next) { gtk_container_remove (GTK_CONTAINER (vbox), GTK_WIDGET (l->data)); } sec = security_combo_get_active (page); if (sec) { GtkWidget *sec_widget; GtkWidget *parent; sec_widget = wireless_security_get_widget (sec); g_assert (sec_widget); parent = gtk_widget_get_parent (sec_widget); if (parent) gtk_container_remove (GTK_CONTAINER (parent), sec_widget); gtk_size_group_add_widget (page->group, page->security_heading); gtk_size_group_add_widget (page->group, page->firewall_heading); wireless_security_add_to_size_group (sec, page->group); gtk_container_add (GTK_CONTAINER (vbox), sec_widget); wireless_security_unref (sec); } ce_page_changed (CE_PAGE (page)); }
static void gal_view_new_dialog_init (GalViewNewDialog *dialog) { GtkWidget *content_area; GtkWidget *parent; GtkWidget *widget; dialog->builder = gtk_builder_new (); e_load_ui_builder_definition ( dialog->builder, "gal-view-new-dialog.ui"); widget = e_builder_get_widget (dialog->builder, "table-top"); if (!widget) { return; } g_object_ref (widget); parent = gtk_widget_get_parent (widget); gtk_container_remove (GTK_CONTAINER (parent), widget); content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); gtk_box_pack_start (GTK_BOX (content_area), widget, TRUE, TRUE, 0); g_object_unref (widget); gtk_dialog_add_buttons ( GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE); gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); gtk_window_set_title (GTK_WINDOW(dialog), _("Define New View")); dialog->collection = NULL; dialog->selected_factory = NULL; }
void hd_status_area_box_reorder_child (HDStatusAreaBox *box, GtkWidget *child, guint position) { HDStatusAreaBoxPrivate *priv; GList *c; g_return_if_fail (HD_IS_STATUS_AREA_BOX (box)); g_return_if_fail (GTK_IS_WIDGET (child)); g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (box)); priv = box->priv; for (c = priv->children; c; c = c->next) { HDStatusAreaBoxChild *info = c->data; if (info->widget == child) { if (info->priority != position) { info->priority = position; /* Reorder children list */ priv->children = g_list_delete_link (priv->children, c); priv->children = g_list_insert_sorted (priv->children, info, hd_status_area_box_cmp_priority); if (gtk_widget_is_visible (child) && gtk_widget_is_visible (GTK_WIDGET(box))) gtk_widget_queue_resize (child); } break; } } }
static GtkWidget * find_label (GtkWidget *widget) { GList *labels; GtkWidget *label; GtkWidget *temp_widget; GList *ptr; labels = gtk_widget_list_mnemonic_labels (widget); label = NULL; ptr = labels; while (ptr) { if (ptr->data && gtk_widget_get_visible (GTK_WIDGET (ptr->data))) { label = ptr->data; break; } ptr = ptr->next; } g_list_free (labels); /* Ignore a label within a button; bug #136602 */ if (label && GTK_IS_BUTTON (widget)) { temp_widget = label; while (temp_widget) { if (temp_widget == widget) { label = NULL; break; } temp_widget = gtk_widget_get_parent (temp_widget); } } return label; }
GtkWidget *gui_detach_box_from_parent (GtkWidget *box, GtkWidget *parent, gboolean *flag, gchar *window_title, gint x, gint y) { /* * This function detaches the box from its parent. If the flag=FALSE, than * it creates a new window and packs the box inside the window, otherwise * it packs the box in its original place inside the main window. */ GtkWidget *window; gchar *glade_pixmap_file = g_build_filename (PHOEBE_GLADE_PIXMAP_DIR, "ico.png", NULL); if(*flag){ window = gtk_widget_get_parent (box); gtk_widget_reparent(box, parent); gtk_widget_destroy(window); gui_status("%s reatached.", window_title); } else{ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_object_set_data (G_OBJECT (window), "data_box", (gpointer) box); g_object_set_data (G_OBJECT (window), "data_parent", (gpointer) parent); g_object_set_data (G_OBJECT (window), "data_flag", (gpointer) flag); gtk_window_set_icon (GTK_WINDOW(window), gdk_pixbuf_new_from_file(glade_pixmap_file, NULL)); gtk_window_set_title (GTK_WINDOW (window), window_title); gtk_widget_reparent(box, window); gtk_widget_set_size_request (window, x, y); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); g_signal_connect (GTK_WIDGET(window), "delete-event", G_CALLBACK (tmp_circumvent_delete_event), NULL); gtk_widget_show_all (window); gui_status("%s detached.", window_title); } *flag = !(*flag); return window; }
static gboolean do_show_display_menu(gpointer data) { ARGS *args = lock_args(data); if (!args->menu->extra1) { GtkWidget *gtk_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); GtkWidget *menu_bar = gtk_menu_bar_new(); gtk_window_set_deletable(GTK_WINDOW(gtk_window), FALSE); build_menu(menu_bar, args->menu); gtk_container_add(GTK_CONTAINER(gtk_window), menu_bar); gtk_widget_show(menu_bar); gtk_window_set_default_size(GTK_WINDOW(gtk_window), 320, 32); args->menu->extra1 = menu_bar; } gtk_widget_show(gtk_widget_get_parent(args->menu->extra1)); return release_args(args); }
/* get the related action of the widget or walk up the parents to find one. * useful for example to get the related action of a tool item from its child. */ GtkAction * mousepad_util_find_related_action (GtkWidget *widget) { GtkAction *action; g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); do { if (GTK_IS_ACTIVATABLE (widget)) action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (widget)); if (G_UNLIKELY (action == NULL)) { if (gtk_widget_is_toplevel (widget)) break; widget = gtk_widget_get_parent (widget); } } while (action == NULL); return action; }
/************************************************************************** Scroll a textview so that the given mark is visible, but only if the scroll window containing the textview is very close to the bottom. The text mark 'scroll_target' should probably be the first character of the last line in the text buffer. **************************************************************************/ void scroll_if_necessary(GtkTextView *textview, GtkTextMark *scroll_target) { GtkWidget *sw; GtkAdjustment *vadj; gdouble val, max, upper, page_size; fc_assert_ret(textview != NULL); fc_assert_ret(scroll_target != NULL); sw = gtk_widget_get_parent(GTK_WIDGET(textview)); fc_assert_ret(sw != NULL); fc_assert_ret(GTK_IS_SCROLLED_WINDOW(sw)); vadj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(sw)); val = gtk_adjustment_get_value(GTK_ADJUSTMENT(vadj)); g_object_get(G_OBJECT(vadj), "upper", &upper, "page-size", &page_size, NULL); max = upper - page_size; if (max - val < 10.0) { gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textview), scroll_target, 0.0, TRUE, 1.0, 0.0); } }
static void popup_button_expose (GtkWidget *widget, GdkEventExpose *event, UmPhotoDialog *um) { GtkAllocation allocation; if (gtk_widget_get_state (widget) != GTK_STATE_PRELIGHT && !gtk_widget_is_focus (gtk_widget_get_parent (widget))) { return; } gtk_widget_get_allocation (widget, &allocation); gtk_paint_expander (gtk_widget_get_style (widget), gtk_widget_get_window (widget), gtk_widget_get_state (widget), NULL, widget, NULL, allocation.x + allocation.width, allocation.y + allocation.height, GTK_EXPANDER_EXPANDED); }
GtkWidget* lookup_widget(GtkWidget *widget, const gchar *widget_name) { GtkWidget *parent, *found_widget; for (;;) { if (GTK_IS_MENU (widget)) parent = gtk_menu_get_attach_widget(GTK_MENU(widget)); else parent = gtk_widget_get_parent(widget); if (!parent) parent = (GtkWidget*)g_object_get_data(G_OBJECT(widget), "GladeParentKey"); if (parent == NULL) break; widget = parent; } found_widget = (GtkWidget*)g_object_get_data(G_OBJECT(widget), widget_name); if (!found_widget) g_warning("Widget not found: %s", widget_name); return found_widget; }
GtkWidget *statusbar_create(void) { GtkWidget *statusbar; GtkWidget *child; GtkWidget *parent; GtkWidget *hbox; statusbar = gtk_statusbar_new(); statusbar_list = g_list_append(statusbar_list, statusbar); gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(statusbar), FALSE); gtk_container_set_border_width(GTK_CONTAINER(statusbar), 1); child = gtk_statusbar_get_message_area(GTK_STATUSBAR(statusbar)); parent = gtk_widget_get_parent(child); gtk_container_remove(GTK_CONTAINER(parent), g_object_ref(child)); hbox = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(parent), hbox); gtk_widget_show(hbox); gtk_box_pack_start(GTK_BOX(hbox), child, TRUE, TRUE, 0); g_object_unref(child); return statusbar; }
/** * gtk_test_find_sibling: * @base_widget: Valid widget, part of a widget hierarchy * @widget_type: Type of a aearched for sibling widget * * This function will search siblings of @base_widget and siblings of its * ancestors for all widgets matching @widget_type. * Of the matching widgets, the one that is geometrically closest to * @base_widget will be returned. * The general purpose of this function is to find the most likely "action" * widget, relative to another labeling widget. Such as finding a * button or text entry widget, given its corresponding label widget. * * Returns: (transfer none): a widget of type @widget_type if any is found. * * Since: 2.14 **/ GtkWidget* gtk_test_find_sibling (GtkWidget *base_widget, GType widget_type) { GList *siblings = NULL; GtkWidget *tmpwidget = base_widget; gpointer data[2]; /* find all sibling candidates */ while (tmpwidget) { tmpwidget = gtk_widget_get_parent (tmpwidget); siblings = g_list_concat (siblings, test_list_descendants (tmpwidget, widget_type)); } /* sort them by distance to base_widget */ data[0] = gtk_widget_get_toplevel (base_widget); data[1] = base_widget; siblings = g_list_sort_with_data (siblings, widget_geo_cmp, data); /* pick nearest != base_widget */ siblings = g_list_remove (siblings, base_widget); tmpwidget = siblings ? siblings->data : NULL; g_list_free (siblings); return tmpwidget; }
void _gcr_display_view_clear (GcrDisplayView *self, GcrRenderer *renderer) { GtkTextIter start, iter; GcrDisplayItem *item; g_return_if_fail (GCR_IS_DISPLAY_VIEW (self)); item = lookup_display_item (self, renderer); g_return_if_fail (item); if (gtk_widget_get_parent (item->details_widget)) gtk_container_remove (GTK_CONTAINER (self), item->details_widget); gtk_text_buffer_get_iter_at_mark (self->pv->buffer, &start, item->beginning); gtk_text_buffer_get_iter_at_mark (self->pv->buffer, &iter, item->ending); gtk_text_buffer_delete (self->pv->buffer, &start, &iter); g_return_if_fail (!gtk_text_mark_get_deleted (item->beginning)); g_return_if_fail (!gtk_text_mark_get_deleted (item->ending)); item->extra_tag = NULL; item->field_width = 0; item->details = FALSE; }
/** * go_combo_popup_reparent * @popup: Popup * @new_parent: New parent * @unrealize: Unrealize popup if TRUE. * * Reparent the popup, taking care of the refcounting * * Compare with gtk_menu_reparent in gtk/gtkmenu.c */ static void go_combo_popup_reparent (GtkWidget *popup, GtkWidget *new_parent, gboolean unrealize) { gboolean was_floating = g_object_is_floating (popup); g_object_ref_sink (popup); if (unrealize) { g_object_ref (popup); gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (popup)), popup); gtk_container_add (GTK_CONTAINER (new_parent), popup); g_object_unref (popup); } else gtk_widget_reparent (GTK_WIDGET (popup), new_parent); gtk_widget_set_size_request (new_parent, -1, -1); if (was_floating) { g_object_force_floating (G_OBJECT (popup)); } else g_object_unref (popup); }
static void gtk_image_menu_item_get_preferred_height_for_width (GtkWidget *widget, gint width, gint *minimum, gint *natural) { GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget); GtkImageMenuItemPrivate *priv = image_menu_item->priv; gint child_height = 0; GtkPackDirection pack_dir; GtkWidget *parent; parent = gtk_widget_get_parent (widget); if (GTK_IS_MENU_BAR (parent)) pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent)); else pack_dir = GTK_PACK_DIRECTION_LTR; if (priv->image && gtk_widget_get_visible (priv->image)) { GtkRequisition child_requisition; gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL); child_height = child_requisition.height; } GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->get_preferred_height_for_width (widget, width, minimum, natural); if (pack_dir == GTK_PACK_DIRECTION_RTL || pack_dir == GTK_PACK_DIRECTION_LTR) { *minimum = MAX (*minimum, child_height); *natural = MAX (*natural, child_height); } }
static void palette_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection, guint info, guint time, gpointer data) { GtkToolItemGroup *drop_group = NULL; GtkWidget *drag_palette = gtk_drag_get_source_widget (context); GtkWidget *drag_item = NULL; GtkAllocation allocation; while (drag_palette && !GTK_IS_TOOL_PALETTE (drag_palette)) drag_palette = gtk_widget_get_parent (drag_palette); if (drag_palette) { drag_item = gtk_tool_palette_get_drag_item (GTK_TOOL_PALETTE (drag_palette), selection); drop_group = gtk_tool_palette_get_drop_group (GTK_TOOL_PALETTE (widget), x, y); gtk_widget_get_allocation (GTK_WIDGET (drop_group), &allocation); } if (GTK_IS_TOOL_ITEM_GROUP (drag_item)) palette_drop_group (GTK_TOOL_PALETTE (drag_palette), GTK_TOOL_ITEM_GROUP (drag_item), drop_group); else if (GTK_IS_TOOL_ITEM (drag_item) && drop_group) palette_drop_item (GTK_TOOL_ITEM (drag_item), drop_group, x - allocation.x, y - allocation.y); }
static void append_child_attrs_foreach (gpointer key, gpointer value, gpointer user_data) { if (!value) { return; } GParamSpec *spec; GError *error = NULL; GValue gval = { 0 }; GtkWidget *child = GTK_WIDGET (user_data); GtkWidget *parent = gtk_widget_get_parent (child); spec = gtk_container_class_find_child_property (G_OBJECT_GET_CLASS (parent), (char *)key); if (!spec || G_TYPE_FUNDAMENTAL (G_PARAM_SPEC_VALUE_TYPE (spec)) == G_TYPE_OBJECT) { return; } #if 1 g_print ("found child property %s.%s on %s\n", g_type_name (G_TYPE_FROM_INSTANCE (parent)), spec->name, g_type_name (G_TYPE_FROM_INSTANCE (child))); #endif if (gtk_builder_value_from_string (NULL, spec, g_value_get_string ((const GValue *)value), &gval, &error)) { gtk_container_child_set_property (GTK_CONTAINER (parent), child, spec->name, &gval); g_value_unset (&gval); } else { g_print ("Error getting value_from_string: %s\n", error->message); g_error_free (error); } }
static AtkObject * eti_ref_accessible_at_point (AtkComponent *component, gint x, gint y, AtkCoordType coord_type) { gint row = -1; gint col = -1; gint x_origin, y_origin; ETableItem *item; GtkWidget *tableOrTree; item = E_TABLE_ITEM (eti_a11y_get_gobject (ATK_OBJECT (component))); if (!item) return NULL; atk_component_get_position ( component, &x_origin, &y_origin, coord_type); x -= x_origin; y -= y_origin; tableOrTree = gtk_widget_get_parent (GTK_WIDGET (item->parent.canvas)); if (E_IS_TREE (tableOrTree)) e_tree_get_cell_at (E_TREE (tableOrTree), x, y, &row, &col); else e_table_get_cell_at (E_TABLE (tableOrTree), x, y, &row, &col); if (row != -1 && col != -1) { return eti_ref_at (ATK_TABLE (component), row, col); } else { return NULL; } }
static void hd_status_area_box_remove (GtkContainer *container, GtkWidget *child) { HDStatusAreaBoxPrivate *priv; GList *c; g_return_if_fail (HD_IS_STATUS_AREA_BOX (container)); g_return_if_fail (GTK_IS_WIDGET (child)); g_return_if_fail (gtk_widget_get_parent (child) == (GtkWidget *)container); priv = HD_STATUS_AREA_BOX (container)->priv; /* search for child in children and remove it */ for (c = priv->children; c; c = c->next) { HDStatusAreaBoxChild *info = c->data; if (info->widget == child) { gboolean visible; visible = gtk_widget_is_visible (child); gtk_widget_unparent (child); priv->children = g_list_delete_link (priv->children, c); g_slice_free (HDStatusAreaBoxChild, info); /* resize container if child was visible */ if (visible) gtk_widget_queue_resize (GTK_WIDGET (container)); break; } } }
/* When parameters in 'All' column in arpeggiator changed, update the whole * row with the same value. */ void on_all_changed (GtkWidget *widget, gpointer user_data) { struct all_updater all_updater; const char *id = gtk_buildable_get_name(GTK_BUILDABLE(widget)); if (!id) return; /* Now mangle parameter name (= widget id) to something matchable */ /* First, need to make copy of string in order to add %d in it */ char format[strlen(id) + 1]; strcpy(format, id); /* Find "All" */ char *allpos = strstr(format, "All"); if (!allpos) return; /* Can't find "All" in widget name, can't do more */ /* Change All to %d */ strcpy(allpos, "%d"); all_updater.format = format; /* Get value of the All parameter */ if (GTK_IS_COMBO_BOX(widget)) all_updater.value = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); else if (GTK_IS_TOGGLE_BUTTON(widget)) all_updater.value = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); /* Add other widget types as needed */ /* Now update all children of the parent container */ /* Actually, we cheat a bit here, we just scan all children of the * immediate parent, which is fine for the arpeggiator where all the * step widgets are in the same box; on a more global scale we'd have * to start at the top window, and recursively scan every container we * find. */ GtkWidget *container = gtk_widget_get_parent(widget); GList *container_children = gtk_container_get_children(GTK_CONTAINER(container)); g_list_foreach(container_children, set_value, &all_updater); }
void plugin_init(GeanyData *data) { /* get a handle on the frame that holds the vte stuff */ vte_frame = get_vte_frame(); /* make sure it's really the frame holding the vte stuff */ if (vte_frame == NULL || !holds_vte(vte_frame)) { show_error_message(); return; } /* set a flag for the cleanup function to use */ have_vte = TRUE; /* store where the vte frame is going to go */ vte_new_home = GTK_NOTEBOOK(geany_data->main_widgets->sidebar_notebook); /* store where the vte was so we can put it back */ vte_old_home = GTK_NOTEBOOK(gtk_widget_get_parent(vte_frame)); /* grab the notebook page label so we can set it on the new tab */ vte_tab_label = gtk_notebook_get_tab_label(vte_old_home, vte_frame); /* increase the ref count so the label doesn't get destroy when we * reparent the notebook child */ g_object_ref(G_OBJECT(vte_tab_label)); /* move the vte frame to the sidebar notebook */ gtk_widget_reparent(vte_frame, GTK_WIDGET(vte_new_home)); /* set the label again since it's gone somewhere */ gtk_notebook_set_tab_label(vte_new_home, GTK_WIDGET(vte_frame), vte_tab_label); /* select the new vte tab in the sidebar */ gtk_notebook_set_current_page(vte_new_home, -1); }
GimpSessionInfoDock * gimp_session_info_dock_from_widget (GimpDock *dock) { GimpSessionInfoDock *dock_info; GList *list; GtkWidget *parent; g_return_val_if_fail (GIMP_IS_DOCK (dock), NULL); dock_info = gimp_session_info_dock_new (GIMP_IS_TOOLBOX (dock) ? "gimp-toolbox" : "gimp-dock"); for (list = gimp_dock_get_dockbooks (dock); list; list = g_list_next (list)) { GimpSessionInfoBook *book; book = gimp_session_info_book_from_widget (list->data); dock_info->books = g_list_prepend (dock_info->books, book); } dock_info->books = g_list_reverse (dock_info->books); dock_info->side = gimp_session_info_dock_get_side (dock); parent = gtk_widget_get_parent (GTK_WIDGET (dock)); if (GTK_IS_PANED (parent)) { GtkPaned *paned = GTK_PANED (parent); if (GTK_WIDGET (dock) == gtk_paned_get_child2 (paned)) dock_info->position = gtk_paned_get_position (paned); } return dock_info; }
void cd_weather_load_custom_widget (GldiModuleInstance *myApplet, GKeyFile* pKeyFile, GSList *pWidgetList) { if (!myApplet) // if called when the applet is not started return; cd_debug ("%s (%s)", __func__, myIcon->cName); //\____________ On recupere le widget. CairoDockGroupKeyWidget *pGroupKeyWidget = cairo_dock_gui_find_group_key_widget_in_list (pWidgetList, "Configuration", "location code"); GtkWidget *pCodeEntry = cairo_dock_gui_get_first_widget (pGroupKeyWidget); myData.pCodeEntry = pCodeEntry; g_return_if_fail (pCodeEntry != NULL); g_signal_connect (myData.pCodeEntry, "delete", G_CALLBACK (_on_destroyed_code_entry), myApplet); /// TODO: remove it on stop, to handle the case our applet is deactivated while the config window is opened. GtkWidget *pWidgetBox = gtk_widget_get_parent (pCodeEntry); GtkWidget *pLabel = gtk_label_new (D_("Search for your location :")); gtk_box_pack_start (GTK_BOX (pWidgetBox), pLabel, FALSE, FALSE, 0); GtkWidget *pLocationEntry = gtk_entry_new (); gtk_widget_set_tooltip_text (pLocationEntry, D_("Enter the name of your location and press Enter to choose amongst results.")); if (myData.wdata.cLocation != NULL) gtk_entry_set_text (GTK_ENTRY (pLocationEntry), (gchar *)myData.wdata.cLocation); gtk_box_pack_start (GTK_BOX (pWidgetBox), pLocationEntry, FALSE, FALSE, 0); g_signal_connect (pLocationEntry, "activate", G_CALLBACK (_cd_weather_search_for_location), myApplet); }
/* Translates coordinates from dest_widget->window relative (src_x, src_y), * to allocation relative (dest_x, dest_y) of dest_widget. */ static void window_to_alloc (GtkWidget *dest_widget, gint src_x, gint src_y, gint *dest_x, gint *dest_y) { GtkAllocation dest_allocation; gtk_widget_get_allocation (dest_widget, &dest_allocation); /* Translate from window relative to allocation relative */ if (gtk_widget_get_has_window (dest_widget) && gtk_widget_get_parent (dest_widget)) { gint wx, wy; gdk_window_get_position (gtk_widget_get_window (dest_widget), &wx, &wy); /* Offset coordinates if widget->window is smaller than * widget->allocation. */ src_x += wx - dest_allocation.x; src_y += wy - dest_allocation.y; } else { src_x -= dest_allocation.x; src_y -= dest_allocation.y; } if (dest_x) *dest_x = src_x; if (dest_y) *dest_y = src_y; }
static void panel_action_button_clicked (GtkButton *gtk_button) { PanelActionButton *button; g_return_if_fail (PANEL_IS_ACTION_BUTTON (gtk_button)); button = PANEL_ACTION_BUTTON (gtk_button); g_return_if_fail (button->priv->type > PANEL_ACTION_NONE); g_return_if_fail (button->priv->type < PANEL_ACTION_LAST); if (panel_global_config_get_drawer_auto_close ()) { PanelToplevel *toplevel; toplevel = PANEL_WIDGET (gtk_widget_get_parent (GTK_WIDGET (button)))->toplevel; if (panel_toplevel_get_is_attached (toplevel)) panel_toplevel_hide (toplevel, FALSE, -1); } if (actions [button->priv->type].invoke) actions [button->priv->type].invoke (GTK_WIDGET (button)); }
static void debug_manager_notify_debugger (IdeDebuggerEditorAddin *self, GParamSpec *pspec, IdeDebugManager *debug_manager) { IdeDebugger *debugger; IdeWorkspace *workspace; g_assert (IDE_IS_DEBUGGER_EDITOR_ADDIN (self)); g_assert (IDE_IS_DEBUG_MANAGER (debug_manager)); if (!gtk_widget_get_visible (GTK_WIDGET (self->panel))) { GtkWidget *stack = gtk_widget_get_parent (GTK_WIDGET (self->panel)); gtk_widget_show (GTK_WIDGET (self->panel)); if (GTK_IS_STACK (stack)) gtk_stack_set_visible_child (GTK_STACK (stack), GTK_WIDGET (self->panel)); } debugger = ide_debug_manager_get_debugger (debug_manager); if ((workspace = ide_widget_get_workspace (GTK_WIDGET (self->editor)))) gtk_widget_insert_action_group (GTK_WIDGET (workspace), "debugger", G_ACTION_GROUP (debugger)); ide_debugger_breakpoints_view_set_debugger (self->breakpoints_view, debugger); ide_debugger_locals_view_set_debugger (self->locals_view, debugger); ide_debugger_libraries_view_set_debugger (self->libraries_view, debugger); ide_debugger_registers_view_set_debugger (self->registers_view, debugger); ide_debugger_threads_view_set_debugger (self->threads_view, debugger); dzl_signal_group_set_target (self->debugger_signals, debugger); }
PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool, bool, bool, bool drawSelectionRect) { WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); GtkWidget* viewContainer = gtk_widget_get_parent(GTK_WIDGET(view)); gint width, height; #ifdef GTK_API_VERSION_2 GdkPixmap* pixmap = gtk_widget_get_snapshot(viewContainer, 0); gdk_pixmap_get_size(pixmap, &width, &height); #else width = gtk_widget_get_allocated_width(viewContainer); height = gtk_widget_get_allocated_height(viewContainer); #endif cairo_surface_t* imageSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); cairo_t* context = cairo_create(imageSurface); #ifdef GTK_API_VERSION_2 gdk_cairo_set_source_pixmap(context, pixmap, 0, 0); cairo_paint(context); g_object_unref(pixmap); #else gtk_widget_draw(viewContainer, context); #endif if (drawSelectionRect) { cairo_rectangle_int_t rectangle; DumpRenderTreeSupportGtk::rectangleForSelection(mainFrame, &rectangle); cairo_set_line_width(context, 1.0); cairo_rectangle(context, rectangle.x, rectangle.y, rectangle.width, rectangle.height); cairo_set_source_rgba(context, 1.0, 0.0, 0.0, 1.0); cairo_stroke(context); } return BitmapContext::createByAdoptingBitmapAndContext(0, context); }