Пример #1
0
void TableofcontentsNoteAddin::get_toc_popover_items(std::vector<Gtk::Widget*> & items) const
{
  std::vector<TocItem> toc_items;

  get_toc_items(toc_items);
  if(toc_items.size()) {
    auto item = dynamic_cast<Gtk::ModelButton*>(gnote::utils::create_popover_button("win.tableofcontents-goto-heading", ""));
    Gtk::Label *label = (Gtk::Label*)item->get_child();
    label->set_markup("<b>" + get_note()->get_title() + "</b>");
    gtk_actionable_set_action_target_value(GTK_ACTIONABLE(item->gobj()), g_variant_new_int32(0));
    item->property_role() = Gtk::BUTTON_ROLE_NORMAL;
    item->property_inverted() = true;
    item->property_centered() = false;
    items.push_back(item);
  }

  for(auto & toc_item : toc_items) {
    if(toc_item.heading_level == Heading::Level_2) {
      toc_item.heading = "→  " + toc_item.heading;
    }
    auto item = dynamic_cast<Gtk::ModelButton*>(gnote::utils::create_popover_button("win.tableofcontents-goto-heading", toc_item.heading));
    if(toc_item.heading_level == Heading::Level_1) {
      item->set_image(*manage(new Gtk::Image(Gtk::Stock::GO_FORWARD, Gtk::ICON_SIZE_MENU)));
    }
    gtk_actionable_set_action_target_value(GTK_ACTIONABLE(item->gobj()), g_variant_new_int32(toc_item.heading_position));
    item->property_role() = Gtk::BUTTON_ROLE_NORMAL;
    item->property_inverted() = true;
    item->property_centered() = false;
    items.push_back(item);
  }
}
Пример #2
0
static void
photos_zoom_controls_update_buttons (PhotosZoomControls *self)
{
  GtkWidget *image;
  gboolean zoom_best_fit_enabled;
  gboolean zoom_out_enabled;
  const gchar *icon_name;

  zoom_best_fit_enabled = g_action_get_enabled (self->zoom_best_fit_action);
  zoom_out_enabled = g_action_get_enabled (self->zoom_out_action);
  g_return_if_fail (zoom_best_fit_enabled == zoom_out_enabled);

  gtk_revealer_set_reveal_child (GTK_REVEALER (self->revealer), zoom_out_enabled);

  gtk_actionable_set_action_name (GTK_ACTIONABLE (self->zoom_toggle_button), NULL);
  gtk_actionable_set_action_target_value (GTK_ACTIONABLE (self->zoom_toggle_button), NULL);

  if (zoom_out_enabled)
    {
      gtk_actionable_set_action_name (GTK_ACTIONABLE (self->zoom_toggle_button), "app.zoom-best-fit");
    }
  else
    {
      GVariant *target_value = NULL;

      target_value = photos_utils_create_zoom_target_value (1.0, PHOTOS_ZOOM_EVENT_MOUSE_CLICK);
      gtk_actionable_set_action_target_value (GTK_ACTIONABLE (self->zoom_toggle_button), target_value);
      gtk_actionable_set_action_name (GTK_ACTIONABLE (self->zoom_toggle_button), "app.zoom-in");
    }

  icon_name = zoom_out_enabled ? "zoom-fit-best-symbolic" : "zoom-in-symbolic";
  image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_INVALID);
  gtk_image_set_pixel_size (GTK_IMAGE (image), 16);
  gtk_button_set_image (GTK_BUTTON (self->zoom_toggle_button), image);
}
static void
gb_preferences_switch_set_settings_schema_value (GbPreferencesSwitch *self,
                                                 GVariant            *variant)
{
  g_return_if_fail (GB_IS_PREFERENCES_SWITCH (self));

  gtk_actionable_set_action_target_value (GTK_ACTIONABLE (self->settings_switch), variant);
  gtk_actionable_set_action_target_value (GTK_ACTIONABLE (self->settings_radio), variant);
}
Пример #4
0
static void
pnl_tab_strip_child_position_changed (PnlTabStrip *self,
                                      GParamSpec  *pspec,
                                      GtkWidget   *child)
{
  GVariant *state;
  GtkWidget *parent;
  PnlTab *tab;
  guint position;

  g_assert (PNL_IS_TAB_STRIP (self));
  g_assert (GTK_IS_WIDGET (child));

  tab = g_object_get_data (G_OBJECT (child), "PNL_TAB");

  if (!tab || !PNL_IS_TAB (tab))
    return;

  parent = gtk_widget_get_parent (child);

  gtk_container_child_get (GTK_CONTAINER (parent), child,
                           "position", &position,
                           NULL);

  gtk_container_child_set (GTK_CONTAINER (self), GTK_WIDGET (tab),
                           "position", position,
                           NULL);

  state = g_variant_new_int32 (position);
  gtk_actionable_set_action_target_value (GTK_ACTIONABLE (tab), state);
}
Пример #5
0
static void
gtk_tool_button_set_action_target_value (GtkActionable *actionable,
                                         GVariant      *action_target)
{
  GtkToolButton *button = GTK_TOOL_BUTTON (actionable);

  gtk_actionable_set_action_target_value (GTK_ACTIONABLE (button->priv->button), action_target);
}
Пример #6
0
/**
 * gtk_actionable_set_action_target:
 * @actionable: a #GtkActionable widget
 * @format_string: a GVariant format string
 * @...: arguments appropriate for @format_string
 *
 * Sets the target of an actionable widget.
 *
 * This is a convenience function that calls g_variant_new() for
 * @format_string and uses the result to call
 * gtk_actionable_set_action_target_value().
 *
 * If you are setting a string-valued target and want to set the action
 * name at the same time, you can use
 * gtk_actionable_set_detailed_action_name ().
 *
 * Since: 3.4
 **/
void
gtk_actionable_set_action_target (GtkActionable *actionable,
                                  const gchar   *format_string,
                                  ...)
{
  va_list ap;

  va_start (ap, format_string);
  gtk_actionable_set_action_target_value (actionable, g_variant_new_va (format_string, NULL, &ap));
  va_end (ap);
}
Пример #7
0
/**
 * gtk_actionable_set_detailed_action_name:
 * @actionable: a #GtkActionable widget
 * @detailed_action_name: the detailed action name
 *
 * Sets the action-name and associated string target value of an
 * actionable widget.
 *
 * This allows for the effect of both gtk_actionable_set_action_name()
 * and gtk_actionable_set_action_target_value() in the common case that
 * the target is string-valued.
 *
 * @detailed_action_name is a string of the form
 * `"action::target"` where `action`
 * is the action name and `target` is the string to use
 * as the target.
 *
 * Since: 3.4
 **/
void
gtk_actionable_set_detailed_action_name (GtkActionable *actionable,
                                         const gchar   *detailed_action_name)
{
  gchar **parts;

  g_return_if_fail (GTK_IS_ACTIONABLE (actionable));

  if (detailed_action_name == NULL)
    {
      gtk_actionable_set_action_name (actionable, NULL);
      gtk_actionable_set_action_target_value (actionable, NULL);
      return;
    }

  parts = g_strsplit (detailed_action_name, "::", 2);
  gtk_actionable_set_action_name (actionable, parts[0]);
  if (parts[0] && parts[1])
    gtk_actionable_set_action_target (actionable, "s", parts[1]);
  else
    gtk_actionable_set_action_target_value (actionable, NULL);
  g_strfreev (parts);
}
Пример #8
0
void BacklinksNoteAddin::get_backlink_menu_items(std::list<Gtk::Widget*> & items) const
{
  gnote::NoteBase::List notes = get_note()->manager().get_notes_linking_to(get_note()->get_title());
  FOREACH(const gnote::NoteBase::Ptr & note, notes) {
    if(note != get_note()) { // don't match ourself
      auto button = manage(gnote::utils::create_popover_button("win.backlinks-open-note", note->get_title()));
      gtk_actionable_set_action_target_value(GTK_ACTIONABLE(button->gobj()),
        Glib::Variant<Glib::ustring>::create(note->uri()).gobj());
      items.push_back(button);
    }
  }

  items.sort([](Gtk::Widget *x, Gtk::Widget *y)
    {
      return dynamic_cast<Gtk::ModelButton*>(x)->get_label() < dynamic_cast<Gtk::ModelButton*>(y)->get_label();
    });
}
static void
photos_tool_filter_button_set_action_target_value (GtkActionable *actionable, GVariant *action_target)
{
  PhotosToolFilterButton *self = PHOTOS_TOOL_FILTER_BUTTON (actionable);
  gtk_actionable_set_action_target_value (GTK_ACTIONABLE (self->button), action_target);
}