char *content_type;
GFile *gfile;
GtkOpenWithDialogMode mode;
+ gboolean show_other_applications;
GtkWidget *label;
GtkWidget *entry;
PROP_GFILE = 1,
PROP_CONTENT_TYPE,
PROP_MODE,
+ PROP_SHOW_OTHER_APPLICATIONS,
N_PROPERTIES
};
!g_app_info_supports_files (app))
continue;
- if (!heading_added)
+ /* hide the heading if we don't show other applications */
+ if (!heading_added && self->priv->show_other_applications)
{
gtk_list_store_append (self->priv->program_list_store, &iter);
gtk_list_store_set (self->priv->program_list_store, &iter,
heading_added = FALSE;
- for (l = all_applications; l != NULL; l = l->next)
+ for (l = all_applications; l != NULL && self->priv->show_other_applications; l = l->next)
{
GAppInfo *app = l->data;
GtkTreeIter iter;
case PROP_MODE:
self->priv->mode = g_value_get_enum (value);
break;
+ case PROP_SHOW_OTHER_APPLICATIONS:
+ self->priv->show_other_applications = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
break;
case PROP_MODE:
g_value_set_enum (value, self->priv->mode);
- break;;
+ break;
+ case PROP_SHOW_OTHER_APPLICATIONS:
+ g_value_set_boolean (value, self->priv->show_other_applications);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
GTK_OPEN_WITH_DIALOG_MODE_OPEN_FILE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
+ properties[PROP_SHOW_OTHER_APPLICATIONS] =
+ g_param_spec_boolean ("show-other-applications",
+ P_("Whether to show other applications"),
+ P_("Whether the dialog should show applications other than the recommended list"),
+ TRUE,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, N_PROPERTIES,
properties);
return retval;
}
+
+void
+gtk_open_with_dialog_set_show_other_applications (GtkOpenWithDialog *self,
+ gboolean show_other_applications)
+{
+ g_return_if_fail (GTK_IS_OPEN_WITH_DIALOG (self));
+
+ if (self->priv->show_other_applications != show_other_applications)
+ {
+ self->priv->show_other_applications = show_other_applications;
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_OTHER_APPLICATIONS]);
+ }
+}
+
+gboolean
+gtk_open_with_get_show_other_applications (GtkOpenWithDialog *self)
+{
+ g_return_val_if_fail (GTK_IS_OPEN_WITH_DIALOG (self), FALSE);
+
+ return self->priv->show_other_applications;
+}