Exemple #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;
}
Exemple #2
1
void activate_action_string(GmpvApplication *app, const gchar *str)
{
	GActionMap *map = G_ACTION_MAP(app);
	GAction *action = NULL;
	gchar *name = NULL;
	GVariant *param = NULL;
	gboolean param_match = FALSE;

	g_action_parse_detailed_name(str, &name, &param, NULL);

	if(name)
	{
		const GVariantType *action_ptype;
		const GVariantType *given_ptype;

		action = g_action_map_lookup_action(map, name);
		action_ptype = g_action_get_parameter_type(action);
		given_ptype = param?g_variant_get_type(param):NULL;

		param_match =	(action_ptype == given_ptype) ||
				g_variant_type_is_subtype_of
				(action_ptype, given_ptype);
	}

	if(action && param_match)
	{
		g_debug("Activating action %s", str);
		g_action_activate(action, param);
	}
	else
	{
		g_warning("Failed to activate action \"%s\"", str);
	}
}
static void
photos_main_window_constructed (GObject *object)
{
  PhotosMainWindow *self = PHOTOS_MAIN_WINDOW (object);
  GApplication *app;

  G_OBJECT_CLASS (photos_main_window_parent_class)->constructed (object);

  /* HACK: Since GtkWindow:application is a non-construct property it
   * will be set after constructed has finished. We explicitly add
   * the window to the application here before creating the rest of
   * the widget hierarchy. This ensures that we can use
   * photos_application_get_scale_factor while constructing the
   * widgets.
   */
  app = g_application_get_default ();
  gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (self));

  self->edit_cancel = g_action_map_lookup_action (G_ACTION_MAP (app), "edit-cancel");
  self->import_cancel = g_action_map_lookup_action (G_ACTION_MAP (app), "import-cancel");
  self->load_next = g_action_map_lookup_action (G_ACTION_MAP (app), "load-next");
  self->load_previous = g_action_map_lookup_action (G_ACTION_MAP (app), "load-previous");

  gtk_widget_init_template (GTK_WIDGET (self));
}
Exemple #4
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;
}
static void
photos_preview_nav_buttons_init (PhotosPreviewNavButtons *self)
{
  GAction *action;
  GApplication *app;
  PhotosSearchContextState *state;

  app = g_application_get_default ();
  state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));

  self->load_next = g_action_map_lookup_action (G_ACTION_MAP (app), "load-next");
  g_signal_connect_object (self->load_next,
                           "activate",
                           G_CALLBACK (photos_preview_nav_buttons_next),
                           self,
                           G_CONNECT_SWAPPED);

  self->load_previous = g_action_map_lookup_action (G_ACTION_MAP (app), "load-previous");
  g_signal_connect_object (self->load_previous,
                           "activate",
                           G_CALLBACK (photos_preview_nav_buttons_previous),
                           self,
                           G_CONNECT_SWAPPED);

  self->item_mngr = g_object_ref (state->item_mngr);
  self->mode_cntrlr = g_object_ref (state->mode_cntrlr);

  action = g_action_map_lookup_action (G_ACTION_MAP (app), "delete");
  g_signal_connect_object (action,
                           "activate",
                           G_CALLBACK (photos_preview_nav_buttons_delete),
                           self,
                           G_CONNECT_SWAPPED);
}
Exemple #7
0
static void
eog_application_init_app_menu (EogApplication *application)
{
	EogApplicationPrivate *priv = application->priv;
	GtkBuilder *builder;
	GError *error = NULL;
	GAction *action;

	g_action_map_add_action_entries (G_ACTION_MAP (application),
					 app_entries, G_N_ELEMENTS (app_entries),
					 application);

	builder = gtk_builder_new ();
	gtk_builder_add_from_file (builder, EOG_DATA_DIR"/eog-app-menu.xml", &error);

	if (error == NULL) {
		gtk_application_set_app_menu (GTK_APPLICATION (application),
					      G_MENU_MODEL (gtk_builder_get_object (builder,
		                                                                    "app-menu")));
	} else {
		g_critical ("Unable to add the application menu: %s\n", error->message);
		g_error_free (error);
	}

	action = g_action_map_lookup_action (G_ACTION_MAP (application),
	                                     "view-gallery");
	g_settings_bind_with_mapping (priv->ui_settings,
	                              EOG_CONF_UI_IMAGE_GALLERY, action,
	                              "state", G_SETTINGS_BIND_DEFAULT,
	                              _settings_map_get_bool_variant,
	                              _settings_map_set_variant,
	                              NULL, NULL);

	action = g_action_map_lookup_action (G_ACTION_MAP (application),
	                                     "toolbar");
	g_settings_bind_with_mapping (priv->ui_settings,
	                              EOG_CONF_UI_TOOLBAR, action, "state",
                                      G_SETTINGS_BIND_DEFAULT,
	                              _settings_map_get_bool_variant,
	                              _settings_map_set_variant,
	                              NULL, NULL);
	action = g_action_map_lookup_action (G_ACTION_MAP (application),
	                                     "view-sidebar");
	g_settings_bind_with_mapping (priv->ui_settings,
	                              EOG_CONF_UI_SIDEBAR, action, "state",
                                      G_SETTINGS_BIND_DEFAULT,
	                              _settings_map_get_bool_variant,
	                              _settings_map_set_variant,
	                              NULL, NULL);
	action = g_action_map_lookup_action (G_ACTION_MAP (application),
	                                     "view-statusbar");
	g_settings_bind_with_mapping (priv->ui_settings,
	                              EOG_CONF_UI_STATUSBAR, action, "state",
                                      G_SETTINGS_BIND_DEFAULT,
	                              _settings_map_get_bool_variant,
	                              _settings_map_set_variant,
	                              NULL, NULL);

	g_object_unref (builder);
}
Exemple #8
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]);
    }
}
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);
	}
}
Exemple #10
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);
}
Exemple #11
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);
}
Exemple #12
0
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);
}
Exemple #13
0
static void
set_auto_spell_from_metadata (GeditSpellPlugin *plugin,
			      GeditView        *view)
{
	gboolean active = FALSE;
	gchar *active_str;
	GeditDocument *doc;
	GeditDocument *active_doc;

	doc = GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
	active_str = gedit_document_get_metadata (doc,
						  GEDIT_METADATA_ATTRIBUTE_SPELL_ENABLED);

	if (active_str)
	{
		active = *active_str == '1';

		g_free (active_str);
	}

	set_auto_spell (plugin->priv->window, view, active);

	/* In case that the doc is the active one we mark the spell action */
	active_doc = gedit_window_get_active_document (plugin->priv->window);

	if (active_doc == doc)
	{
		GAction *action;

		action = g_action_map_lookup_action (G_ACTION_MAP (plugin->priv->window),
		                                     "auto-spell");
		g_action_change_state (action, g_variant_new_boolean (active));
	}
}
Exemple #14
0
static void
tm_populate(GtkWidget * toolbar, BalsaToolbarModel * model)
{
    gboolean style_is_both;
    gboolean make_two_line;
    GArray *current;
    guint j;
    GActionMap *action_map =
        g_object_get_data(G_OBJECT(toolbar), BALSA_TOOLBAR_ACTION_MAP);

    style_is_both = (model->style == GTK_TOOLBAR_BOTH
                     || (model->style == (GtkToolbarStyle) - 1
                         && tm_default_style() == GTK_TOOLBAR_BOTH));
    make_two_line = style_is_both && tm_has_second_line(model);

    current = balsa_toolbar_model_get_current(model);
    for (j = 0; j < current->len; j++) {
        BalsaToolbarEntry *entry;
        GtkToolItem *item;

        entry = &g_array_index(current, BalsaToolbarEntry, j);

        if (!*entry->action) {
            item = gtk_separator_tool_item_new();
        } else {
            GtkWidget *icon;
            GAction *action;
            const GVariantType *type;
            gchar *prefixed_action;

            icon = gtk_image_new_from_icon_name
                (balsa_icon_id(entry->icon), GTK_ICON_SIZE_SMALL_TOOLBAR);
            action = g_action_map_lookup_action(action_map, entry->action);
            if (action &&
                (type = g_action_get_state_type(action)) &&
                g_variant_type_equal(type, G_VARIANT_TYPE_BOOLEAN)) {
                item = gtk_toggle_tool_button_new();
                g_object_set(G_OBJECT(item), "icon-widget", icon,
                             "label", entry->action, NULL);
            } else {
                item = gtk_tool_button_new(icon, entry->action);
            }
            tm_set_tool_item_label(GTK_TOOL_ITEM(item), entry->icon,
                                   make_two_line);

            prefixed_action =
                g_strconcat(action ? "win." : "app.", entry->action, NULL);
            gtk_actionable_set_action_name(GTK_ACTIONABLE(item),
                                           prefixed_action);
            g_free(prefixed_action);
        }
        gtk_toolbar_insert((GtkToolbar *) toolbar, item, -1);
    }

    gtk_toolbar_set_style(GTK_TOOLBAR(toolbar),
                          model->style != (GtkToolbarStyle) (-1) ?
                          model->style : tm_default_style());

    gtk_widget_show_all(toolbar);
}
Exemple #15
0
static void
ide_editor_spell__widget_mapped_cb (IdeEditorSpellWidget *self)
{
  GActionGroup *group = NULL;
  GtkWidget *widget = GTK_WIDGET (self->view);
  g_autoptr (GVariant) value = NULL;

  g_assert (IDE_IS_EDITOR_SPELL_WIDGET (self));

  while ((group == NULL) && (widget != NULL))
    {
      group = gtk_widget_get_action_group (widget, "view");
      widget = gtk_widget_get_parent (widget);
    }

  if (group != NULL &&
      NULL != (self->view_spellchecking_action = g_action_map_lookup_action (G_ACTION_MAP (group),
                                                                             "spellchecking")))
    {
      value = g_action_get_state (self->view_spellchecking_action);
      self->view_spellchecker_set = g_variant_get_boolean (value);
      gtk_switch_set_active (GTK_SWITCH (self->highlight_switch), self->view_spellchecker_set);
    }

  jump_to_next_misspelled_word (self);
}
Exemple #16
0
/**
 * panel_applet_get_action:
 * @applet: a #PanelApplet.
 *
 * ...
 *
 * Returns: 
 **/
GSimpleAction *
panel_applet_get_menu_action (PanelApplet        *applet,
                              const gchar        *action)
{
	return (GSimpleAction *) g_action_map_lookup_action (G_ACTION_MAP (applet->priv->action_group),
	                                                     action);
}
Exemple #17
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 void
photos_selection_toolbar_init (PhotosSelectionToolbar *self)
{
  GAction *action;
  GApplication *app;
  PhotosSearchContextState *state;

  app = g_application_get_default ();
  state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));

  self->item_listeners = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref);

  gtk_widget_init_template (GTK_WIDGET (self));

  self->item_mngr = g_object_ref (state->item_mngr);

  self->sel_cntrlr = photos_selection_controller_dup_singleton ();
  g_signal_connect_object (self->sel_cntrlr,
                           "selection-changed",
                           G_CALLBACK (photos_selection_toolbar_selection_changed),
                           self,
                           G_CONNECT_SWAPPED);
  g_signal_connect_object (self->sel_cntrlr,
                           "selection-mode-changed",
                           G_CALLBACK (photos_selection_toolbar_selection_mode_changed),
                           self,
                           G_CONNECT_SWAPPED);

  action = g_action_map_lookup_action (G_ACTION_MAP (app), "delete");
  g_signal_connect_object (action,
                           "activate",
                           G_CALLBACK (photos_selection_toolbar_delete),
                           self,
                           G_CONNECT_SWAPPED);
}
Exemple #19
0
static gboolean
geyes_applet_fill (PanelApplet *applet)
{
	EyesApplet *eyes_applet;
	GSimpleActionGroup *action_group;
	GAction *action;
	gchar *ui_path;

	panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MINOR);
	
        eyes_applet = create_eyes (applet);

	eyes_applet->settings = panel_applet_settings_new (applet, GEYES_PREFS_SCHEMA);

        eyes_applet->timeout_id = g_timeout_add (
		UPDATE_TIMEOUT, (GSourceFunc) timer_cb, eyes_applet);

	action_group = g_simple_action_group_new ();
	g_action_map_add_action_entries (G_ACTION_MAP (action_group),
	                                 geyes_applet_menu_actions,
	                                 G_N_ELEMENTS (geyes_applet_menu_actions),
	                                 eyes_applet);
	ui_path = g_build_filename (GEYES_MENU_UI_DIR, "geyes-applet-menu.xml", NULL);
	panel_applet_setup_menu_from_file (eyes_applet->applet,
					   ui_path, action_group,
					   GETTEXT_PACKAGE);
	g_free (ui_path);

	gtk_widget_insert_action_group (GTK_WIDGET (applet), "geyes",
	                                G_ACTION_GROUP (action_group));

	action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "preferences");
	g_object_bind_property (applet, "locked-down",
	                        action, "enabled",
	                        G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE);

	g_object_unref (action_group);

	gtk_widget_set_tooltip_text (GTK_WIDGET (eyes_applet->applet), _("Eyes"));

	set_atk_name_description (GTK_WIDGET (eyes_applet->applet), _("Eyes"), 
			_("The eyes look in the direction of the mouse pointer"));

	g_signal_connect (eyes_applet->vbox,
			  "destroy",
			  G_CALLBACK (destroy_cb),
			  eyes_applet);

	gtk_widget_show_all (GTK_WIDGET (eyes_applet->applet));

	/* setup here and not in create eyes so the destroy signal is set so 
	 * that when there is an error within loading the theme
	 * we can emit this signal */
        if (properties_load (eyes_applet) == FALSE)
		return FALSE;

	setup_eyes (eyes_applet);

	return TRUE;
}
Exemple #20
0
static void
create_menus (GtkUIManager * ui_manager)
{
  GtkActionGroup *action_group;

  action_group = gtk_action_group_new ("group");

  gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
  gtk_action_group_add_actions (action_group, action_entry,
				G_N_ELEMENTS (action_entry), window);

  gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
  gtk_ui_manager_add_ui_from_string (ui_manager, ui_description, -1, NULL);
  scores_action = g_action_map_lookup_action (G_ACTION_MAP (application), "Scores");
  undo_action   = g_action_map_lookup_action (G_ACTION_MAP (application), "Undo");
  update_undo_sensitivity();
}
Exemple #21
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);
    }
}
Exemple #22
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;
}
Exemple #23
0
static GAction *
gtk_application_window_lookup_action (GActionMap  *action_map,
                                      const gchar *action_name)
{
  GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (action_map);

  return g_action_map_lookup_action (G_ACTION_MAP (window->priv->actions), action_name);
}
Exemple #24
0
void
gth_window_enable_action (GthWindow  *window,
			  const char *action_name,
			  gboolean    enabled)
{
	GAction *action;

	action = g_action_map_lookup_action (G_ACTION_MAP (window), action_name);
	g_object_set (action, "enabled", enabled, NULL);
}
Exemple #25
0
static GAction *
get_corresponding_window_action (GtkApplication *app,
                                 GAction        *action)
{
  GList *windows = gtk_application_get_windows (app);
  const char *name;

  name = g_action_get_name (G_ACTION (action));
  return g_action_map_lookup_action (G_ACTION_MAP (windows->data), name);
}
Exemple #26
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));
}
Exemple #27
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);
}
Exemple #28
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
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);
    }
}
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));
    }
}