static void
add_clicked_cb (GtkButton *button,
		gpointer user_data)
{
	NautilusMimeApplicationChooser *chooser = user_data;
	GAppInfo *info;
	gchar *message;
	GError *error = NULL;

	info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (chooser->details->open_with_widget));

	if (info == NULL)
		return;

	g_app_info_set_as_last_used_for_type (info, chooser->details->content_type, &error);

	if (error != NULL) {
		message = g_strdup_printf (_("Error while adding “%s”: %s"),
					   g_app_info_get_display_name (info), error->message);
		eel_show_error_dialog (_("Could not add application"),
				       message,
				       GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (chooser))));
		g_error_free (error);
		g_free (message);
	} else {		
		gtk_app_chooser_refresh (GTK_APP_CHOOSER (chooser->details->open_with_widget));
		g_signal_emit_by_name (nautilus_signaller_get_current (), "mime-data-changed");
	}

	g_object_unref (info);
}
static void
remove_clicked_cb (GtkMenuItem *item,
                   gpointer user_data)
{
    NemoMimeApplicationChooser *chooser = user_data;
    GError *error;
    GAppInfo *info;

    info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (chooser->details->open_with_widget));

    if (info) {
        error = NULL;
        if (!g_app_info_remove_supports_type (info,
                                              chooser->details->content_type,
                                              &error)) {
            eel_show_error_dialog (_("Could not forget association"),
                                   error->message,
                                   GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (chooser))));
            g_error_free (error);

        }

        gtk_app_chooser_refresh (GTK_APP_CHOOSER (chooser->details->open_with_widget));
        g_object_unref (info);
    }

    g_signal_emit_by_name (nemo_signaller_get_current (), "mime_data_changed");
}
Пример #3
0
static void
gtk_app_chooser_dialog_refresh (GtkAppChooser *object)
{
  GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);

  gtk_app_chooser_refresh (GTK_APP_CHOOSER (self->priv->app_chooser_widget));
}
Пример #4
0
static void
search_for_mimetype_ready_cb (GObject      *source,
                              GAsyncResult *res,
                              gpointer      user_data)
{
  GtkAppChooserOnline *online = GTK_APP_CHOOSER_ONLINE (source);
  GtkAppChooserDialog *self = user_data;
  GError *error = NULL;

  gdk_threads_enter ();

  _gtk_app_chooser_online_search_for_mimetype_finish (online, res, &error);

  if (error != NULL)
    {
      show_error_dialog (_("Failed to look for applications online"),
                         error->message, GTK_WINDOW (self));
      g_error_free (error);
    }
  else
    {
      gtk_app_chooser_refresh (GTK_APP_CHOOSER (self->priv->app_chooser_widget));
    }

  gdk_threads_leave ();
}
Пример #5
0
static void
other_application_dialog_response_cb (GtkDialog *dialog,
                                      gint response_id,
                                      gpointer user_data)
{
  GtkAppChooserButton *self = user_data;
  GAppInfo *info;

  if (response_id != GTK_RESPONSE_OK)
    {
      /* reset the active item, otherwise we are stuck on
       * 'Other application...'
       */
      gtk_combo_box_set_active (GTK_COMBO_BOX (self), self->priv->last_active);
      gtk_widget_destroy (GTK_WIDGET (dialog));
      return;
    }

  info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (dialog));

  /* refresh the combobox to get the new application */
  gtk_app_chooser_refresh (GTK_APP_CHOOSER (self));
  gtk_app_chooser_button_select_application (self, info);

  g_object_unref (info);
}
Пример #6
0
static void
gtk_app_chooser_widget_initialize_items (GtkAppChooserWidget *self)
{
  /* initial padding */
  g_object_set (self->priv->padding_renderer,
                "xpad", self->priv->show_all ? 0 : 6,
                NULL);

  /* populate the widget */
  gtk_app_chooser_refresh (GTK_APP_CHOOSER (self));
}
static void
reset_clicked_cb (GtkButton *button,
                  gpointer   user_data)
{
    NemoMimeApplicationChooser *chooser;

    chooser = NEMO_MIME_APPLICATION_CHOOSER (user_data);

    g_app_info_reset_type_associations (chooser->details->content_type);
    gtk_app_chooser_refresh (GTK_APP_CHOOSER (chooser->details->open_with_widget));
    gtk_entry_set_text (GTK_ENTRY (chooser->details->custom_entry), "");
    g_signal_emit_by_name (nemo_signaller_get_current (), "mime_data_changed");
}
Пример #8
0
/**
 * gtk_app_chooser_button_set_show_dialog_item:
 * @self: a #GtkAppChooserButton
 * @setting: the new value for #GtkAppChooserButton:show-dialog-item
 *
 * Sets whether the dropdown menu of this button should show an
 * entry to trigger a #GtkAppChooserDialog.
 *
 * Since: 3.0
 */
void
gtk_app_chooser_button_set_show_dialog_item (GtkAppChooserButton *self,
                                             gboolean setting)
{
  if (self->priv->show_dialog_item != setting)
    {
      self->priv->show_dialog_item = setting;

      g_object_notify (G_OBJECT (self), "show-dialog-item");

      gtk_app_chooser_refresh (GTK_APP_CHOOSER (self));
    }
}
static void
reset_clicked_cb (GtkButton *button,
                  gpointer   user_data)
{
	NautilusMimeApplicationChooser *chooser;
	
	chooser = NAUTILUS_MIME_APPLICATION_CHOOSER (user_data);

	g_app_info_reset_type_associations (chooser->details->content_type);
	gtk_app_chooser_refresh (GTK_APP_CHOOSER (chooser->details->open_with_widget));

	g_signal_emit_by_name (nautilus_signaller_get_current (), "mime-data-changed");
}
Пример #10
0
/**
 * gtk_app_chooser_widget_set_show_all:
 * @self: a #GtkAppChooserWidget
 * @setting: the new value for #GtkAppChooserWidget:show-all
 *
 * Sets whether the app chooser should show all applications
 * in a flat list.
 */
void
gtk_app_chooser_widget_set_show_all (GtkAppChooserWidget *self,
                                     gboolean             setting)
{
  g_return_if_fail (GTK_IS_APP_CHOOSER_WIDGET (self));

  if (self->priv->show_all != setting)
    {
      self->priv->show_all = setting;

      g_object_notify (G_OBJECT (self), "show-all");

      gtk_app_chooser_refresh (GTK_APP_CHOOSER (self));
    }
}
Пример #11
0
/**
 * gtk_app_chooser_widget_set_default_text:
 * @self: a #GtkAppChooserWidget
 * @text: the new value for #GtkAppChooserWidget:default-text
 *
 * Sets the text that is shown if there are not applications
 * that can handle the content type.
 */
void
gtk_app_chooser_widget_set_default_text (GtkAppChooserWidget *self,
                                         const gchar         *text)
{
  g_return_if_fail (GTK_IS_APP_CHOOSER_WIDGET (self));

  if (g_strcmp0 (text, self->priv->default_text) != 0)
    {
      g_free (self->priv->default_text);
      self->priv->default_text = g_strdup (text);

      g_object_notify (G_OBJECT (self), "default-text");

      gtk_app_chooser_refresh (GTK_APP_CHOOSER (self));
    }
}
Пример #12
0
static void
forget_menu_item_activate_cb (GtkMenuItem *item,
                              gpointer     user_data)
{
  GtkAppChooserDialog *self = user_data;
  GAppInfo *info;

  info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self));

  if (info != NULL)
    {
      g_app_info_remove_supports_type (info, self->priv->content_type, NULL);

      gtk_app_chooser_refresh (GTK_APP_CHOOSER (self));

      g_object_unref (info);
    }
}
static void
set_as_default_clicked_cb (GtkButton *button,
                           gpointer user_data)
{
    NemoMimeApplicationChooser *chooser = user_data;
    GAppInfo *info;

    if (!chooser->details->custom_info) {
        info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (chooser->details->open_with_widget));
        g_app_info_set_as_default_for_type (info, chooser->details->content_type, NULL);
    } else {
        info = chooser->details->custom_info;
        create_custom_desktop_file (chooser, TRUE);
    }

    gtk_app_chooser_refresh (GTK_APP_CHOOSER (chooser->details->open_with_widget));
    gtk_entry_set_text (GTK_ENTRY (chooser->details->custom_entry), "");
    g_signal_emit_by_name (nemo_signaller_get_current (), "mime_data_changed");
}
static void
add_clicked_cb (GtkButton *button,
		gpointer user_data)
{
	NemoMimeApplicationChooser *chooser = user_data;
	GAppInfo *info;

    if (!chooser->details->custom_info) {
        info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (chooser->details->open_with_widget));
        g_app_info_set_as_last_used_for_type (info, chooser->details->content_type, NULL);
    } else {
        info = chooser->details->custom_info;
        g_app_info_set_as_last_used_for_type (info, chooser->details->content_type, NULL);
    }

	if (info == NULL)
		return;

    gtk_app_chooser_refresh (GTK_APP_CHOOSER (chooser->details->open_with_widget));
    gtk_entry_set_text (GTK_ENTRY (chooser->details->custom_entry), "");
    gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (chooser->details->file_button), "");
    g_signal_emit_by_name (nemo_signaller_get_current (), "mime_data_changed");
}
Пример #15
0
int
main (int argc,
      char **argv)
{
  GtkWidget *w;

  g_type_init ();
  gtk_init (&argc, &argv);

  toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_container_set_border_width (GTK_CONTAINER (toplevel), 12);

  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_container_add (GTK_CONTAINER (toplevel), box);

  combobox = gtk_app_chooser_button_new ("image/jpeg");
  gtk_box_pack_start (GTK_BOX (box), combobox, TRUE, TRUE, 0);

  g_signal_connect (combobox, "changed",
                    G_CALLBACK (combo_changed_cb), NULL);

  w = gtk_label_new (NULL);
  gtk_label_set_markup (GTK_LABEL (w), "<b>Selected app info</b>");
  gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0);

  w = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0);

  sel_image = gtk_image_new ();
  gtk_box_pack_start (GTK_BOX (w), sel_image, TRUE, TRUE, 0);
  sel_name = gtk_label_new (NULL);
  gtk_box_pack_start (GTK_BOX (w), sel_name, TRUE, TRUE, 0);

  gtk_app_chooser_button_set_heading (GTK_APP_CHOOSER_BUTTON (combobox), "Choose one, <i>not</i> two");
  gtk_app_chooser_button_append_separator (GTK_APP_CHOOSER_BUTTON (combobox));
  gtk_app_chooser_button_append_custom_item (GTK_APP_CHOOSER_BUTTON (combobox),
                                             CUSTOM_ITEM,
                                             "Hey, I'm special!",
                                             g_themed_icon_new ("face-smile"));

  /* this one will trigger a warning, and will not be added */
  gtk_app_chooser_button_append_custom_item (GTK_APP_CHOOSER_BUTTON (combobox),
                                             CUSTOM_ITEM,
                                             "Hey, I'm fake!",
                                             g_themed_icon_new ("face-evil"));

  gtk_app_chooser_button_set_show_dialog_item (GTK_APP_CHOOSER_BUTTON (combobox),
                                               TRUE);

  /* connect to the detailed signal */
  g_signal_connect (combobox, "custom-item-activated::" CUSTOM_ITEM,
                    G_CALLBACK (special_item_activated_cb), NULL);

  /* connect to the generic signal too */
  g_signal_connect (combobox, "custom-item-activated",
                    G_CALLBACK (action_cb), NULL);

  /* test refresh on a combo */
  gtk_app_chooser_refresh (GTK_APP_CHOOSER (combobox));

  gtk_app_chooser_button_set_active_custom_item (GTK_APP_CHOOSER_BUTTON (combobox),
                                                 CUSTOM_ITEM);

  gtk_widget_show_all (toplevel);

  g_signal_connect (toplevel, "delete-event",
                    G_CALLBACK (gtk_main_quit), NULL);

  gtk_main ();

  return EXIT_SUCCESS;
}
Пример #16
0
static void
app_info_changed (GAppInfoMonitor     *monitor,
                  GtkAppChooserWidget *self)
{
  gtk_app_chooser_refresh (GTK_APP_CHOOSER (self));
}