예제 #1
1
GtkWidget *
hitori_create_interface (Hitori *hitori)
{
	GtkBuilder *builder;
	GtkStyleContext *style_context;
	GtkCssProvider *css_provider;
	const PangoFontDescription *font;
	GAction *action;

	builder = gtk_builder_new_from_resource ("/org/gnome/Hitori/ui/hitori.ui");

	gtk_builder_set_translation_domain (builder, PACKAGE);
	gtk_builder_connect_signals (builder, hitori);

	/* Setup the main window */
	hitori->window = GTK_WIDGET (gtk_builder_get_object (builder, "hitori_main_window"));
	hitori->drawing_area = GTK_WIDGET (gtk_builder_get_object (builder, "hitori_drawing_area"));
	hitori->timer_label = GTK_LABEL (gtk_builder_get_object (builder, "hitori_timer"));

	g_object_unref (builder);

	/* Set up actions */
	g_action_map_add_action_entries (G_ACTION_MAP (hitori), app_entries, G_N_ELEMENTS (app_entries), hitori);
	g_action_map_add_action_entries (G_ACTION_MAP (hitori->window), win_entries, G_N_ELEMENTS (win_entries), hitori);

	action = g_settings_create_action (hitori->settings, "board-size");
	g_action_map_add_action (G_ACTION_MAP (hitori), action);
	g_signal_connect (G_OBJECT (action), "notify::state", (GCallback) board_size_change_cb, hitori);
	g_object_unref (action);

	hitori->undo_action = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (hitori->window), "undo"));
	hitori->redo_action = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (hitori->window), "redo"));
	hitori->hint_action = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (hitori->window), "hint"));

	/* Set up font descriptions for the drawing area */
	style_context = gtk_widget_get_style_context (hitori->drawing_area);
	gtk_style_context_get (style_context,
	                       gtk_style_context_get_state (style_context),
	                       GTK_STYLE_PROPERTY_FONT, &font, NULL);
	hitori->normal_font_desc = pango_font_description_copy (font);
	hitori->painted_font_desc = pango_font_description_copy (font);

	/* Load CSS for the drawing area */
	css_provider = gtk_css_provider_new ();
	gtk_css_provider_load_from_resource (css_provider, "/org/gnome/Hitori/ui/hitori.css");
	gtk_style_context_add_provider (style_context, GTK_STYLE_PROVIDER (css_provider),
                                            GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	g_object_unref (css_provider);

	/* Reset the timer */
	hitori_reset_timer (hitori);

	/* Disable undo/redo until a cell has been clicked. */
	g_simple_action_set_enabled (hitori->undo_action, FALSE);
	g_simple_action_set_enabled (hitori->redo_action, FALSE);

	return hitori->window;
}
예제 #2
0
void
ide_editor_frame_actions_init (IdeEditorFrame *self)
{
  GSimpleActionGroup *group;
  GAction *action;

  g_assert (IDE_IS_EDITOR_FRAME (self));

  group = g_simple_action_group_new ();
  g_action_map_add_action_entries (G_ACTION_MAP (group), IdeEditorFrameActions,
                                   G_N_ELEMENTS (IdeEditorFrameActions), self);
  gtk_widget_insert_action_group (GTK_WIDGET (self), "frame", G_ACTION_GROUP (group));
  g_object_unref (group);

  group = g_simple_action_group_new ();
  g_action_map_add_action_entries (G_ACTION_MAP (group), IdeEditorFrameSearchActions,
                                   G_N_ELEMENTS (IdeEditorFrameSearchActions), self);

  /* Disable replace and replace-all by default; they should only be enabled
   * when the corresponding operations would make sense.
   */
  action = g_action_map_lookup_action (G_ACTION_MAP (group), "replace");
  g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
  action = g_action_map_lookup_action (G_ACTION_MAP (group), "replace-all");
  g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);

  gtk_widget_insert_action_group (GTK_WIDGET (self->search_frame), "search-entry", G_ACTION_GROUP (group));
  g_object_unref (group);
}
static gboolean
change_interval (gpointer user_data)
{
    g_message ("change interval");

    IndicatorTestService *indicator = user_data;

    GAction* action_switch = g_action_map_lookup_action(G_ACTION_MAP(indicator->actions), "action.switch");
    actual_switch(G_SIMPLE_ACTION(action_switch));

    GAction* action_checkbox = g_action_map_lookup_action(G_ACTION_MAP(indicator->actions), "action.checkbox");
    actual_switch(G_SIMPLE_ACTION(action_checkbox));

    GAction* action_accessPoint = g_action_map_lookup_action(G_ACTION_MAP(indicator->actions), "action.accessPoint");
    actual_switch(G_SIMPLE_ACTION(action_accessPoint));

    GAction* action_slider = g_action_map_lookup_action(G_ACTION_MAP(indicator->actions), "action.slider");
    static double old_value = 0.25;
    double new_value = old_value == 0.25 ? 0.75 : 0.25;
    old_value = new_value;
    Action* slide_action = malloc(sizeof(Action));
    slide_action->action = G_SIMPLE_ACTION(action_slider);
    slide_action->value = g_variant_new_double(new_value);
    actual_slide(slide_action);

    return TRUE;
}
예제 #4
0
static void
photos_preview_nav_buttons_update_visibility (PhotosPreviewNavButtons *self)
{
  PhotosBaseItem *item;
  PhotosBaseItem *next_item;
  PhotosBaseItem *previous_item;

  item = PHOTOS_BASE_ITEM (photos_base_manager_get_active_object (self->item_mngr));
  if (self->old_mode == PHOTOS_WINDOW_MODE_NONE || item == NULL || !self->visible)
    {
      self->enable_prev = FALSE;
      self->enable_next = FALSE;
      goto out;
    }

  previous_item = photos_preview_nav_buttons_get_previous_item (self);
  self->enable_prev = previous_item != NULL;

  next_item = photos_preview_nav_buttons_get_next_item (self);
  self->enable_next = next_item != NULL;

 out:
  if (self->visible_internal && self->enable_next)
    photos_preview_nav_buttons_fade_in_button (self, self->next_widget);
  else
    photos_preview_nav_buttons_fade_out_button (self, self->next_widget);

  if (self->visible_internal && self->enable_prev)
    photos_preview_nav_buttons_fade_in_button (self, self->prev_widget);
  else
    photos_preview_nav_buttons_fade_out_button (self, self->prev_widget);

  g_simple_action_set_enabled (G_SIMPLE_ACTION (self->load_next), self->enable_next);
  g_simple_action_set_enabled (G_SIMPLE_ACTION (self->load_previous), self->enable_prev);
}
예제 #5
0
void on_menu_changed(gpointer instance, GVariant *parameters, gpointer user_data)
{
  WorkraveApplet *applet = WORKRAVE_APPLET(user_data);

  GVariantIter *iter;
  g_variant_get (parameters, "(a(sii))", &iter);

  char *text;
  int id;
  int flags;

  gboolean visible[sizeof(menu_data)/sizeof(struct Menuitems)];
  for (int i = 0; i < sizeof(menu_data)/sizeof(struct Menuitems); i++)
    {
      visible[i] = menu_data[i].visible_when_not_running;
    }

  while (g_variant_iter_loop(iter, "(sii)", &text, &id, &flags))
    {
      int index = lookup_menu_index_by_id((enum MenuCommand)id);
      if (index == -1)
        {
          continue;
        }

      GAction *action = g_action_map_lookup_action(G_ACTION_MAP(applet->priv->action_group), menu_data[index].action);

      if (flags & MENU_ITEM_FLAG_SUBMENU_END ||
          flags & MENU_ITEM_FLAG_SUBMENU_BEGIN)
        {
          continue;
        }

      visible[index] = TRUE;

      if (g_action_get_state_type(G_ACTION(action)) != NULL)
        {
          if (menu_data[index].state == NULL)
            {
              g_simple_action_set_state(G_SIMPLE_ACTION(action), g_variant_new_boolean(flags & MENU_ITEM_FLAG_ACTIVE));
            }
          else
            {
              if (flags & MENU_ITEM_FLAG_ACTIVE)
                {
                  g_simple_action_set_state(G_SIMPLE_ACTION(action), g_variant_new_string(menu_data[index].state));
                }
            }
        }
    }

  g_variant_iter_free (iter);

  for (int i = 0; i < sizeof(menu_data)/sizeof(struct Menuitems); i++)
    {
      GAction *action = g_action_map_lookup_action(G_ACTION_MAP(applet->priv->action_group), menu_data[i].action);
      g_simple_action_set_enabled(G_SIMPLE_ACTION(action), visible[i]);
    }
}
예제 #6
0
static void
update_ui (GeditSpellPlugin *plugin)
{
	GeditSpellPluginPrivate *priv;
	GeditView *view;
	GAction *check_spell_action;
	GAction *config_spell_action;
	GAction *auto_spell_action;

	gedit_debug (DEBUG_PLUGINS);

	priv = plugin->priv;

	view = gedit_window_get_active_view (priv->window);

	check_spell_action = g_action_map_lookup_action (G_ACTION_MAP (priv->window),
	                                                 "check-spell");
	g_simple_action_set_enabled (G_SIMPLE_ACTION (check_spell_action),
	                             (view != NULL) &&
	                             gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));

	config_spell_action = g_action_map_lookup_action (G_ACTION_MAP (priv->window),
	                                                  "config-spell");
	g_simple_action_set_enabled (G_SIMPLE_ACTION (config_spell_action),
	                             (view != NULL) &&
	                             gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));

	auto_spell_action = g_action_map_lookup_action (G_ACTION_MAP (priv->window),
	                                                "auto-spell");
	g_simple_action_set_enabled (G_SIMPLE_ACTION (auto_spell_action),
	                             (view != NULL) &&
	                             gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));

	if (view != NULL)
	{
		GeditDocument *doc;
		GeditTab *tab;
		GeditTabState state;
		gboolean autospell;

		doc = GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
		tab = gedit_window_get_active_tab (priv->window);
		state = gedit_tab_get_state (tab);
		autospell = (doc != NULL &&
		             gedit_automatic_spell_checker_get_from_document (doc) != NULL);

		/* If the document is loading we can't get the metadata so we
		   endup with an useless speller */
		if (state == GEDIT_TAB_STATE_NORMAL)
		{
			g_action_change_state (auto_spell_action, g_variant_new_boolean (autospell));
		}

		g_simple_action_set_enabled (G_SIMPLE_ACTION (check_spell_action),
		                             gtk_text_buffer_get_char_count (GTK_TEXT_BUFFER (doc)) > 0);
	}
}
static void
set_menu_items_state (TotemDiscRecorderPlugin *pi,
		      gboolean                 dvd,
		      gboolean                 dvd_copy,
		      gboolean                 vcd_copy)
{
	g_simple_action_set_enabled (G_SIMPLE_ACTION (pi->priv->dvd_action), dvd);
	g_simple_action_set_enabled (G_SIMPLE_ACTION (pi->priv->copy_action), dvd_copy);
	g_simple_action_set_enabled (G_SIMPLE_ACTION (pi->priv->copy_vcd_action), vcd_copy);
}
예제 #8
0
static void
update_replace_actions_sensitivity (IdeEditorFrame *self)
{
  GtkSourceSearchContext *search_context;
  GtkSourceSearchSettings *search_settings;
  GtkTextBuffer *buffer;
  GtkTextIter start;
  GtkTextIter end;
  const gchar *search_text;
  const gchar *replace_text;
  gint pos;
  gint count;
  gboolean enable_replace;
  gboolean enable_replace_all;
  gboolean replace_regex_valid;
  g_autoptr(GError) regex_error = NULL;
  g_autoptr(GError) replace_regex_error = NULL;
  GActionGroup *group;
  GAction *replace_action;
  GAction *replace_all_action;

  g_assert (IDE_IS_EDITOR_FRAME (self));

  search_context = ide_source_view_get_search_context (self->source_view);
  search_settings = gtk_source_search_context_get_settings (search_context);
  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->source_view));
  gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (buffer), &start, &end);
  replace_text = gtk_entry_get_text (GTK_ENTRY (self->replace_entry));

  /* Gather enough info to determine if Replace or Replace All would make sense */
  search_text = gtk_entry_get_text (GTK_ENTRY (self->search_entry));
  pos = gtk_source_search_context_get_occurrence_position (search_context, &start, &end);
  count = gtk_source_search_context_get_occurrences_count (search_context);
  regex_error = gtk_source_search_context_get_regex_error (search_context);
  replace_regex_valid = gtk_source_search_settings_get_regex_enabled (search_settings) ?
                        g_regex_check_replacement (replace_text, NULL, &replace_regex_error) :
                        TRUE;

  enable_replace = (!ide_str_empty0 (search_text) &&
                    regex_error == NULL &&
                    replace_regex_valid &&
                    pos > 0);

  enable_replace_all = (!ide_str_empty0 (search_text) &&
                        regex_error == NULL &&
                        replace_regex_valid &&
                        count > 0);

  group = gtk_widget_get_action_group (GTK_WIDGET (self->search_frame), "search-entry");
  replace_action = g_action_map_lookup_action (G_ACTION_MAP (group), "replace");
  replace_all_action = g_action_map_lookup_action (G_ACTION_MAP (group), "replace-all");

  g_simple_action_set_enabled (G_SIMPLE_ACTION (replace_action), enable_replace);
  g_simple_action_set_enabled (G_SIMPLE_ACTION (replace_all_action), enable_replace_all);
}
예제 #9
0
static void
enable_win_actions (PtWindow *win,
                    gboolean  state)
{
    GAction   *action;

    action = g_action_map_lookup_action (G_ACTION_MAP (win), "copy");
    g_simple_action_set_enabled (G_SIMPLE_ACTION (action), state);

    action = g_action_map_lookup_action (G_ACTION_MAP (win), "goto");
    g_simple_action_set_enabled (G_SIMPLE_ACTION (action), state);
}
static void
g_simple_action_set_state (GAction  *action,
                           GVariant *value)
{
  GSimpleAction *simple = G_SIMPLE_ACTION (action);

  g_return_if_fail (value != NULL);

  {
    const GVariantType *state_type;

    state_type = simple->priv->state ?
                   g_variant_get_type (simple->priv->state) : NULL;
    g_return_if_fail (state_type != NULL);
    g_return_if_fail (g_variant_is_of_type (value, state_type));
  }

  g_variant_ref_sink (value);

  if (!g_variant_equal (simple->priv->state, value))
    {
      if (simple->priv->state)
        g_variant_unref (simple->priv->state);

      simple->priv->state = g_variant_ref (value);

      g_object_notify (G_OBJECT (simple), "state");
    }

  g_variant_unref (value);
}
static gboolean
g_simple_action_get_enabled (GAction *action)
{
  GSimpleAction *simple = G_SIMPLE_ACTION (action);

  return simple->priv->enabled;
}
예제 #12
0
void
ide_application_actions_update (IdeApplication *self)
{
  GList *windows;
  GAction *action;
  gboolean enabled;

  g_assert (IDE_IS_APPLICATION (self));

  /*
   * We only enable the preferences action if we have a workbench open
   * that is past the greeter.
   */
  action = g_action_map_lookup_action (G_ACTION_MAP (self), "preferences");
  enabled = FALSE;
  for (windows = gtk_application_get_windows (GTK_APPLICATION (self));
       windows != NULL;
       windows = windows->next)
    {
      GtkWindow *window = windows->data;

      if (IDE_IS_WORKBENCH (window) &&
          !ide_str_equal0 ("greeter",
                           ide_workbench_get_visible_perspective_name (IDE_WORKBENCH (window))))
        {
          enabled = TRUE;
          break;
        }
    }
  g_simple_action_set_enabled (G_SIMPLE_ACTION (action), enabled);
}
static const gchar *
g_simple_action_get_name (GAction *action)
{
  GSimpleAction *simple = G_SIMPLE_ACTION (action);

  return simple->priv->name;
}
예제 #14
0
파일: testgmenu.c 프로젝트: 3v1n0/gtk
static void
enabled_cell_toggled (GtkCellRendererToggle *cell,
                      const gchar           *path_str,
                      GtkTreeModel          *model)
{
  GActionGroup *group;
  GAction *action;
  gchar *name;
  GtkTreePath *path;
  GtkTreeIter iter;
  gboolean enabled;

  group = g_object_get_data (G_OBJECT (model), "group");
  path = gtk_tree_path_new_from_string (path_str);
  gtk_tree_model_get_iter (model, &iter, path);
  gtk_tree_model_get (model, &iter, 0, &name, -1);

  enabled = g_action_group_get_action_enabled (group, name);
  action = g_action_map_lookup_action (G_ACTION_MAP (group), name);
  g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !enabled);

  gtk_tree_model_row_changed (model, path, &iter);

  g_free (name);
  gtk_tree_path_free (path);
}
const GVariantType *
g_simple_action_get_parameter_type (GAction *action)
{
  GSimpleAction *simple = G_SIMPLE_ACTION (action);

  return simple->priv->parameter_type;
}
static GVariant *
g_simple_action_get_state (GAction *action)
{
  GSimpleAction *simple = G_SIMPLE_ACTION (action);

  return simple->priv->state ? g_variant_ref (simple->priv->state) : NULL;
}
예제 #17
0
/*
 * To stop the recursive search within directories or saving files
 */
void Action_Main_Stop_Button_Pressed (void)
{
    GAction *action;

    action = g_action_map_lookup_action (G_ACTION_MAP (MainWindow), "stop");
    g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
    Main_Stop_Button_Pressed = TRUE;
}
예제 #18
0
static void
ide_editor_frame__search_populate_popup (IdeEditorFrame *self,
                                         GtkWidget      *popup,
                                         GdTaggedEntry  *entry)
{
  g_assert (IDE_IS_EDITOR_FRAME (self));
  g_assert (GTK_IS_WIDGET (popup));
  g_assert (GD_IS_TAGGED_ENTRY (entry));

  if (GTK_IS_MENU_SHELL (popup))
    {
      GMenu *menu;
      GActionGroup *group;
      GAction *action;
      GtkEntryBuffer *buffer;
      GtkClipboard *clipboard;
      gboolean clipboard_contains_text;
      gboolean entry_has_selection;

      group = gtk_widget_get_action_group (GTK_WIDGET (self->search_frame), "search-entry");

      menu = ide_application_get_menu_by_id (IDE_APPLICATION_DEFAULT, "ide-editor-frame-search-menu");
      gtk_menu_shell_bind_model (GTK_MENU_SHELL (popup), G_MENU_MODEL (menu), NULL, TRUE);

      clipboard = gtk_widget_get_clipboard (GTK_WIDGET (entry), GDK_SELECTION_CLIPBOARD);
      clipboard_contains_text = gtk_clipboard_wait_is_text_available (clipboard);

      action = g_action_map_lookup_action (G_ACTION_MAP (group), "paste-clipboard");
      g_simple_action_set_enabled (G_SIMPLE_ACTION (action), clipboard_contains_text);

      entry_has_selection = gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), NULL, NULL);

      action = g_action_map_lookup_action (G_ACTION_MAP (group), "cut-clipboard");
      g_simple_action_set_enabled (G_SIMPLE_ACTION (action), entry_has_selection);

      action = g_action_map_lookup_action (G_ACTION_MAP (group), "copy-clipboard");
      g_simple_action_set_enabled (G_SIMPLE_ACTION (action), entry_has_selection);

      action = g_action_map_lookup_action (G_ACTION_MAP (group), "delete-selection");
      g_simple_action_set_enabled (G_SIMPLE_ACTION (action), entry_has_selection);

      action = g_action_map_lookup_action (G_ACTION_MAP (group), "select-all");
      buffer = gtk_entry_get_buffer (GTK_ENTRY (self->search_entry));
      g_simple_action_set_enabled (G_SIMPLE_ACTION (action), gtk_entry_buffer_get_length (buffer) > 0);
    }
}
예제 #19
0
static void
update_actions (RBMediaPlayerSource *source)
{
	RBMediaPlayerSourcePrivate *priv = MEDIA_PLAYER_SOURCE_GET_PRIVATE (source);
	RBSourceLoadStatus status;
	gboolean selected;

	g_object_get (source,
		      "load-status", &status,
		      "selected", &selected,
		      NULL);

	if (selected) {
		g_simple_action_set_enabled (G_SIMPLE_ACTION (priv->sync_action),
					     (status == RB_SOURCE_LOAD_STATUS_LOADED) && (priv->syncing == FALSE));
		g_simple_action_set_enabled (G_SIMPLE_ACTION (priv->properties_action),
					     (status == RB_SOURCE_LOAD_STATUS_LOADED));
	}
}
static const GVariantType *
g_simple_action_get_state_type (GAction *action)
{
  GSimpleAction *simple = G_SIMPLE_ACTION (action);

  if (simple->priv->state != NULL)
    return g_variant_get_type (simple->priv->state);
  else
    return NULL;
}
예제 #21
0
static void
photos_searchbar_change_state (PhotosSearchbar *self, GVariant *value)
{
  g_simple_action_set_state (G_SIMPLE_ACTION (self->priv->search), value);

  if (g_variant_get_boolean (value))
    photos_searchbar_show (self);
  else
    photos_searchbar_hide (self);
}
static gboolean
actual_slide (gpointer user_data)
{
    Action *slide_action = user_data;

    g_simple_action_set_state(G_SIMPLE_ACTION(slide_action->action), slide_action->value);
    g_message ("sliding %f", g_variant_get_double(slide_action->value));
    free(slide_action);

    return FALSE;
}
예제 #23
0
static void
pref_playlist_shuffle_changed (GSettings  *settings,
	  	 	       const char *key,
	  	 	       gpointer    user_data)
{
	GooApplication *application = user_data;

	g_simple_action_set_state (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (application), PREF_PLAYLIST_SHUFFLE)),
				   g_variant_new_boolean (g_settings_get_boolean (application->priv->settings, PREF_PLAYLIST_SHUFFLE)));
	update_actions_sensitivity (G_APPLICATION (application));
}
예제 #24
0
/*
 * GdauiDsnEditor class implementation
 */
static void
_changed_cb (GdauiDsnEditor *config)
{
	gboolean can_save = FALSE;
	can_save = gdaui_dsn_editor_has_been_changed (config);
	GtkWindow *win;
	win = gtk_application_get_active_window (GTK_APPLICATION (g_application_get_default ()));
	GAction *action;
	action = g_action_map_lookup_action (G_ACTION_MAP (win), "DSNReset");
	g_simple_action_set_enabled (G_SIMPLE_ACTION (action), can_save);
}
static void
g_simple_action_set_property (GObject      *object,
                              guint         prop_id,
                              const GValue *value,
                              GParamSpec   *pspec)
{
  GSimpleAction *simple = G_SIMPLE_ACTION (object);

  switch (prop_id)
    {
    case PROP_NAME:
      g_assert (simple->priv->name == NULL);
      simple->priv->name = g_value_dup_string (value);
      break;

    case PROP_PARAMETER_TYPE:
      g_assert (simple->priv->parameter_type == NULL);
      simple->priv->parameter_type = g_value_dup_boxed (value);
      break;

    case PROP_ENABLED:
      g_simple_action_set_enabled (simple, g_value_get_boolean (value));
      break;

    case PROP_STATE:
      /* PROP_STATE is marked as G_PARAM_CONSTRUCT so we always get a
       * call during object construction, even if it is NULL.  We treat
       * that first call differently, for a number of reasons.
       *
       * First, we don't want the value to be rejected by the
       * possibly-overridden .set_state() function.  Second, we don't
       * want to be tripped by the assertions in g_simple_action_set_state()
       * that would enforce the catch22 that we only provide a value of
       * the same type as the existing value (when there is not yet an
       * existing value).
       */
      if (simple->priv->state_set)
        g_simple_action_set_state (G_ACTION (simple),
                                   g_value_get_variant (value));

      else /* this is the special case */
        {
          /* only do it the first time. */
          simple->priv->state_set = TRUE;

          /* blindly set it. */
          simple->priv->state = g_value_dup_variant (value);
        }
      break;

    default:
      g_assert_not_reached ();
    }
}
예제 #26
0
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
photos_preview_nav_buttons_update_visibility (PhotosPreviewNavButtons *self)
{
  GtkTreeIter iter;
  GtkTreeIter tmp;
  GtkTreePath *current_path = NULL;

  if (self->model == NULL
      || !gtk_tree_row_reference_valid (self->current_row)
      || !self->visible)
    {
      self->enable_prev = FALSE;
      self->enable_next = FALSE;
      goto out;
    }

  current_path = gtk_tree_row_reference_get_path (self->current_row);
  gtk_tree_model_get_iter (self->model, &iter, current_path);

  tmp = iter;
  self->enable_prev = gtk_tree_model_iter_previous (self->model, &tmp);

  tmp = iter;
  self->enable_next = gtk_tree_model_iter_next (self->model, &tmp);

 out:
  if (self->visible_internal && self->enable_next)
    photos_preview_nav_buttons_fade_in_button (self, self->next_widget);
  else
    photos_preview_nav_buttons_fade_out_button (self, self->next_widget);

  if (self->visible_internal && self->enable_prev)
    photos_preview_nav_buttons_fade_in_button (self, self->prev_widget);
  else
    photos_preview_nav_buttons_fade_out_button (self, self->prev_widget);

  g_simple_action_set_enabled (G_SIMPLE_ACTION (self->load_next), self->enable_next);
  g_simple_action_set_enabled (G_SIMPLE_ACTION (self->load_previous), self->enable_prev);

  g_clear_pointer (&current_path, (GDestroyNotify) gtk_tree_path_free);
}
예제 #28
0
static void
action_set_active_bool (GActionGroup *group, const gchar *action_name, bool value)
{
    g_assert (G_IS_ACTION_GROUP (group));
    g_assert (G_IS_ACTION_MAP (group));

    GAction *action = g_action_map_lookup_action (G_ACTION_MAP (group), action_name);

    if (action) {
        g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_boolean (value));
    }
}
예제 #29
0
static void
action_set_enabled (GActionGroup *group, const gchar *action_name, bool value)
{
    g_assert (G_IS_ACTION_GROUP (group));
    g_assert (G_IS_ACTION_MAP (group));

    GAction *action = g_action_map_lookup_action (G_ACTION_MAP (group), action_name);

    if (action) {
        g_simple_action_set_enabled (G_SIMPLE_ACTION (action), value);
    }
}
예제 #30
0
static void
ide_editor_frame_actions_exit_search (GSimpleAction *action,
                                      GVariant      *state,
                                      gpointer       user_data)
{
  IdeEditorFrame *self = user_data;
  GtkTextBuffer *buffer;
  GActionGroup *group;
  GAction *replace_action;
  GAction *replace_all_action;

  g_assert (IDE_IS_EDITOR_FRAME (self));

  /* stash the search string for later */
  g_free (self->previous_search_string);
  g_object_get (self->search_entry, "text", &self->previous_search_string, NULL);

  /* disable the replace and replace all actions */
  group = gtk_widget_get_action_group (GTK_WIDGET (self->search_frame), "search-entry");
  replace_action = g_action_map_lookup_action (G_ACTION_MAP (group), "replace");
  replace_all_action = g_action_map_lookup_action (G_ACTION_MAP (group), "replace-all");
  g_simple_action_set_enabled (G_SIMPLE_ACTION (replace_action), FALSE);
  g_simple_action_set_enabled (G_SIMPLE_ACTION (replace_all_action), FALSE);

  /* clear the highlights in the source view */
  ide_source_view_clear_search (self->source_view);

  /* disable rubberbanding and ensure insert mark is on screen */
  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->source_view));
  ide_source_view_set_rubberband_search (self->source_view, FALSE);
  ide_source_view_scroll_mark_onscreen (self->source_view,
                                        gtk_text_buffer_get_insert (buffer),
                                        TRUE,
                                        0.5,
                                        0.5);

  /* finally we can focus the source view */
  gtk_widget_grab_focus (GTK_WIDGET (self->source_view));
}