should_set_default =
(self->priv->mode == GTK_OPEN_WITH_DIALOG_MODE_SELECT_DEFAULT) ||
- (self->priv->mode == GTK_OPEN_WITH_DIALOG_MODE_OPEN_FILE &&
+ (self->priv->mode == GTK_OPEN_WITH_DIALOG_MODE_SELECT_ONE &&
gtk_widget_get_visible (self->priv->checkbox) &&
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->checkbox)));
success = TRUE;
description = g_content_type_get_description (self->priv->content_type);
- if (self->priv->mode == GTK_OPEN_WITH_DIALOG_MODE_OPEN_FILE)
+ if (self->priv->mode == GTK_OPEN_WITH_DIALOG_MODE_SELECT_ONE)
{
- /* we have the GFile, its content type and its name and extension. */
- gtk_window_set_title (GTK_WINDOW (self), _("Open With"));
+ if (self->priv->gfile != NULL)
+ gtk_window_set_title (GTK_WINDOW (self), _("Open With"));
+ else
+ gtk_window_set_title (GTK_WINDOW (self), _("Select Application"));
- /* Translators: %s is a filename */
- label = g_strdup_printf (_("Open %s with:"), emname);
+ if (emname != NULL)
+ {
+ /* Translators: %s is a filename */
+ label = g_strdup_printf (_("Open %s with:"), emname);
- if (g_content_type_is_unknown (self->priv->content_type))
- /* Translators: the %s is the extension of the file */
- checkbox_text = g_strdup_printf (_("_Remember this application for %s documents"),
- extension);
+ if (g_content_type_is_unknown (self->priv->content_type))
+ /* Translators: the %s is the extension of the file */
+ checkbox_text = g_strdup_printf (_("_Remember this application for %s documents"),
+ extension);
+ else
+ /* Translators: %s is a file type description */
+ checkbox_text = g_strdup_printf (_("_Remember this application for \"%s\" files"),
+ description);
+ }
else
- /* Translators: %s is a file type description */
- checkbox_text = g_strdup_printf (_("_Remember this application for \"%s\" files"),
- description);
+ {
+ /* we're in the content_type + SELECT_ONE case */
+
+ /* Translators: %s is a file type description */
+ label = g_strdup_printf (_("Select an application for \"%s\" files:"),
+ g_content_type_is_unknown (self->priv->content_type) ?
+ self->priv->content_type : description);
+
+ /* Translators: %s is a file type description */
+ checkbox_text = g_strdup_printf (_("_Remember this application for \"%s\" files"),
+ g_content_type_is_unknown (self->priv->content_type) ?
+ self->priv->content_type : description);
+ }
gtk_button_set_label (GTK_BUTTON (self->priv->checkbox), checkbox_text);
g_free (checkbox_text);
/* Translators: first %s is a filename and second %s is a file extension */
label = g_strdup_printf (_("Open %s and other %s document with:"),
emname, extension);
- else;
- /* TODO: content type is unknown and no file provided?? */
+ else
+ label = g_strdup_printf (_("Open all \"%s\" files with:"), self->priv->content_type);
}
else
{
P_("The dialog mode"),
P_("The operation mode for this dialog"),
GTK_TYPE_OPEN_WITH_DIALOG_MODE,
- GTK_OPEN_WITH_DIALOG_MODE_OPEN_FILE,
+ GTK_OPEN_WITH_DIALOG_MODE_SELECT_ONE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
properties[PROP_SHOW_OTHER_APPLICATIONS] =
GtkWidget *
gtk_open_with_dialog_new_for_content_type (GtkWindow *parent,
GtkDialogFlags flags,
+ GtkOpenWithDialogMode mode,
const gchar *content_type)
{
GtkWidget *retval;
retval = g_object_new (GTK_TYPE_OPEN_WITH_DIALOG,
"content-type", content_type,
- "mode", GTK_OPEN_WITH_DIALOG_MODE_SELECT_DEFAULT,
+ "mode", mode,
NULL);
set_parent_and_flags (retval, parent, flags);
static GtkWidget *toplevel;
static GFile *file;
static GtkWidget *grid, *file_l, *open, *show_all, *show_set_as_default;
-static GtkWidget *radio_file, *radio_content_from_file, *radio_content, *dialog;
+static GtkWidget *radio_file, *radio_file_default, *radio_content, *radio_content_default, *dialog;
static void
dialog_response (GtkDialog *d,
gpointer user_data)
{
gboolean use_file = FALSE;
- gboolean use_content = FALSE;
+ gboolean default_mode = FALSE;
gchar *content_type = NULL;
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_content_from_file)))
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_file)))
{
use_file = TRUE;
- use_content = TRUE;
+ default_mode = FALSE;
}
- else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_file)))
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_file_default)))
{
use_file = TRUE;
- use_content = FALSE;
+ default_mode = TRUE;
}
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_content)))
{
- GFileInfo *info;
-
use_file = FALSE;
- use_content = TRUE;
-
- info = g_file_query_info (file,
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
- 0, NULL, NULL);
- content_type = g_strdup (g_file_info_get_content_type (info));
-
- g_object_unref (info);
- }
+ default_mode = FALSE;
+ }
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_content_default)))
+ {
+ use_file = FALSE;
+ default_mode = TRUE;
+ }
if (use_file)
{
dialog = gtk_open_with_dialog_new (GTK_WINDOW (toplevel),
- 0, use_content ?
+ 0, default_mode ?
GTK_OPEN_WITH_DIALOG_MODE_SELECT_DEFAULT :
- GTK_OPEN_WITH_DIALOG_MODE_OPEN_FILE,
+ GTK_OPEN_WITH_DIALOG_MODE_SELECT_ONE,
file);
}
else
{
+ GFileInfo *info;
+
+ info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ 0, NULL, NULL);
+ content_type = g_strdup (g_file_info_get_content_type (info));
+
+ g_object_unref (info);
+
dialog = gtk_open_with_dialog_new_for_content_type (GTK_WINDOW (toplevel),
- 0, content_type);
+ 0, default_mode ?
+ GTK_OPEN_WITH_DIALOG_MODE_SELECT_DEFAULT :
+ GTK_OPEN_WITH_DIALOG_MODE_SELECT_ONE,
+ content_type);
}
gtk_open_with_dialog_set_show_other_applications (GTK_OPEN_WITH_DIALOG (dialog),
g_signal_connect (file_l, "clicked",
G_CALLBACK (button_clicked), NULL);
- radio_file = gtk_radio_button_new_with_label (NULL, "Use GFile");
- radio_content_from_file = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio_file),
- "Use content type and GFile");
+ radio_file = gtk_radio_button_new_with_label (NULL, "Use GFile and select one");
+ radio_file_default = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio_file),
+ "Use GFile and select default");
radio_content = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio_file),
- "Use content type only");
+ "Use content type and select one");
+ radio_content_default = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio_file),
+ "Use content type and select default");
gtk_grid_attach (GTK_GRID (grid), radio_file,
0, 1, 1, 1);
- gtk_grid_attach_next_to (GTK_GRID (grid), radio_content_from_file,
+ gtk_grid_attach_next_to (GTK_GRID (grid), radio_file_default,
radio_file, GTK_POS_BOTTOM, 1, 1);
gtk_grid_attach_next_to (GTK_GRID (grid), radio_content,
- radio_content_from_file, GTK_POS_BOTTOM, 1, 1);
+ radio_file_default, GTK_POS_BOTTOM, 1, 1);
+ gtk_grid_attach_next_to (GTK_GRID (grid), radio_content_default,
+ radio_content, GTK_POS_BOTTOM, 1, 1);
open = gtk_button_new_with_label ("Trigger Open With dialog");
gtk_grid_attach_next_to (GTK_GRID (grid), open,
- radio_content, GTK_POS_BOTTOM, 1, 1);
+ radio_content_default, GTK_POS_BOTTOM, 1, 1);
gtk_widget_set_sensitive (open, FALSE);
g_signal_connect (open, "clicked",
G_CALLBACK (display_dialog), NULL);