Пример #1
0
static GtkWidget *
photos_import_dialog_create_collection_button (PhotosBaseItem *collection)
{
  GtkWidget *collection_button;
  GtkWidget *collection_label;
  const gchar *id;
  const gchar *name;

  id = photos_filterable_get_id (PHOTOS_FILTERABLE (collection));
  name = photos_base_item_get_name (collection);

  collection_button = photos_model_button_new ();
  gtk_actionable_set_action_name (GTK_ACTIONABLE (collection_button), "dialog.add-existing");
  gtk_actionable_set_action_target (GTK_ACTIONABLE (collection_button), "s", id);

  collection_label = gtk_label_new (name);
  gtk_widget_set_halign (collection_label, GTK_ALIGN_START);
  gtk_widget_set_hexpand (collection_label, TRUE);
  gtk_container_add (GTK_CONTAINER (collection_button), collection_label);

  return collection_button;
}
Пример #2
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);
}