static void test_app_chooser_widget_basic (void) { GtkWidget *widget; widget = gtk_app_chooser_widget_new (NULL); g_assert (GTK_IS_APP_CHOOSER_WIDGET (widget)); gtk_widget_destroy (widget); }
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)); }
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); } }
static void build_dialog_ui (GtkAppChooserDialog *self) { GtkWidget *vbox; GtkWidget *vbox2; GtkWidget *label; GtkWidget *button, *w; gtk_container_set_border_width (GTK_CONTAINER (self), 5); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_box_pack_start (GTK_BOX (vbox), vbox2, TRUE, TRUE, 0); gtk_widget_show (vbox2); self->priv->label = gtk_label_new (""); gtk_misc_set_alignment (GTK_MISC (self->priv->label), 0, 0.5); gtk_label_set_line_wrap (GTK_LABEL (self->priv->label), TRUE); gtk_box_pack_start (GTK_BOX (vbox2), self->priv->label, FALSE, FALSE, 0); gtk_widget_show (self->priv->label); self->priv->app_chooser_widget = gtk_app_chooser_widget_new (self->priv->content_type); gtk_box_pack_start (GTK_BOX (vbox2), self->priv->app_chooser_widget, TRUE, TRUE, 0); gtk_widget_show (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); button = gtk_button_new_with_label (_("Show other applications")); self->priv->show_more_button = button; w = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (button), w); gtk_box_pack_start (GTK_BOX (self->priv->app_chooser_widget), button, FALSE, FALSE, 6); gtk_widget_show_all (button); g_signal_connect (button, "clicked", G_CALLBACK (show_more_button_clicked_cb), self); gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); /* Create a custom stock icon */ self->priv->button = gtk_button_new (); label = gtk_label_new_with_mnemonic (_("_Select")); gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (self->priv->button)); gtk_widget_set_halign (label, GTK_ALIGN_CENTER); gtk_widget_show (label); self->priv->open_label = label; gtk_container_add (GTK_CONTAINER (self->priv->button), self->priv->open_label); gtk_widget_show (self->priv->button); gtk_widget_set_can_default (self->priv->button, TRUE); gtk_dialog_add_action_widget (GTK_DIALOG (self), self->priv->button, GTK_RESPONSE_OK); gtk_dialog_set_default_response (GTK_DIALOG (self), GTK_RESPONSE_OK); }
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); }