void ide_workbench_set_visible_perspective (IdeWorkbench *self, IdePerspective *perspective) { GActionGroup *actions; GtkStack *stack; gchar *id; g_return_if_fail (IDE_IS_WORKBENCH (self)); g_return_if_fail (IDE_IS_PERSPECTIVE (perspective)); stack = GTK_STACK (gtk_widget_get_ancestor (GTK_WIDGET (perspective), GTK_TYPE_STACK)); id = ide_perspective_get_id (perspective); if (!ide_str_equal0 (gtk_stack_get_visible_child_name (stack), id)) { gtk_stack_set_visible_child_name (stack, id); gtk_stack_set_visible_child_name (self->titlebar_stack, id); } g_free (id); actions = ide_perspective_get_actions (perspective); gtk_widget_insert_action_group (GTK_WIDGET (self), "perspective", actions); if ((stack == self->perspectives_stack) && !ide_str_equal0 (gtk_stack_get_visible_child_name (self->top_stack), "perspectives")) { gtk_stack_set_visible_child_name (self->top_stack, "perspectives"); g_timeout_add (1000 + gtk_stack_get_transition_duration (self->top_stack), remove_early_perspectives, g_object_ref (self)); } }
static void update_forward_button_sensitivity (GtkStack *stack, GParamSpec *pspec, GtkWidget *button) { const gchar *vis; vis = gtk_stack_get_visible_child_name (stack); gtk_widget_set_sensitive (button, g_strcmp0 (vis, "3") != 0); }
static gboolean cb_window_key_press_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) { const char *current_page = gtk_stack_get_visible_child_name (GTK_STACK (GsmApplication::get()->stack)); if (strcmp (current_page, "processes") == 0) return gtk_search_bar_handle_event (GTK_SEARCH_BAR (user_data), event); return FALSE; }
static void clickity (GtkButton *button, gpointer stack) { if (g_strcmp0 (gtk_stack_get_visible_child_name (GTK_STACK (stack)), "label") == 0) gtk_stack_set_visible_child_name (GTK_STACK (stack), "clutter"); else gtk_stack_set_visible_child_name (GTK_STACK (stack), "label"); fade = !fade; }
static void ev_sidebar_child_change_cb (GObject *gobject, GParamSpec *pspec, EvSidebar *ev_sidebar) { EvSidebarPrivate *priv = GET_PRIVATE (ev_sidebar); GtkStack *stack = GTK_STACK (priv->stack); const gchar *name; name = gtk_stack_get_visible_child_name (stack); if (name) g_object_notify (G_OBJECT (ev_sidebar), "current-page"); }
static void gb_shortcuts_dialog__entry__changed (GbShortcutsDialog *self, GtkSearchEntry *search_entry) { GbShortcutsDialogPrivate *priv = gb_shortcuts_dialog_get_instance_private (self); g_autoptr(IdePatternSpec) spec = NULL; g_autofree gchar *downcase = NULL; GHashTableIter iter; const gchar *text; const gchar *last_view_name; gpointer key; gpointer value; g_assert (GB_IS_SHORTCUTS_DIALOG (self)); g_assert (GTK_IS_SEARCH_ENTRY (search_entry)); text = gtk_entry_get_text (GTK_ENTRY (search_entry)); if (!text || !*text) { if (priv->last_view_name != NULL) { gtk_stack_set_visible_child_name (priv->stack, priv->last_view_name); return; } } last_view_name = gtk_stack_get_visible_child_name (priv->stack); if (g_strcmp0 (last_view_name, "internal-search") != 0) { g_free (priv->last_view_name); priv->last_view_name = g_strdup (last_view_name); } gtk_stack_set_visible_child_name (priv->stack, "internal-search"); downcase = g_utf8_strdown (text, -1); spec = ide_pattern_spec_new (downcase); g_hash_table_iter_init (&iter, priv->keywords); while (g_hash_table_iter_next (&iter, &key, &value)) { GtkWidget *widget = key; const gchar *keywords = value; gtk_widget_set_visible (widget, ide_pattern_spec_match (spec, keywords)); } }
static void gtk_shortcuts_window_add_section (GtkShortcutsWindow *self, GtkShortcutsSection *section) { GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self); GtkListBoxRow *row; gchar *title; gchar *name; const gchar *visible_section; GtkWidget *label; gtk_container_foreach (GTK_CONTAINER (section), gtk_shortcuts_window_add_search_item, self); g_object_get (section, "section-name", &name, "title", &title, NULL); g_signal_connect (section, "notify", G_CALLBACK (section_notify_cb), self); if (name == NULL) name = g_strdup ("shortcuts"); gtk_stack_add_titled (priv->stack, GTK_WIDGET (section), name, title); visible_section = gtk_stack_get_visible_child_name (priv->stack); if (strcmp (visible_section, "internal-search") == 0 || (priv->initial_section && strcmp (priv->initial_section, visible_section) == 0)) gtk_stack_set_visible_child (priv->stack, GTK_WIDGET (section)); row = g_object_new (GTK_TYPE_LIST_BOX_ROW, "visible", TRUE, NULL); g_object_set_data (G_OBJECT (row), "gtk-shortcuts-section", section); label = g_object_new (GTK_TYPE_LABEL, "margin", 6, "label", title, "xalign", 0.5f, "visible", TRUE, NULL); g_object_set_data (G_OBJECT (section), "gtk-shortcuts-title", label); gtk_container_add (GTK_CONTAINER (row), GTK_WIDGET (label)); gtk_container_add (GTK_CONTAINER (priv->list_box), GTK_WIDGET (row)); update_title_stack (self); g_free (name); g_free (title); }
void update_page_activities (GsmApplication *app) { const char *current_page = gtk_stack_get_visible_child_name (app->stack); if (strcmp (current_page, "processes") == 0) { GAction *search_action = g_action_map_lookup_action (G_ACTION_MAP (app->main_window), "search"); proctable_update (app); proctable_thaw (app); gtk_widget_show (GTK_WIDGET (app->end_process_button)); gtk_widget_show (GTK_WIDGET (app->search_button)); gtk_widget_show (GTK_WIDGET (app->process_menu_button)); update_sensitivity (app); if (g_variant_get_boolean (g_action_get_state (search_action))) gtk_widget_grab_focus (GTK_WIDGET (app->search_entry)); else gtk_widget_grab_focus (GTK_WIDGET (app->tree)); } else { proctable_freeze (app); gtk_widget_hide (GTK_WIDGET (app->end_process_button)); gtk_widget_hide (GTK_WIDGET (app->search_button)); gtk_widget_hide (GTK_WIDGET (app->process_menu_button)); update_sensitivity (app); } if (strcmp (current_page, "resources") == 0) { load_graph_start (app->cpu_graph); load_graph_start (app->mem_graph); load_graph_start (app->net_graph); } else { load_graph_stop (app->cpu_graph); load_graph_stop (app->mem_graph); load_graph_stop (app->net_graph); } if (strcmp (current_page, "disks") == 0) { disks_update (app); disks_thaw (app); } else { disks_freeze (app); } }
static void page_changed_cb (GtkWidget *stack, GParamSpec *pspec, gpointer data) { const gchar *name; GtkWidget *page; if (gtk_widget_in_destruction (stack)) return; name = gtk_stack_get_visible_child_name (GTK_STACK (stack)); if (g_str_equal (name, "page3")) { page = gtk_stack_get_visible_child (GTK_STACK (stack)); set_needs_attention (GTK_WIDGET (page), FALSE); } }
static gdouble dialog_adjustments_get_frac_hours (CcNightLightDialog *self, GtkAdjustment *adj_hours, GtkAdjustment *adj_mins, GtkStack *stack) { gdouble value; value = gtk_adjustment_get_value (adj_hours); value += gtk_adjustment_get_value (adj_mins) / 60.0f; if (g_strcmp0 (gtk_stack_get_visible_child_name (stack), "pm") == 0) value += 12.f; return value; }
static void pocketvox_stack_child_changed(GtkWidget *button, GParamSpec *pspec, gpointer data) { GtkWidget* stack = (GtkWidget *)data; const gchar* name = gtk_stack_get_visible_child_name(GTK_STACK(stack)); if(G_IS_OBJECT(button)) { if(!g_strcmp0("Setup", name)) { gtk_widget_hide(button); } else { gtk_widget_show(button); } } }
static void on_forward_button_clicked (GtkButton *button, GtkStack *stack) { const gchar *seq[] = { "1", "2", "3" }; const gchar *vis; gint i; vis = gtk_stack_get_visible_child_name (stack); for (i = 0; i < G_N_ELEMENTS (seq) - 1; i++) { if (g_strcmp0 (vis, seq[i]) == 0) { gtk_stack_set_visible_child_full (stack, seq[i + 1], GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT); break; } } }
void update_sensitivity(GsmApplication *app) { const char * const selected_actions[] = { "send-signal-stop", "send-signal-cont", "send-signal-end", "send-signal-kill", "priority", "memory-maps", "open-files", "process-properties" }; const char * const processes_actions[] = { "refresh", "search", "show-whose-processes", "show-dependencies" }; size_t i; gboolean processes_sensitivity, selected_sensitivity; GAction *action; processes_sensitivity = (strcmp (gtk_stack_get_visible_child_name (GTK_STACK (app->stack)), "processes") == 0); selected_sensitivity = gtk_tree_selection_count_selected_rows (app->selection) > 0; for (i = 0; i != G_N_ELEMENTS (processes_actions); ++i) { action = g_action_map_lookup_action (G_ACTION_MAP (app->main_window), processes_actions[i]); g_simple_action_set_enabled (G_SIMPLE_ACTION (action), processes_sensitivity); } for (i = 0; i != G_N_ELEMENTS (selected_actions); ++i) { action = g_action_map_lookup_action (G_ACTION_MAP (app->main_window), selected_actions[i]); g_simple_action_set_enabled (G_SIMPLE_ACTION (action), processes_sensitivity & selected_sensitivity); } gtk_revealer_set_reveal_child (GTK_REVEALER (app->proc_actionbar_revealer), selected_sensitivity); }
static void ide_omni_bar_next_message (IdeOmniBar *self) { IdeBuildManager *build_manager; const gchar *name; IdeContext *context; g_assert (IDE_IS_OMNI_BAR (self)); if (NULL == (context = ide_widget_get_context (GTK_WIDGET (self)))) return; build_manager = ide_context_get_build_manager (context); name = gtk_stack_get_visible_child_name (self->message_stack); /* * TODO: This isn't the cleanest way to do this. * We need to come up with a strategy for moving between these * in a way that has a "check" function to determine if we can * toggle to the next child. */ if (g_strcmp0 (name, "config") == 0) { /* Only rotate to build result if we have one and we haven't * flapped too many times. */ if (self->did_build && self->seen_count < 2) gtk_stack_set_visible_child_name (self->message_stack, "build"); } else if (!ide_build_manager_get_busy (build_manager)) { self->seen_count++; gtk_stack_set_visible_child_name (self->message_stack, "config"); } }
const gchar * ide_workbench_get_visible_perspective_name (IdeWorkbench *self) { IdePerspective *perspective; g_return_val_if_fail (IDE_IS_WORKBENCH (self), NULL); perspective = ide_workbench_get_visible_perspective (self); if (perspective != NULL) { GtkWidget *parent; /* * Normally we would call ide_perspective_get_id(), but we want to be * able to return a const gchar*. So instead we just use the registered * name in the stack, which is the same thing. */ parent = gtk_widget_get_parent (GTK_WIDGET (perspective)); return gtk_stack_get_visible_child_name (GTK_STACK (parent)); } return NULL; }
void ide_workbench_set_visible_perspective (IdeWorkbench *self, IdePerspective *perspective) { g_autofree gchar *id = NULL; GActionGroup *actions = NULL; const gchar *current_id; GtkWidget *titlebar; guint restore_duration = 0; g_return_if_fail (IDE_IS_WORKBENCH (self)); g_return_if_fail (IDE_IS_PERSPECTIVE (perspective)); /* * If we can detect that this is the first transition to the editor, * and that our window is not yet displayed, we can avoid the transition * duration altogether. This is handy when first opening a window with * a project loaded, as used by self->disable_greeter. */ if (self->disable_greeter && IDE_IS_EDITOR_PERSPECTIVE (perspective) && !self->did_initial_editor_transition) { self->did_initial_editor_transition = TRUE; restore_duration = gtk_stack_get_transition_duration (self->perspectives_stack); gtk_stack_set_transition_duration (self->perspectives_stack, 0); } current_id = gtk_stack_get_visible_child_name (self->perspectives_stack); id = ide_perspective_get_id (perspective); if (!ide_str_equal0 (current_id, id)) gtk_stack_set_visible_child_name (self->perspectives_stack, id); titlebar = gtk_stack_get_child_by_name (self->header_stack, id); if (titlebar != NULL) gtk_stack_set_visible_child (self->header_stack, titlebar); else gtk_stack_set_visible_child (self->header_stack, GTK_WIDGET (self->header_bar)); actions = ide_perspective_get_actions (perspective); gtk_widget_insert_action_group (GTK_WIDGET (self), "perspective", actions); /* * If we are transitioning to the editor the first time, we can * remove the early perspectives (greeter, etc). */ if (IDE_IS_EDITOR_PERSPECTIVE (perspective)) remove_early_perspectives (self); gtk_widget_set_visible (GTK_WIDGET (self->perspective_menu_button), !ide_perspective_is_early (perspective)); if (self->addins != NULL) peas_extension_set_foreach (self->addins, ide_workbench_notify_perspective_set, perspective); g_clear_object (&actions); if (restore_duration != 0) gtk_stack_set_transition_duration (self->perspectives_stack, restore_duration); /* Notify the application to possibly update actions such * as the preferences state. */ ide_application_actions_update (IDE_APPLICATION_DEFAULT); }
static void gtk_shortcuts_window__entry__changed (GtkShortcutsWindow *self, GtkSearchEntry *search_entry) { GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self); gchar *downcase = NULL; GHashTableIter iter; const gchar *text; const gchar *last_section_name; gpointer key; gpointer value; gboolean has_result; text = gtk_entry_get_text (GTK_ENTRY (search_entry)); if (!text || !*text) { if (priv->last_section_name != NULL) { gtk_stack_set_visible_child_name (priv->stack, priv->last_section_name); return; } } last_section_name = gtk_stack_get_visible_child_name (priv->stack); if (g_strcmp0 (last_section_name, "internal-search") != 0 && g_strcmp0 (last_section_name, "no-search-results") != 0) { g_free (priv->last_section_name); priv->last_section_name = g_strdup (last_section_name); } downcase = g_utf8_strdown (text, -1); g_hash_table_iter_init (&iter, priv->keywords); has_result = FALSE; while (g_hash_table_iter_next (&iter, &key, &value)) { GtkWidget *widget = key; const gchar *keywords = value; gboolean match; if (hidden_by_direction (widget)) match = FALSE; else match = strstr (keywords, downcase) != NULL; gtk_widget_set_visible (widget, match); has_result |= match; } g_free (downcase); if (has_result) gtk_stack_set_visible_child_name (priv->stack, "internal-search"); else gtk_stack_set_visible_child_name (priv->stack, "no-search-results"); }