Esempio n. 1
0
static void
popup_menu_detach (GtkWidget *attach_widget,
                   GtkMenu   *menu)
{
  GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (attach_widget);

  self->priv->popup_menu = NULL;
}
Esempio n. 2
0
static void
gtk_app_chooser_widget_dispose (GObject *object)
{
  GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (object);

  g_clear_object (&self->priv->selected_app_info);

  G_OBJECT_CLASS (gtk_app_chooser_widget_parent_class)->dispose (object);
}
Esempio n. 3
0
static void
gtk_app_chooser_widget_snapshot (GtkWidget   *widget,
                                 GtkSnapshot *snapshot)
{
  GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (widget);
  GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);

  gtk_widget_snapshot_child (widget, priv->overlay, snapshot);
}
Esempio n. 4
0
static GAppInfo *
gtk_app_chooser_widget_get_app_info (GtkAppChooser *object)
{
  GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (object);

  if (self->priv->selected_app_info == NULL)
    return NULL;

  return g_object_ref (self->priv->selected_app_info);
}
Esempio n. 5
0
static void
gtk_app_chooser_widget_finalize (GObject *object)
{
  GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (object);

  g_free (self->priv->content_type);
  g_free (self->priv->default_text);

  G_OBJECT_CLASS (gtk_app_chooser_widget_parent_class)->finalize (object);
}
Esempio n. 6
0
static void
gtk_app_chooser_widget_constructed (GObject *object)
{
  GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (object);

  if (G_OBJECT_CLASS (gtk_app_chooser_widget_parent_class)->constructed != NULL)
    G_OBJECT_CLASS (gtk_app_chooser_widget_parent_class)->constructed (object);

  gtk_app_chooser_widget_initialize_items (self);
}
Esempio n. 7
0
static void
gtk_app_chooser_widget_finalize (GObject *object)
{
  GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (object);

  g_free (self->priv->content_type);
  g_free (self->priv->default_text);
  g_signal_handlers_disconnect_by_func (self->priv->monitor, app_info_changed, self);
  g_object_unref (self->priv->monitor);

  G_OBJECT_CLASS (gtk_app_chooser_widget_parent_class)->finalize (object);
}
Esempio n. 8
0
static void
widget_notify_for_button_cb (GObject    *source,
                             GParamSpec *pspec,
                             gpointer    user_data)
{
  GtkAppChooserDialog *self = user_data;
  GtkAppChooserWidget *widget = GTK_APP_CHOOSER_WIDGET (source);
  gboolean should_hide;

  should_hide = gtk_app_chooser_widget_get_show_other (widget) ||
    self->priv->show_more_clicked;

  if (should_hide)
    gtk_widget_hide (self->priv->show_more_button);
}
Esempio n. 9
0
static void
gtk_app_chooser_widget_measure (GtkWidget       *widget,
                                GtkOrientation  orientation,
                                int             for_size,
                                int            *minimum,
                                int            *natural,
                                int            *minimum_baseline,
                                int            *natural_baseline)
{
  GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (widget);
  GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);

  gtk_widget_measure (priv->overlay, orientation, for_size,
                      minimum, natural,
                      minimum_baseline, natural_baseline);
}
Esempio n. 10
0
static void
gtk_app_chooser_widget_dispose (GObject *object)
{
  GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (object);
  GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);

  g_clear_object (&priv->selected_app_info);

  if (priv->overlay)
    {
      gtk_widget_unparent (priv->overlay);
      priv->overlay = NULL;
    }

  G_OBJECT_CLASS (gtk_app_chooser_widget_parent_class)->dispose (object);
}
Esempio n. 11
0
static void
gtk_app_chooser_widget_refresh (GtkAppChooser *object)
{
  GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (object);

  if (self->priv->program_list_store != NULL)
    {
      gtk_list_store_clear (self->priv->program_list_store);

      /* don't add additional xpad if we don't have headings */
      g_object_set (self->priv->padding_renderer,
                    "visible", !self->priv->show_all,
                    NULL);

      gtk_app_chooser_widget_real_add_items (self);
    }
}
Esempio n. 12
0
static void
gtk_app_chooser_widget_size_allocate (GtkWidget *widget,
                                      int        width,
                                      int        height,
                                      int                  baseline)
{
  GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (widget);
  GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self);

  GTK_WIDGET_CLASS (gtk_app_chooser_widget_parent_class)->size_allocate (widget, width, height, baseline);

  gtk_widget_size_allocate (priv->overlay,
                            &(GtkAllocation) {
                              0, 0,
                              width, height
                            },baseline);
}
Esempio n. 13
0
static void
construct_appchooser_widget (GtkAppChooserDialog *self)
{
  GAppInfo *info;

  /* Need to build the appchooser widget after, because of the content-type construct-only property */
  self->priv->app_chooser_widget = gtk_app_chooser_widget_new (self->priv->content_type);
  gtk_widget_set_vexpand (self->priv->app_chooser_widget, TRUE);
  gtk_box_pack_start (GTK_BOX (self->priv->inner_box), self->priv->app_chooser_widget);


  g_signal_connect (self->priv->app_chooser_widget, "application-selected",
                    G_CALLBACK (widget_application_selected_cb), self);
  g_signal_connect (self->priv->app_chooser_widget, "application-activated",
                    G_CALLBACK (widget_application_activated_cb), self);
  g_signal_connect (self->priv->app_chooser_widget, "notify::show-other",
                    G_CALLBACK (widget_notify_for_button_cb), self);
  g_signal_connect (self->priv->app_chooser_widget, "populate-popup",
                    G_CALLBACK (widget_populate_popup_cb), self);

  /* Add the custom button to the new appchooser */
  gtk_box_pack_start (GTK_BOX (self->priv->inner_box),
                      self->priv->show_more_button);

  gtk_box_pack_start (GTK_BOX (self->priv->inner_box),
                      self->priv->software_button);

  info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self->priv->app_chooser_widget));
  gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, info != NULL);
  if (info)
    g_object_unref (info);

  _gtk_app_chooser_widget_set_search_entry (GTK_APP_CHOOSER_WIDGET (self->priv->app_chooser_widget),
                                            GTK_ENTRY (self->priv->search_entry));

  gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (self->priv->search_bar),
                                         GTK_WIDGET (self));
}
Esempio n. 14
0
static void
gtk_app_chooser_widget_get_property (GObject    *object,
                                     guint       property_id,
                                     GValue     *value,
                                     GParamSpec *pspec)
{
  GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (object);

  switch (property_id)
    {
    case PROP_CONTENT_TYPE:
      g_value_set_string (value, self->priv->content_type);
      break;
    case PROP_SHOW_DEFAULT:
      g_value_set_boolean (value, self->priv->show_default);
      break;
    case PROP_SHOW_RECOMMENDED:
      g_value_set_boolean (value, self->priv->show_recommended);
      break;
    case PROP_SHOW_FALLBACK:
      g_value_set_boolean (value, self->priv->show_fallback);
      break;
    case PROP_SHOW_OTHER:
      g_value_set_boolean (value, self->priv->show_other);
      break;
    case PROP_SHOW_ALL:
      g_value_set_boolean (value, self->priv->show_all);
      break;
    case PROP_DEFAULT_TEXT:
      g_value_set_string (value, self->priv->default_text);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
}
static void
set_dialog_properties (GtkAppChooserDialog *self)
{
  gchar *name;
  gchar *extension;
  gchar *description;
  gchar *string;
  gboolean unknown;
  gchar *title;
  gchar *subtitle;
  gboolean use_header;
  GtkWidget *header;

  name = NULL;
  extension = NULL;
  description = NULL;
  unknown = TRUE;

  if (self->priv->gfile != NULL)
    {
      name = g_file_get_basename (self->priv->gfile);
      extension = get_extension (name);
    }

  if (self->priv->content_type)
    {
      description = g_content_type_get_description (self->priv->content_type);
      unknown = g_content_type_is_unknown (self->priv->content_type);
    }

  if (name != NULL)
    {
      title = g_strdup (_("Select Application"));
      /* Translators: %s is a filename */
      subtitle = g_strdup_printf (_("Opening “%s”."), name);
      string = g_strdup_printf (_("No applications found for “%s”"), name);
    }
  else
    {
      title = g_strdup (_("Select Application"));
      /* Translators: %s is a file type description */
      subtitle = g_strdup_printf (_("Opening “%s” files."), 
                                  unknown ? self->priv->content_type : description);
      string = g_strdup_printf (_("No applications found for “%s” files"),
                                unknown ? self->priv->content_type : description);
    }

  g_object_get (self, "use-header-bar", &use_header, NULL); 
  if (use_header)
    {
      header = gtk_dialog_get_header_bar (GTK_DIALOG (self));
      gtk_header_bar_set_title (GTK_HEADER_BAR (header), title);
      gtk_header_bar_set_subtitle (GTK_HEADER_BAR (header), subtitle);
    }
  else
    {
      gtk_window_set_title (GTK_WINDOW (self), _("Select Application"));
    }

  if (self->priv->heading != NULL)
    {
      gtk_label_set_markup (GTK_LABEL (self->priv->label), self->priv->heading);
      gtk_widget_show (self->priv->label);
    }
  else
    {
      gtk_widget_hide (self->priv->label);
    }

  gtk_app_chooser_widget_set_default_text (GTK_APP_CHOOSER_WIDGET (self->priv->app_chooser_widget),
                                           string);

  g_free (title);
  g_free (subtitle);
  g_free (name);
  g_free (extension);
  g_free (description);
  g_free (string);
}
Esempio n. 16
0
static void
set_dialog_properties (GtkAppChooserDialog *self)
{
  gchar *label;
  gchar *name;
  gchar *extension;
  gchar *description;
  gchar *default_text;
  gchar *string;
  gboolean unknown;
  PangoFontDescription *font_desc;

  name = NULL;
  extension = NULL;
  label = NULL;
  description = NULL;
  unknown = TRUE;

  if (self->priv->gfile != NULL)
    {
      name = g_file_get_basename (self->priv->gfile);
      extension = get_extension (name);
    }

  if (self->priv->content_type)
    {
      description = g_content_type_get_description (self->priv->content_type);
      unknown = g_content_type_is_unknown (self->priv->content_type);
    }

  gtk_window_set_title (GTK_WINDOW (self), "");

  if (name != NULL)
    {
      /* Translators: %s is a filename */
      label = g_strdup_printf (_("Select an application to open \"%s\""), name);
      string = g_strdup_printf (_("No applications available to open \"%s\""),
                                name);
    }
  else
    {
      /* Translators: %s is a file type description */
      label = g_strdup_printf (_("Select an application for \"%s\" files"),
                               unknown ? self->priv->content_type : description);
      string = g_strdup_printf (_("No applications available to open \"%s\" files"),
                               unknown ? self->priv->content_type : description);
    }

  font_desc = pango_font_description_new ();
  pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
  gtk_widget_override_font (self->priv->label, font_desc);
  pango_font_description_free (font_desc);

  if (self->priv->heading != NULL)
    gtk_label_set_markup (GTK_LABEL (self->priv->label), self->priv->heading);
  else
    gtk_label_set_markup (GTK_LABEL (self->priv->label), label);

  default_text = g_strdup_printf ("<big><b>%s</b></big>\n%s",
                                  string,
                                  _("Click \"Show other applications\", for more options, or "
                                    "\"Find applications online\" to install a new application"));

  gtk_app_chooser_widget_set_default_text (GTK_APP_CHOOSER_WIDGET (self->priv->app_chooser_widget),
                                           default_text);

  g_free (label);
  g_free (name);
  g_free (extension);
  g_free (description);
  g_free (string);
  g_free (default_text);
}
static void
nautilus_mime_application_chooser_build_ui (NautilusMimeApplicationChooser *chooser)
{
	GtkWidget *box, *button;
	GAppInfo *info;

	gtk_container_set_border_width (GTK_CONTAINER (chooser), 8);
	gtk_box_set_spacing (GTK_BOX (chooser), 0);
	gtk_box_set_homogeneous (GTK_BOX (chooser), FALSE);

	chooser->details->label = gtk_label_new ("");
        gtk_label_set_xalign (GTK_LABEL (chooser->details->label), 0);
	gtk_label_set_line_wrap (GTK_LABEL (chooser->details->label), TRUE);
	gtk_label_set_line_wrap_mode (GTK_LABEL (chooser->details->label),
				      PANGO_WRAP_WORD_CHAR);
	gtk_box_pack_start (GTK_BOX (chooser), chooser->details->label, 
			    FALSE, FALSE, 0);

	gtk_widget_show (chooser->details->label);

	chooser->details->open_with_widget = gtk_app_chooser_widget_new (chooser->details->content_type);
	gtk_app_chooser_widget_set_show_default (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget),
						 TRUE);
	gtk_app_chooser_widget_set_show_fallback (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget),
						  TRUE);
	gtk_app_chooser_widget_set_show_other (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget),
					       TRUE);
	gtk_box_pack_start (GTK_BOX (chooser), chooser->details->open_with_widget,
			    TRUE, TRUE, 6);
	gtk_widget_show (chooser->details->open_with_widget);

	box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_box_set_spacing (GTK_BOX (box), 6);
	gtk_button_box_set_layout (GTK_BUTTON_BOX (box), GTK_BUTTONBOX_END);
	gtk_box_pack_start (GTK_BOX (chooser), box, FALSE, FALSE, 6);
	gtk_widget_show (box);

	button = gtk_button_new_with_label (_("Reset"));
	g_signal_connect (button, "clicked", 
			  G_CALLBACK (reset_clicked_cb),
			  chooser);
	gtk_widget_show (button);
	gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
	gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (box), button, TRUE);

	button = gtk_button_new_with_mnemonic (_("_Add"));
	g_signal_connect (button, "clicked", 
			  G_CALLBACK (add_clicked_cb),
			  chooser);
	gtk_widget_show (button);
	gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
	chooser->details->add_button = button;

	button = gtk_button_new_with_label (_("Set as default"));
	g_signal_connect (button, "clicked",
			  G_CALLBACK (set_as_default_clicked_cb),
			  chooser);
	gtk_widget_show (button);
	gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);

	chooser->details->set_as_default_button = button;

	/* initialize sensitivity */
	info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (chooser->details->open_with_widget));
	if (info != NULL) {
		application_selected_cb (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget),
					 info, chooser);
		g_object_unref (info);
	}

	g_signal_connect (chooser->details->open_with_widget,
			  "application-selected",
			  G_CALLBACK (application_selected_cb),
			  chooser);
	g_signal_connect (chooser->details->open_with_widget,
			  "populate-popup",
			  G_CALLBACK (populate_popup_cb),
			  chooser);
}
static void
nemo_mime_application_chooser_build_ui (NemoMimeApplicationChooser *chooser)
{
    GtkWidget *box, *button;
    GAppInfo *info;

    gtk_container_set_border_width (GTK_CONTAINER (chooser), 8);
    gtk_box_set_spacing (GTK_BOX (chooser), 0);
    gtk_box_set_homogeneous (GTK_BOX (chooser), FALSE);

    chooser->details->label = gtk_label_new ("");
    gtk_misc_set_alignment (GTK_MISC (chooser->details->label), 0.0, 0.5);
    gtk_label_set_line_wrap (GTK_LABEL (chooser->details->label), TRUE);
    gtk_label_set_line_wrap_mode (GTK_LABEL (chooser->details->label),
                                  PANGO_WRAP_WORD_CHAR);
    gtk_box_pack_start (GTK_BOX (chooser), chooser->details->label,
                        FALSE, FALSE, 0);

    gtk_widget_show (chooser->details->label);

    chooser->details->open_with_widget = gtk_app_chooser_widget_new (chooser->details->content_type);
    gtk_app_chooser_widget_set_show_default (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget),
            TRUE);
    gtk_app_chooser_widget_set_show_fallback (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget),
            TRUE);
    gtk_box_pack_start (GTK_BOX (chooser), chooser->details->open_with_widget,
                        TRUE, TRUE, 6);
    gtk_widget_show (chooser->details->open_with_widget);

    g_signal_connect (chooser->details->open_with_widget, "application-selected",
                      G_CALLBACK (application_selected_cb),
                      chooser);
    g_signal_connect (chooser->details->open_with_widget, "populate-popup",
                      G_CALLBACK (populate_popup_cb),
                      chooser);

    gtk_app_chooser_widget_set_show_other (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget),
                                           TRUE);
    gtk_app_chooser_widget_set_show_recommended (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget),
            TRUE);

    GtkWidget *custom_label = gtk_label_new (_("You can also type or select a custom executable file to use to open this file type.  "
                              "You can use this command just once, or set it as default for all files of this type."));
    gtk_misc_set_alignment (GTK_MISC (custom_label), 0.0, 0.5);
    gtk_label_set_line_wrap (GTK_LABEL (custom_label), TRUE);
    gtk_label_set_line_wrap_mode (GTK_LABEL (custom_label),
                                  PANGO_WRAP_WORD_CHAR);
    gtk_box_pack_start (GTK_BOX (chooser), custom_label, FALSE, FALSE, 0);
    gtk_widget_show (GTK_WIDGET (custom_label));

    GtkWidget *custom_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start (GTK_BOX (chooser), custom_box, TRUE, TRUE, 0);

    GtkWidget *entry = gtk_entry_new ();
    gtk_box_pack_start (GTK_BOX (custom_box), entry, TRUE, TRUE, 0);
    gtk_entry_set_placeholder_text (GTK_ENTRY (entry), _("Enter a custom command..."));

    g_signal_connect (entry, "changed",
                      G_CALLBACK (custom_entry_changed_cb),
                      chooser);

    chooser->details->custom_entry = entry;

    button = gtk_file_chooser_button_new (_("Custom application"), GTK_FILE_CHOOSER_ACTION_OPEN);
    g_signal_connect (button, "file-set",
                      G_CALLBACK (custom_app_set_cb),
                      chooser);
    gtk_widget_show (button);
    gtk_box_pack_start (GTK_BOX (custom_box), button, FALSE, FALSE, 6);

    gtk_widget_show_all (custom_box);

    chooser->details->custom_picker = button;

    box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
    gtk_box_set_spacing (GTK_BOX (box), 6);
    gtk_button_box_set_layout (GTK_BUTTON_BOX (box), GTK_BUTTONBOX_CENTER);
    gtk_box_pack_start (GTK_BOX (chooser), box, FALSE, FALSE, 6);
    gtk_widget_show (box);

    GtkFileFilter *filter = gtk_file_filter_new ();
    gtk_file_filter_add_mime_type (filter, "application/*");
    gtk_file_filter_set_name (filter, _("Executables"));
    gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (button), filter);

    button = gtk_button_new_with_label (_("Add to list"));
    g_signal_connect (button, "clicked",
                      G_CALLBACK (add_clicked_cb),
                      chooser);
    gtk_widget_show (button);
    gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
    chooser->details->add_button = button;

    button = gtk_button_new_with_label (_("Set as default"));
    g_signal_connect (button, "clicked",
                      G_CALLBACK (set_as_default_clicked_cb),
                      chooser);
    gtk_widget_show (button);
    gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);

    chooser->details->set_as_default_button = button;

    button = gtk_button_new_with_label (_("Reset to system defaults"));
    g_signal_connect (button, "clicked",
                      G_CALLBACK (reset_clicked_cb),
                      chooser);
    gtk_widget_show (button);
    gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);

    /* initialize sensitivity */
    info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (chooser->details->open_with_widget));
    if (info != NULL) {
        application_selected_cb (GTK_APP_CHOOSER_WIDGET (chooser->details->open_with_widget),
                                 info, chooser);
        g_object_unref (info);
    }
}
Esempio n. 19
0
GtkAppChooserWidget* cast_GtkAppChooserWidget(GtkWidget* widget) {
    return GTK_APP_CHOOSER_WIDGET(widget);
}