From 862f151cc79bcf042b9e27a82de29c7527655609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20K=C3=BCmmerlin?= <rgcjonas@gmail.com> Date: Wed, 12 Aug 2015 17:56:16 +0200 Subject: [PATCH] uca: UI modernization Now making use of widget templates and proper height-for-width geometry. Header bars are used depending on the gtk setting, and deprecated functions have been removed (modulo GtkAction). --- .gitignore | 1 + plugins/thunar-uca/Makefile.am | 14 +- plugins/thunar-uca/thunar-uca-chooser.c | 159 ++--- plugins/thunar-uca/thunar-uca-chooser.ui | 134 ++++ plugins/thunar-uca/thunar-uca-editor.c | 410 ++---------- plugins/thunar-uca/thunar-uca-editor.ui | 683 ++++++++++++++++++++ plugins/thunar-uca/thunar-uca-model.c | 12 - plugins/thunar-uca/thunar-uca-provider.c | 10 +- plugins/thunar-uca/thunar-uca.gresource.xml | 7 + po/POTFILES.in | 2 + 10 files changed, 938 insertions(+), 494 deletions(-) create mode 100644 plugins/thunar-uca/thunar-uca-chooser.ui create mode 100644 plugins/thunar-uca/thunar-uca-editor.ui create mode 100644 plugins/thunar-uca/thunar-uca.gresource.xml diff --git a/.gitignore b/.gitignore index 6c7af6dbc..5f5c19bbb 100644 --- a/.gitignore +++ b/.gitignore @@ -87,6 +87,7 @@ plugins/thunar-tpa/.*.swp plugins/thunar-tpa/thunar-tpa plugins/thunar-uca/.*.swp plugins/thunar-uca/uca.xml +plugins/thunar-uca/thunar-uca.gresource.c po-doc/.*.swp po-doc/.xml2po.mo po/Makefile.in.in diff --git a/plugins/thunar-uca/Makefile.am b/plugins/thunar-uca/Makefile.am index 98be9aa3b..d0f3a0afd 100644 --- a/plugins/thunar-uca/Makefile.am +++ b/plugins/thunar-uca/Makefile.am @@ -26,7 +26,8 @@ thunar_uca_la_SOURCES = \ thunar-uca-private.c \ thunar-uca-private.h \ thunar-uca-provider.c \ - thunar-uca-provider.h + thunar-uca-provider.h \ + thunar-uca.gresource.c thunar_uca_la_CFLAGS = \ $(EXO_CFLAGS) \ @@ -51,6 +52,17 @@ thunar_uca_la_LIBADD = \ thunar_uca_la_DEPENDENCIES = \ $(top_builddir)/thunarx/libthunarx-$(THUNARX_VERSION_API).la +thunar_uca_templates = \ + thunar-uca-ui.xml + +GLIB_COMPILE_RESOURCES = $(shell $(PKG_CONFIG) --variable=glib_compile_resources gio-2.0) + +resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/thunar-uca.gresource.xml) + +thunar-uca.gresource.c: thunar-uca.gresource.xml $(resource_files) + $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< \ + --target=$@ --sourcedir=$(srcdir) --generate-source + defaultsdir = $(sysconfdir)/xdg/Thunar defaults_in_files = uca.xml.in defaults_DATA = $(defaults_in_files:.xml.in=.xml) diff --git a/plugins/thunar-uca/thunar-uca-chooser.c b/plugins/thunar-uca/thunar-uca-chooser.c index 0e16ae573..399f82b09 100644 --- a/plugins/thunar-uca/thunar-uca-chooser.c +++ b/plugins/thunar-uca/thunar-uca-chooser.c @@ -81,14 +81,32 @@ THUNARX_DEFINE_TYPE (ThunarUcaChooser, thunar_uca_chooser, GTK_TYPE_DIALOG); static void thunar_uca_chooser_class_init (ThunarUcaChooserClass *klass) { - GtkDialogClass *gtkdialog_class; - GtkWidgetClass *gtkwidget_class; - - gtkwidget_class = GTK_WIDGET_CLASS (klass); - gtkwidget_class->key_press_event = thunar_uca_chooser_key_press_event; - - gtkdialog_class = GTK_DIALOG_CLASS (klass); - gtkdialog_class->response = thunar_uca_chooser_response; + GtkDialogClass *dialog_class; + GtkWidgetClass *widget_class; + + widget_class = GTK_WIDGET_CLASS (klass); + widget_class->key_press_event = thunar_uca_chooser_key_press_event; + + dialog_class = GTK_DIALOG_CLASS (klass); + dialog_class->response = thunar_uca_chooser_response; + + /* Setup the template xml */ + gtk_widget_class_set_template_from_resource (widget_class, "/org/xfce/thunar/uca/chooser.ui"); + + /* bind stuff */ + gtk_widget_class_bind_template_child (widget_class, ThunarUcaChooser, treeview); + gtk_widget_class_bind_template_child (widget_class, ThunarUcaChooser, add_button); + gtk_widget_class_bind_template_child (widget_class, ThunarUcaChooser, edit_button); + gtk_widget_class_bind_template_child (widget_class, ThunarUcaChooser, delete_button); + gtk_widget_class_bind_template_child (widget_class, ThunarUcaChooser, up_button); + gtk_widget_class_bind_template_child (widget_class, ThunarUcaChooser, down_button); + + gtk_widget_class_bind_template_callback(widget_class, thunar_uca_chooser_add_clicked); + gtk_widget_class_bind_template_callback(widget_class, thunar_uca_chooser_edit_clicked); + gtk_widget_class_bind_template_callback(widget_class, thunar_uca_chooser_delete_clicked); + gtk_widget_class_bind_template_callback(widget_class, thunar_uca_chooser_up_clicked); + gtk_widget_class_bind_template_callback(widget_class, thunar_uca_chooser_down_clicked); + gtk_widget_class_bind_template_callback(widget_class, thunar_uca_chooser_selection_changed); } @@ -97,56 +115,26 @@ static void thunar_uca_chooser_init (ThunarUcaChooser *uca_chooser) { GtkTreeViewColumn *column; - GtkTreeSelection *selection; GtkCellRenderer *renderer; ThunarUcaModel *uca_model; - GtkWidget *image; - GtkWidget *label; - GtkWidget *hbox; - GtkWidget *swin; - GtkWidget *vbox; + GtkWidget *button; + gboolean have_header_bar; + + /* Initialize the template for this instance */ + gtk_widget_init_template (GTK_WIDGET (uca_chooser)); /* configure the dialog window */ - gtk_dialog_add_button (GTK_DIALOG (uca_chooser), _("_Help"), GTK_RESPONSE_HELP); - gtk_dialog_add_button (GTK_DIALOG (uca_chooser), _("_Close"), GTK_RESPONSE_CLOSE); + g_object_get (uca_chooser, "use-header-bar", &have_header_bar, NULL); + + if (!have_header_bar) + { + /* add a regular close button, the header bar already provides one */ + gtk_dialog_add_button (GTK_DIALOG (uca_chooser), _("_Close"), GTK_RESPONSE_CLOSE); + } + gtk_dialog_set_default_response (GTK_DIALOG (uca_chooser), GTK_RESPONSE_CLOSE); - gtk_window_set_default_size (GTK_WINDOW (uca_chooser), 500, 350); - gtk_window_set_destroy_with_parent (GTK_WINDOW (uca_chooser), TRUE); - gtk_window_set_title (GTK_WINDOW (uca_chooser), _("Custom Actions")); - - hbox = gtk_hbox_new (FALSE, 3); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); - gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (uca_chooser))), hbox, FALSE, TRUE, 0); - gtk_widget_show (hbox); - - image = gtk_image_new_from_icon_name ("dialog-information", GTK_ICON_SIZE_DND); - gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); - gtk_widget_show (image); - - label = gtk_label_new (_("You can configure custom actions that will appear in the\n" - "file managers context menus for certain kinds of files.")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.5f); - gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0); - gtk_widget_show (label); - - hbox = gtk_hbox_new (FALSE, 3); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); - gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (uca_chooser))), hbox, TRUE, TRUE, 0); - gtk_widget_show (hbox); - - swin = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swin), GTK_SHADOW_IN); - gtk_box_pack_start (GTK_BOX (hbox), swin, TRUE, TRUE, 0); - gtk_widget_show (swin); - - uca_chooser->treeview = gtk_tree_view_new (); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (uca_chooser->treeview), FALSE); - gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (uca_chooser->treeview), TRUE); - gtk_container_add (GTK_CONTAINER (swin), uca_chooser->treeview); - g_signal_connect_swapped (G_OBJECT (uca_chooser->treeview), "row-activated", G_CALLBACK (thunar_uca_chooser_edit_clicked), uca_chooser); - gtk_widget_show (uca_chooser->treeview); + /* configure the tree view */ uca_model = thunar_uca_model_get_default (); gtk_tree_view_set_model (GTK_TREE_VIEW (uca_chooser->treeview), GTK_TREE_MODEL (uca_model)); g_object_unref (G_OBJECT (uca_model)); @@ -164,65 +152,8 @@ thunar_uca_chooser_init (ThunarUcaChooser *uca_chooser) gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_attributes (column, renderer, "markup", THUNAR_UCA_MODEL_COLUMN_STOCK_LABEL, NULL); - vbox = gtk_vbox_new (FALSE, 3); - gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); - gtk_widget_show (vbox); - - uca_chooser->add_button = gtk_button_new (); - gtk_widget_set_tooltip_text (uca_chooser->add_button, _("Add a new custom action.")); - gtk_box_pack_start (GTK_BOX (vbox), uca_chooser->add_button, FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (uca_chooser->add_button), "clicked", G_CALLBACK (thunar_uca_chooser_add_clicked), uca_chooser); - gtk_widget_show (uca_chooser->add_button); - - image = gtk_image_new_from_icon_name ("list-add-symbolic", GTK_ICON_SIZE_BUTTON); - gtk_container_add (GTK_CONTAINER (uca_chooser->add_button), image); - gtk_widget_show (image); - - uca_chooser->edit_button = gtk_button_new (); - gtk_widget_set_tooltip_text (uca_chooser->edit_button, _("Edit the currently selected action.")); - gtk_box_pack_start (GTK_BOX (vbox), uca_chooser->edit_button, FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (uca_chooser->edit_button), "clicked", G_CALLBACK (thunar_uca_chooser_edit_clicked), uca_chooser); - gtk_widget_show (uca_chooser->edit_button); - - image = gtk_image_new_from_icon_name ("emblem-system-symbolic", GTK_ICON_SIZE_BUTTON); - gtk_container_add (GTK_CONTAINER (uca_chooser->edit_button), image); - gtk_widget_show (image); - - uca_chooser->delete_button = gtk_button_new (); - gtk_widget_set_tooltip_text (uca_chooser->delete_button, _("Delete the currently selected action.")); - gtk_box_pack_start (GTK_BOX (vbox), uca_chooser->delete_button, FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (uca_chooser->delete_button), "clicked", G_CALLBACK (thunar_uca_chooser_delete_clicked), uca_chooser); - gtk_widget_show (uca_chooser->delete_button); - - image = gtk_image_new_from_icon_name ("list-remove-symbolic", GTK_ICON_SIZE_BUTTON); - gtk_container_add (GTK_CONTAINER (uca_chooser->delete_button), image); - gtk_widget_show (image); - - uca_chooser->up_button = gtk_button_new (); - gtk_widget_set_tooltip_text (uca_chooser->up_button, _("Move the currently selected action up by one row.")); - gtk_box_pack_start (GTK_BOX (vbox), uca_chooser->up_button, FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (uca_chooser->up_button), "clicked", G_CALLBACK (thunar_uca_chooser_up_clicked), uca_chooser); - gtk_widget_show (uca_chooser->up_button); - - image = gtk_image_new_from_icon_name ("go-up-symbolic", GTK_ICON_SIZE_BUTTON); - gtk_container_add (GTK_CONTAINER (uca_chooser->up_button), image); - gtk_widget_show (image); - - uca_chooser->down_button = gtk_button_new (); - gtk_widget_set_tooltip_text (uca_chooser->down_button, _("Move the currently selected action down by one row.")); - gtk_box_pack_start (GTK_BOX (vbox), uca_chooser->down_button, FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (uca_chooser->down_button), "clicked", G_CALLBACK (thunar_uca_chooser_down_clicked), uca_chooser); - gtk_widget_show (uca_chooser->down_button); - - image = gtk_image_new_from_icon_name ("go-down-symbolic", GTK_ICON_SIZE_BUTTON); - gtk_container_add (GTK_CONTAINER (uca_chooser->down_button), image); - gtk_widget_show (image); - - /* configure the tree view selection after the buttons have been created */ - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (uca_chooser->treeview)); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - g_signal_connect_swapped (G_OBJECT (selection), "changed", G_CALLBACK (thunar_uca_chooser_selection_changed), uca_chooser); - thunar_uca_chooser_selection_changed (uca_chooser, selection); + /* configure the tree view selection */ + thunar_uca_chooser_selection_changed (uca_chooser, gtk_tree_view_get_selection (GTK_TREE_VIEW (uca_chooser->treeview))); } @@ -327,11 +258,15 @@ thunar_uca_chooser_open_editor (ThunarUcaChooser *uca_chooser, GtkTreeModel *model; GtkTreeIter iter; GtkWidget *editor; + gboolean use_header_bar = FALSE; g_return_if_fail (THUNAR_UCA_IS_CHOOSER (uca_chooser)); /* allocate the new editor */ - editor = g_object_new (THUNAR_UCA_TYPE_EDITOR, NULL); + g_object_get (gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (uca_chooser))), + "gtk-dialogs-use-header", &use_header_bar, NULL); + + editor = g_object_new (THUNAR_UCA_TYPE_EDITOR, "use-header-bar", use_header_bar, NULL); gtk_window_set_title (GTK_WINDOW (editor), edit ? _("Edit Action") : _("Create Action")); gtk_window_set_transient_for (GTK_WINDOW (editor), GTK_WINDOW (uca_chooser)); diff --git a/plugins/thunar-uca/thunar-uca-chooser.ui b/plugins/thunar-uca/thunar-uca-chooser.ui new file mode 100644 index 000000000..7c96b7ac1 --- /dev/null +++ b/plugins/thunar-uca/thunar-uca-chooser.ui @@ -0,0 +1,134 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + For now, better don't edit this with glade, since glade insists upon inserting + deprecated properties and otherwise messing with the file. +--> +<interface> + <requires lib="gtk+" version="3.12"/> + <template class="ThunarUcaChooser" parent="GtkDialog"> + <property name="default-width">500</property> + <property name="default-height">350</property> + <property name="type-hint">dialog</property> + <property name="title" translatable="yes">Custom Actions</property> + <property name="destroy-with-parent">True</property> + <child internal-child="vbox"> + <object class="GtkBox" id="vbox"> + <!-- label at the top --> + <child> + <object class="GtkBox"> + <property name="border-width">6</property> + <property name="spacing">3</property> + <property name="visible">TRUE</property> + <child> + <object class="GtkImage"> + <property name="icon-name">dialog-information</property> + <property name="icon-size">5</property> + <property name="visible">TRUE</property> + </object> + </child> + <child> + <object class="GtkLabel"> + <property name="label" translatable="yes">You can configure custom actions that will appear in the file managers context menus for certain kinds of files.</property> + <property name="xalign">0.0</property> + <property name="yalign">0.5</property> + <property name="visible">TRUE</property> + <property name="wrap">TRUE</property> + </object> + </child> + </object> + </child> + <!-- main part --> + <child> + <object class="GtkFrame"> + <property name="border-width">6</property> + <property name="visible">true</property> + <child> + <object class="GtkBox"> + <property name="spacing">0</property> + <property name="visible">TRUE</property> + <property name="hexpand">TRUE</property> + <property name="vexpand">TRUE</property> + <!-- tree view containing the list of items --> + <child> + <object class="GtkScrolledWindow"> + <property name="visible">TRUE</property> + <property name="expand">TRUE</property> + <child> + <object class="GtkTreeView" id="treeview"> + <property name="headers-visible">FALSE</property> + <property name="visible">TRUE</property> + <signal name="row-activated" handler="thunar_uca_chooser_edit_clicked" swapped="true" /> + <!-- TODO: setup columns here --> + <child internal-child="selection"> + <object class="GtkTreeSelection"> + <property name="mode">GTK_SELECTION_SINGLE</property> + <signal name="changed" handler="thunar_uca_chooser_selection_changed" swapped="true" /> + </object> + </child> + </object> + </child> + </object> + </child> + <!-- buttons --> + <child> + <object class="GtkToolbar"> + <property name="orientation">GTK_ORIENTATION_VERTICAL</property> + <property name="visible">TRUE</property> + <property name="toolbar-style">GTK_TOOLBAR_ICONS</property> + <property name="icon-size">GTK_ICON_SIZE_BUTTON</property> + <property name="show-arrow">false</property> + <!-- add button --> + <child> + <object class="GtkToolButton" id="add_button"> + <property name="tooltip-text" translatable="yes">Add a new custom action.</property> + <property name="visible">TRUE</property> + <property name="icon-name">list-add-symbolic</property> + <signal name="clicked" handler="thunar_uca_chooser_add_clicked" swapped="true" /> + </object> + </child> + <!-- edit button --> + <child> + <object class="GtkToolButton" id="edit_button"> + <property name="tooltip-text" translatable="yes">Edit the currently selected action.</property> + <property name="visible">TRUE</property> + <property name="icon-name">emblem-system-symbolic</property> + <signal name="clicked" handler="thunar_uca_chooser_edit_clicked" swapped="true" /> + </object> + </child> + <!-- remove button --> + <child> + <object class="GtkToolButton" id="delete_button"> + <property name="tooltip-text" translatable="yes">Delete the currently selected action.</property> + <property name="visible">TRUE</property> + <property name="icon-name">list-remove-symbolic</property> + <signal name="clicked" handler="thunar_uca_chooser_delete_clicked" swapped="true" /> + </object> + </child> + <!-- move up button --> + <child> + <object class="GtkToolButton" id="up_button"> + <property name="tooltip-text" translatable="yes">Move the currently selected action up by one row.</property> + <property name="visible">TRUE</property> + <property name="icon-name">go-up-symbolic</property> + <signal name="clicked" handler="thunar_uca_chooser_up_clicked" swapped="true" /> + </object> + </child> + <!-- move down button --> + <child> + <object class="GtkToolButton" id="down_button"> + <property name="tooltip-text" translatable="yes">Move the currently selected action down by one row.</property> + <property name="visible">TRUE</property> + <property name="icon-name">go-down-symbolic</property> + <signal name="clicked" handler="thunar_uca_chooser_down_clicked" swapped="true" /> + </object> + </child> + </object> + </child> <!-- end: buttons toolbar --> + </object> + </child> <!-- end of main part hbox --> + </object> + </child> <!-- end of main part frame --> + </object> + </child> + </template> +</interface> diff --git a/plugins/thunar-uca/thunar-uca-editor.c b/plugins/thunar-uca/thunar-uca-editor.c index 2ca7ead06..13717c0b3 100644 --- a/plugins/thunar-uca/thunar-uca-editor.c +++ b/plugins/thunar-uca/thunar-uca-editor.c @@ -44,6 +44,7 @@ static void thunar_uca_editor_set_types (ThunarUcaEditor ThunarUcaTypes types); static void thunar_uca_editor_command_clicked (ThunarUcaEditor *uca_editor); static void thunar_uca_editor_icon_clicked (ThunarUcaEditor *uca_editor); +static void thunar_uca_editor_constructed (GObject *object); @@ -56,12 +57,12 @@ struct _ThunarUcaEditor { GtkDialog __parent__; + GtkWidget *notebook; GtkWidget *name_entry; GtkWidget *description_entry; GtkWidget *icon_button; GtkWidget *command_entry; GtkWidget *sn_button; - GtkWidget *parameter_entry; GtkWidget *patterns_entry; GtkWidget *directories_button; GtkWidget *audio_files_button; @@ -80,6 +81,32 @@ THUNARX_DEFINE_TYPE (ThunarUcaEditor, thunar_uca_editor, GTK_TYPE_DIALOG); static void thunar_uca_editor_class_init (ThunarUcaEditorClass *klass) { + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + /* vfuncs */ + object_class->constructed = thunar_uca_editor_constructed; + + /* Setup the template xml */ + gtk_widget_class_set_template_from_resource (widget_class, "/org/xfce/thunar/uca/editor.ui"); + + /* bind stuff */ + gtk_widget_class_bind_template_child (widget_class, ThunarUcaEditor, notebook); + gtk_widget_class_bind_template_child (widget_class, ThunarUcaEditor, name_entry); + gtk_widget_class_bind_template_child (widget_class, ThunarUcaEditor, description_entry); + gtk_widget_class_bind_template_child (widget_class, ThunarUcaEditor, icon_button); + gtk_widget_class_bind_template_child (widget_class, ThunarUcaEditor, command_entry); + gtk_widget_class_bind_template_child (widget_class, ThunarUcaEditor, sn_button); + gtk_widget_class_bind_template_child (widget_class, ThunarUcaEditor, patterns_entry); + gtk_widget_class_bind_template_child (widget_class, ThunarUcaEditor, directories_button); + gtk_widget_class_bind_template_child (widget_class, ThunarUcaEditor, audio_files_button); + gtk_widget_class_bind_template_child (widget_class, ThunarUcaEditor, image_files_button); + gtk_widget_class_bind_template_child (widget_class, ThunarUcaEditor, text_files_button); + gtk_widget_class_bind_template_child (widget_class, ThunarUcaEditor, video_files_button); + gtk_widget_class_bind_template_child (widget_class, ThunarUcaEditor, other_files_button); + + gtk_widget_class_bind_template_callback(widget_class, thunar_uca_editor_icon_clicked); + gtk_widget_class_bind_template_callback(widget_class, thunar_uca_editor_command_clicked); } @@ -87,373 +114,27 @@ thunar_uca_editor_class_init (ThunarUcaEditorClass *klass) static void thunar_uca_editor_init (ThunarUcaEditor *uca_editor) { - AtkRelationSet *relations; - PangoAttribute *attribute; - PangoAttrList *attrs_small_bold; - PangoAttrList *attrs_small; - AtkRelation *relation; - AtkObject *object; - GtkWidget *notebook; - GtkWidget *button; - GtkWidget *itable; - GtkWidget *align; - GtkWidget *image; - GtkWidget *label; - GtkWidget *table; - GtkWidget *hbox; - GtkWidget *vbox; + /* Initialize the template for this instance */ + gtk_widget_init_template (GTK_WIDGET (uca_editor)); /* configure the dialog properties */ gtk_dialog_add_button (GTK_DIALOG (uca_editor), _("_Cancel"), GTK_RESPONSE_CANCEL); gtk_dialog_add_button (GTK_DIALOG (uca_editor), _("_OK"), GTK_RESPONSE_OK); - gtk_dialog_set_alternative_button_order (GTK_DIALOG (uca_editor), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); gtk_dialog_set_default_response (GTK_DIALOG (uca_editor), GTK_RESPONSE_OK); - gtk_window_set_destroy_with_parent (GTK_WINDOW (uca_editor), TRUE); - gtk_window_set_resizable (GTK_WINDOW (uca_editor), FALSE); - - notebook = gtk_notebook_new (); - gtk_container_set_border_width (GTK_CONTAINER (notebook), 6); - gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (uca_editor))), notebook, TRUE, TRUE, 0); - gtk_widget_show (notebook); - - /* - Basic - */ - label = gtk_label_new (_("Basic")); - table = gtk_table_new (7, 2, FALSE); - gtk_table_set_col_spacings (GTK_TABLE (table), 12); - gtk_table_set_row_spacings (GTK_TABLE (table), 6); - gtk_container_set_border_width (GTK_CONTAINER (table), 12); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), table, label); - gtk_widget_show (label); - gtk_widget_show (table); - - label = g_object_new (GTK_TYPE_LABEL, "label", _("_Name:"), "use-underline", TRUE, "xalign", 0.0f, NULL); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - uca_editor->name_entry = g_object_new (GTK_TYPE_ENTRY, "activates-default", TRUE, NULL); - gtk_widget_set_tooltip_text (uca_editor->name_entry, _("The name of the action that will be displayed in the context menu.")); - gtk_table_attach (GTK_TABLE (table), uca_editor->name_entry, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), uca_editor->name_entry); - gtk_widget_grab_focus (uca_editor->name_entry); - gtk_widget_show (uca_editor->name_entry); - - /* set Atk label relation for the entry */ - object = gtk_widget_get_accessible (uca_editor->name_entry); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); - - label = g_object_new (GTK_TYPE_LABEL, "label", _("_Description:"), "use-underline", TRUE, "xalign", 0.0f, NULL); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - uca_editor->description_entry = g_object_new (GTK_TYPE_ENTRY, "activates-default", TRUE, NULL); - gtk_widget_set_tooltip_text (uca_editor->description_entry, _("The description of the action that will be displayed as tooltip " - "in the statusbar when selecting the item from the context menu.")); - gtk_table_attach (GTK_TABLE (table), uca_editor->description_entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), uca_editor->description_entry); - gtk_widget_show (uca_editor->description_entry); - - /* set Atk label relation for the entry */ - object = gtk_widget_get_accessible (uca_editor->description_entry); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); - - label = g_object_new (GTK_TYPE_LABEL, "label", _("_Command:"), "use-underline", TRUE, "xalign", 0.0f, NULL); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - hbox = gtk_hbox_new (FALSE, 2); - gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (hbox); - - uca_editor->command_entry = g_object_new (GTK_TYPE_ENTRY, "activates-default", TRUE, NULL); - gtk_widget_set_tooltip_text (uca_editor->command_entry, _("The command (including the necessary parameters) to perform the action. " - "See the command parameter legend below for a list of supported parameter " - "variables, which will be substituted when launching the command. When " - "upper-case letters (e.g. %F, %D, %N) are used, the action will be applicable " - "even if more than one item is selected. Else the action will only be " - "applicable if exactly one item is selected.")); - gtk_box_pack_start (GTK_BOX (hbox), uca_editor->command_entry, TRUE, TRUE, 0); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), uca_editor->command_entry); - gtk_widget_show (uca_editor->command_entry); - - button = gtk_button_new (); - gtk_widget_set_tooltip_text (button, _("Browse the file system to select an application to use for this action.")); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - g_signal_connect_swapped (G_OBJECT (button), "clicked", G_CALLBACK (thunar_uca_editor_command_clicked), uca_editor); - gtk_widget_show (button); - - image = gtk_image_new_from_icon_name ("document-open", GTK_ICON_SIZE_BUTTON); - gtk_container_add (GTK_CONTAINER (button), image); - gtk_widget_show (image); - - /* set Atk label relation for the entry */ - object = gtk_widget_get_accessible (uca_editor->command_entry); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); - - uca_editor->sn_button = gtk_check_button_new_with_label (_("Use Startup Notification")); - gtk_widget_set_tooltip_text (uca_editor->sn_button, _("Enable this option if you want a waiting cursor to be shown while the " - "action is launched. This is also highly recommended if you have focus " - "stealing prevention enabled in your window manager.")); - gtk_table_attach (GTK_TABLE (table), uca_editor->sn_button, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (uca_editor->sn_button); - - label = g_object_new (GTK_TYPE_LABEL, "label", _("_Icon:"), "use-underline", TRUE, "xalign", 0.0f, NULL); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - align = gtk_alignment_new (0.0f, 0.5f, 0.0f, 0.0f); - gtk_table_attach (GTK_TABLE (table), align, 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (align); - - uca_editor->icon_button = gtk_button_new_with_label (_("No icon")); - gtk_widget_set_tooltip_text (uca_editor->icon_button, _("Click this button to select an icon file that will be displayed " - "in the context menu in addition to the action name chosen above.")); - gtk_container_add (GTK_CONTAINER (align), uca_editor->icon_button); - g_signal_connect_swapped (G_OBJECT (uca_editor->icon_button), "clicked", G_CALLBACK (thunar_uca_editor_icon_clicked), uca_editor); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), uca_editor->icon_button); - gtk_widget_show (uca_editor->icon_button); - - /* set Atk label relation for the button */ - object = gtk_widget_get_accessible (uca_editor->icon_button); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); - - align = g_object_new (GTK_TYPE_ALIGNMENT, "height-request", 12, NULL); - gtk_table_attach (GTK_TABLE (table), align, 0, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (align); - - hbox = gtk_hbox_new (FALSE, 6); - gtk_table_attach (GTK_TABLE (table), hbox, 0, 2, 6, 7, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (hbox); - - image = gtk_image_new_from_icon_name ("dialog-information", GTK_ICON_SIZE_DND); - gtk_misc_set_alignment (GTK_MISC (image), 0.5f, 0.0f); - gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); - gtk_widget_show (image); - - vbox = gtk_vbox_new (FALSE, 6); - gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); - gtk_widget_show (vbox); - - label = gtk_label_new (_("The following command parameters will be\n" - "substituted when launching the action:")); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.0f); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - table = gtk_table_new (2, 2, FALSE); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); - gtk_table_set_row_spacings (GTK_TABLE (table), 3); - gtk_container_set_border_width (GTK_CONTAINER (table), 6); - gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0); - gtk_widget_show (table); - - /* setup the small+bold attribute list */ - attrs_small_bold = pango_attr_list_new (); - attribute = pango_attr_weight_new (PANGO_WEIGHT_BOLD); - attribute->start_index = 0; - attribute->end_index = -1; - pango_attr_list_insert (attrs_small_bold, attribute); - attribute = pango_attr_scale_new (PANGO_SCALE_SMALL); - attribute->start_index = 0; - attribute->end_index = -1; - pango_attr_list_insert (attrs_small_bold, attribute); - - /* setup the small attribute list */ - attrs_small = pango_attr_list_new (); - attribute = pango_attr_scale_new (PANGO_SCALE_SMALL); - attribute->start_index = 0; - attribute->end_index = -1; - pango_attr_list_insert (attrs_small, attribute); - - label = gtk_label_new ("%f"); - gtk_label_set_attributes (GTK_LABEL (label), attrs_small_bold); - gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.0f); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - label = gtk_label_new (_("the path to the first selected file")); - gtk_label_set_attributes (GTK_LABEL (label), attrs_small); - gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.0f); - gtk_table_attach (GTK_TABLE (table), label, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - label = gtk_label_new ("%F"); - gtk_label_set_attributes (GTK_LABEL (label), attrs_small_bold); - gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.0f); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - label = gtk_label_new (_("the paths to all selected files")); - gtk_label_set_attributes (GTK_LABEL (label), attrs_small); - gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.0f); - gtk_table_attach (GTK_TABLE (table), label, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - label = gtk_label_new ("%d"); - gtk_label_set_attributes (GTK_LABEL (label), attrs_small_bold); - gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.0f); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - label = gtk_label_new (_("directory containing the file that is passed in %f")); - gtk_label_set_attributes (GTK_LABEL (label), attrs_small); - gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.0f); - gtk_table_attach (GTK_TABLE (table), label, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - label = gtk_label_new ("%D"); - gtk_label_set_attributes (GTK_LABEL (label), attrs_small_bold); - gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.0f); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - label = gtk_label_new (_("directories containing the files that are passed in %F")); - gtk_label_set_attributes (GTK_LABEL (label), attrs_small); - gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.0f); - gtk_table_attach (GTK_TABLE (table), label, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - label = gtk_label_new ("%n"); - gtk_label_set_attributes (GTK_LABEL (label), attrs_small_bold); - gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.0f); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - label = gtk_label_new (_("the first selected filename (without path)")); - gtk_label_set_attributes (GTK_LABEL (label), attrs_small); - gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.0f); - gtk_table_attach (GTK_TABLE (table), label, 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - label = gtk_label_new ("%N"); - gtk_label_set_attributes (GTK_LABEL (label), attrs_small_bold); - gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.0f); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 5, 6, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - label = gtk_label_new (_("the selected filenames (without paths)")); - gtk_label_set_attributes (GTK_LABEL (label), attrs_small); - gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.0f); - gtk_table_attach (GTK_TABLE (table), label, 1, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - /* release the pango attribute lists */ - pango_attr_list_unref (attrs_small_bold); - pango_attr_list_unref (attrs_small); - - /* - Appearance Conditions - */ - table = gtk_table_new (3, 2, FALSE); - label = gtk_label_new (_("Appearance Conditions")); - gtk_table_set_col_spacings (GTK_TABLE (table), 12); - gtk_table_set_row_spacings (GTK_TABLE (table), 6); - gtk_container_set_border_width (GTK_CONTAINER (table), 12); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), table, label); - gtk_widget_show (label); - gtk_widget_show (table); - - label = g_object_new (GTK_TYPE_LABEL, "label", _("_File Pattern:"), "use-underline", TRUE, "xalign", 0.0f, NULL); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - uca_editor->patterns_entry = g_object_new (GTK_TYPE_ENTRY, "activates-default", TRUE, "text", "*", NULL); - gtk_widget_set_tooltip_text (uca_editor->patterns_entry, _("Enter a list of patterns that will be used to determine " - "whether this action should be displayed for a selected " - "file. If you specify more than one pattern here, the list " - "items must be separated with semicolons (e.g. *.txt;*.doc).")); - gtk_table_attach (GTK_TABLE (table), uca_editor->patterns_entry, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), uca_editor->patterns_entry); - gtk_widget_show (uca_editor->patterns_entry); - - /* set Atk label relation for the entry */ - object = gtk_widget_get_accessible (uca_editor->patterns_entry); - relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label)); - relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR); - atk_relation_set_add (relations, relation); - g_object_unref (G_OBJECT (relation)); - - align = g_object_new (GTK_TYPE_ALIGNMENT, "height-request", 0, NULL); - gtk_table_attach (GTK_TABLE (table), align, 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (align); - - label = g_object_new (GTK_TYPE_LABEL, "label", _("Appears if selection contains:"), "xalign", 0.0f, NULL); - gtk_table_attach (GTK_TABLE (table), label, 0, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - align = g_object_new (GTK_TYPE_ALIGNMENT, "left-padding", 18, NULL); - gtk_table_attach (GTK_TABLE (table), align, 0, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (align); - - itable = gtk_table_new (3, 2, TRUE); - gtk_table_set_col_spacings (GTK_TABLE (itable), 12); - gtk_container_add (GTK_CONTAINER (align), itable); - gtk_widget_show (itable); - - uca_editor->directories_button = gtk_check_button_new_with_mnemonic (_("_Directories")); - gtk_table_attach (GTK_TABLE (itable), uca_editor->directories_button, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (uca_editor->directories_button); - - uca_editor->audio_files_button = gtk_check_button_new_with_mnemonic (_("_Audio Files")); - gtk_table_attach (GTK_TABLE (itable), uca_editor->audio_files_button, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (uca_editor->audio_files_button); - - uca_editor->image_files_button = gtk_check_button_new_with_mnemonic (_("_Image Files")); - gtk_table_attach (GTK_TABLE (itable), uca_editor->image_files_button, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (uca_editor->image_files_button); - - uca_editor->text_files_button = gtk_check_button_new_with_mnemonic (_("_Text Files")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (uca_editor->text_files_button), TRUE); - gtk_table_attach (GTK_TABLE (itable), uca_editor->text_files_button, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (uca_editor->text_files_button); - - uca_editor->video_files_button = gtk_check_button_new_with_mnemonic (_("_Video Files")); - gtk_table_attach (GTK_TABLE (itable), uca_editor->video_files_button, 1, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (uca_editor->video_files_button); - - uca_editor->other_files_button = gtk_check_button_new_with_mnemonic (_("_Other Files")); - gtk_table_attach (GTK_TABLE (itable), uca_editor->other_files_button, 1, 2, 2, 3, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (uca_editor->other_files_button); - - align = g_object_new (GTK_TYPE_ALIGNMENT, "height-request", 12, NULL); - gtk_table_attach (GTK_TABLE (table), align, 0, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (align); - - hbox = gtk_hbox_new (FALSE, 6); - gtk_table_attach (GTK_TABLE (table), hbox, 0, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (hbox); - - image = gtk_image_new_from_icon_name ("dialog-information", GTK_ICON_SIZE_DND); - gtk_misc_set_alignment (GTK_MISC (image), 0.5f, 0.0f); - gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); - gtk_widget_show (image); - - label = gtk_label_new (_("This page lists the conditions under which the\n" - "action will appear in the file managers context\n" - "menus. The file patterns are specified as a list\n" - "of simple file patterns separated by semicolons\n" - "(e.g. *.txt;*.doc). For an action to appear in the\n" - "context menu of a file or folder, at least one of\n" - "these patterns must match the name of the file\n" - "or folder. Additionally, you can specify that the\n" - "action should only appear for certain kinds of\nfiles.")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.0f); - gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0); - gtk_widget_show (label); +} + + + +static void +thunar_uca_editor_constructed (GObject *object) +{ + ThunarUcaEditor *editor = THUNAR_UCA_EDITOR (object); + + G_OBJECT_CLASS (thunar_uca_editor_parent_class)->constructed (object); + + /* Visual tweaks for header-bar mode only */ + g_object_set (gtk_dialog_get_content_area (GTK_DIALOG (editor)), "border-width", 0, NULL); + g_object_set (editor->notebook, "show-border", FALSE, NULL); } @@ -476,6 +157,7 @@ thunar_uca_editor_command_clicked (ThunarUcaEditor *uca_editor) _("_Cancel"), GTK_RESPONSE_CANCEL, _("_Open"), GTK_RESPONSE_ACCEPT, NULL); + gtk_dialog_set_default_response (GTK_DIALOG (chooser), GTK_RESPONSE_ACCEPT); gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), TRUE); /* add file chooser filters */ @@ -610,7 +292,6 @@ thunar_uca_editor_icon_clicked (ThunarUcaEditor *uca_editor) _("_Cancel"), GTK_RESPONSE_CANCEL, _("_OK"), GTK_RESPONSE_ACCEPT, NULL); - gtk_dialog_set_alternative_button_order (GTK_DIALOG (chooser), GTK_RESPONSE_ACCEPT, GTK_RESPONSE_CANCEL, -1); gtk_dialog_set_default_response (GTK_DIALOG (chooser), GTK_RESPONSE_ACCEPT); g_free (title); @@ -665,6 +346,7 @@ thunar_uca_editor_set_icon_name (ThunarUcaEditor *uca_editor, { /* setup an image for the icon */ image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG); + g_object_set (image, "icon-size", GTK_ICON_SIZE_DND, NULL); gtk_container_add (GTK_CONTAINER (uca_editor->icon_button), image); gtk_widget_show (image); diff --git a/plugins/thunar-uca/thunar-uca-editor.ui b/plugins/thunar-uca/thunar-uca-editor.ui new file mode 100644 index 000000000..e254072e4 --- /dev/null +++ b/plugins/thunar-uca/thunar-uca-editor.ui @@ -0,0 +1,683 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + For now, better don't edit this with glade, since glade insists upon inserting + deprecated properties and otherwise messing with the file. +--> +<interface> + <requires lib="gtk+" version="3.12"/> + <template class="ThunarUcaEditor" parent="GtkDialog"> + <property name="can_focus">False</property> + <property name="title" translatable="yes">FIXME</property> + <property name="modal">True</property> + <property name="default_width">450</property> + <property name="default_height">500</property> + <property name="destroy_with_parent">True</property> + <property name="type_hint">dialog</property> + <child internal-child="vbox"> + <object class="GtkBox" id="vbox"> + <child> + <object class="GtkNotebook" id="notebook"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkGrid" id="grid1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_start">12</property> + <property name="margin_end">12</property> + <property name="margin_top">12</property> + <property name="margin_bottom">12</property> + <property name="row_spacing">12</property> + <property name="column_spacing">6</property> + <child> + <object class="GtkLabel" id="name_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Name:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">name_entry</property> + <property name="xalign">0</property> + <accessibility> + <relation type="label-for" target="name_entry"/> + </accessibility> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="name_entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip_text" translatable="yes">The name of the action that will be displayed in the context menu.</property> + <property name="hexpand">True</property> + <property name="activates_default">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="description_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Description:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">description_entry</property> + <property name="xalign">0</property> + <accessibility> + <relation type="label-for" target="description_entry"/> + </accessibility> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="description_entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip_text" translatable="yes">The description of the action that will be displayed as tooltip in the statusbar when selecting the item from the context menu.</property> + <property name="hexpand">True</property> + <property name="activates_default">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="command_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Command:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">command_entry</property> + <property name="xalign">0</property> + <accessibility> + <relation type="label-for" target="command_entry"/> + </accessibility> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkEntry" id="command_entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip_text" translatable="yes">The command (including the necessary parameters) to perform the action. See the command parameter legend below for a list of supported parameter variables, which will be substituted when launching the command. When upper-case letters (e.g. %F, %D, %N) are used, the action will be applicable even if more than one item is selected. Else the action will only be applicable if exactly one item is selected.</property> + <property name="hexpand">True</property> + <property name="activates_default">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="command_button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="tooltip_text" translatable="yes">Browse the file system to select an application to use for this action.</property> + <signal name="clicked" handler="thunar_uca_editor_command_clicked" swapped="yes"/> + <child> + <object class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">document-open-symbolic</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <style> + <class name="linked"/> + </style> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="sn_button"> + <property name="label" translatable="yes">Use Startup Notification</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes">Enable this option if you want a waiting cursor to be shown while the action is launched. This is also highly recommended if you have focus stealing prevention enabled in your window manager.</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="icon_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Icon:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">icon_button</property> + <property name="ellipsize">end</property> + <property name="xalign">0</property> + <accessibility> + <relation type="label-for" target="icon_button"/> + </accessibility> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">4</property> + </packing> + </child> + <child> + <object class="GtkButton" id="icon_button"> + <property name="label" translatable="yes">No icon</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="tooltip_text" translatable="yes">Click this button to select an icon file that will be displayed in the context menu in addition to the action name chosen above.</property> + <signal name="clicked" handler="thunar_uca_editor_icon_clicked" swapped="yes"/> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">4</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">5</property> + <property name="width">2</property> + </packing> + </child> + <child> + <object class="GtkGrid" id="grid2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="row_spacing">3</property> + <property name="column_spacing">6</property> + <child> + <object class="GtkImage" id="image2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">dialog-information</property> + <property name="icon_size">6</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">The following command parameters will be substituted when launching the action:</property> + <property name="wrap">True</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="width">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label">%f</property> + <property name="xalign">0</property> + <attributes> + <attribute name="weight" value="bold"/> + <attribute name="scale" value="0.8"/> + </attributes> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label6"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label">%F</property> + <property name="xalign">0</property> + <attributes> + <attribute name="weight" value="bold"/> + <attribute name="scale" value="0.8"/> + </attributes> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label7"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label">%d</property> + <property name="xalign">0</property> + <attributes> + <attribute name="weight" value="bold"/> + <attribute name="scale" value="0.8"/> + </attributes> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label8"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label">%D</property> + <property name="xalign">0</property> + <attributes> + <attribute name="weight" value="bold"/> + <attribute name="scale" value="0.8"/> + </attributes> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">4</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label9"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label">%n</property> + <property name="xalign">0</property> + <attributes> + <attribute name="weight" value="bold"/> + <attribute name="scale" value="0.8"/> + </attributes> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">5</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label10"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label">%N</property> + <property name="xalign">0</property> + <attributes> + <attribute name="weight" value="bold"/> + <attribute name="scale" value="0.8"/> + </attributes> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">6</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label11"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">the path to the first selected file</property> + <property name="xalign">0</property> + <property name="expand">true</property> + <attributes> + <attribute name="scale" value="0.8"/> + </attributes> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label12"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">the paths to all selected files</property> + <property name="xalign">0</property> + <attributes> + <attribute name="scale" value="0.8"/> + </attributes> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label13"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">directory containing the file that is passed in %f</property> + <property name="xalign">0</property> + <attributes> + <attribute name="scale" value="0.8"/> + </attributes> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label14"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">directories containing the files that are passed in %F</property> + <property name="xalign">0</property> + <attributes> + <attribute name="scale" value="0.8"/> + </attributes> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">4</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label15"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">the first selected filename (without path)</property> + <property name="xalign">0</property> + <attributes> + <attribute name="scale" value="0.8"/> + </attributes> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">5</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label16"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">the selected filenames (without paths)</property> + <property name="xalign">0</property> + <attributes> + <attribute name="scale" value="0.8"/> + </attributes> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">6</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">6</property> + <property name="width">2</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> + </child> + <child type="tab"> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Basic</property> + </object> + <packing> + <property name="tab_fill">False</property> + </packing> + </child> + <child> + <object class="GtkGrid" id="grid3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_start">12</property> + <property name="margin_end">12</property> + <property name="margin_top">12</property> + <property name="margin_bottom">12</property> + <property name="row_spacing">6</property> + <property name="column_spacing">12</property> + <child> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_File Pattern:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">patterns_entry</property> + <property name="xalign">0</property> + <accessibility> + <relation type="label-for" target="patterns_entry"/> + </accessibility> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="patterns_entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip_text" translatable="yes">Enter a list of patterns that will be used to determine whether this action should be displayed for a selected file. If you specify more than one pattern here, the list items must be separated with semicolons (e.g. *.txt;*.doc).</property> + <property name="hexpand">True</property> + <property name="activates_default">True</property> + <property name="text" translatable="yes">*</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label17"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Appears if selection contains:</property> + <property name="ellipsize">middle</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">2</property> + </packing> + </child> + <child> + <object class="GtkGrid" id="grid4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_start">18</property> + <property name="column_spacing">48</property> + <child> + <object class="GtkCheckButton" id="directories_button"> + <property name="label" translatable="yes">_Directories</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="hexpand">False</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="audio_files_button"> + <property name="label" translatable="yes">_Audio Files</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="image_files_button"> + <property name="label" translatable="yes">_Image Files</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="image_position">top</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="text_files_button"> + <property name="label" translatable="yes">_Text Files</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="video_files_button"> + <property name="label" translatable="yes">_Video Files</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="other_files_button"> + <property name="label" translatable="yes">_Other Files</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + <property name="width">2</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_top">12</property> + <child> + <object class="GtkImage" id="image3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="valign">start</property> + <property name="icon_name">dialog-information</property> + <property name="icon_size">6</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label18"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">This page lists the conditions under which the action will appear in the file managers context menus. The file patterns are specified as a list of simple file patterns separated by semicolons (e.g. *.txt;*.doc). For an action to appear in the context menu of a file or folder, at least one of these patterns must match the name of the file or folder. Additionally, you can specify that the action should only appear for certain kinds of files.</property> + <property name="wrap">True</property> + <property name="xalign">0</property> + <property name="yalign">0</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + <property name="width">2</property> + </packing> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child type="tab"> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Appearance Conditions</property> + </object> + <packing> + <property name="position">1</property> + <property name="tab_fill">False</property> + </packing> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </template> +</interface> diff --git a/plugins/thunar-uca/thunar-uca-model.c b/plugins/thunar-uca/thunar-uca-model.c index 023245ac8..fc5cef966 100644 --- a/plugins/thunar-uca/thunar-uca-model.c +++ b/plugins/thunar-uca/thunar-uca-model.c @@ -153,8 +153,6 @@ struct _ThunarUcaModel { GObject __parent__; - GtkIconFactory *icon_factory; - GList *items; gint stamp; }; @@ -254,12 +252,6 @@ thunar_uca_model_init (ThunarUcaModel *uca_model) GError *error = NULL; gchar *filename; - /* allocate a new icon factory for our action icons - * and add it to the default icon factories - */ - uca_model->icon_factory = gtk_icon_factory_new (); - gtk_icon_factory_add_default (uca_model->icon_factory); - /* generate a unique stamp */ uca_model->stamp = g_random_int (); @@ -286,10 +278,6 @@ thunar_uca_model_finalize (GObject *object) { ThunarUcaModel *uca_model = THUNAR_UCA_MODEL (object); - /* drop our icon factory */ - gtk_icon_factory_remove_default (uca_model->icon_factory); - g_object_unref (G_OBJECT (uca_model->icon_factory)); - /* release all items */ g_list_free_full (uca_model->items, thunar_uca_model_item_free); diff --git a/plugins/thunar-uca/thunar-uca-provider.c b/plugins/thunar-uca/thunar-uca-provider.c index 60a5b1902..e14db0ce3 100644 --- a/plugins/thunar-uca/thunar-uca-provider.c +++ b/plugins/thunar-uca/thunar-uca-provider.c @@ -159,8 +159,12 @@ static void manage_actions (GtkWindow *window) { GtkWidget *dialog; + gboolean use_header_bar = FALSE; - dialog = g_object_new (THUNAR_UCA_TYPE_CHOOSER, NULL); + g_object_get (gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window))), + "gtk-dialogs-use-header", &use_header_bar, NULL); + + dialog = g_object_new (THUNAR_UCA_TYPE_CHOOSER, "use-header-bar", use_header_bar, NULL); gtk_window_set_transient_for (GTK_WINDOW (dialog), window); gtk_widget_show (dialog); } @@ -435,8 +439,6 @@ thunar_uca_provider_child_watch (ThunarUcaProvider *uca_provider, g_return_if_fail (THUNAR_UCA_IS_PROVIDER (uca_provider)); - GDK_THREADS_ENTER (); - /* verify that we still have a valid child_watch_path */ if (G_LIKELY (uca_provider->child_watch_path != NULL)) { @@ -457,8 +459,6 @@ thunar_uca_provider_child_watch (ThunarUcaProvider *uca_provider, } thunar_uca_provider_child_watch_destroy (uca_provider, NULL); - - GDK_THREADS_LEAVE (); } diff --git a/plugins/thunar-uca/thunar-uca.gresource.xml b/plugins/thunar-uca/thunar-uca.gresource.xml new file mode 100644 index 000000000..dbaf9a3bf --- /dev/null +++ b/plugins/thunar-uca/thunar-uca.gresource.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<gresources> + <gresource prefix="/org/xfce/thunar/uca"> + <file compressed="true" alias="editor.ui">thunar-uca-editor.ui</file> + <file compressed="true" alias="chooser.ui">thunar-uca-chooser.ui</file> + </gresource> +</gresources> diff --git a/po/POTFILES.in b/po/POTFILES.in index 9eddda13f..8a02bc065 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -119,6 +119,8 @@ plugins/thunar-uca/thunar-uca-model.c plugins/thunar-uca/thunar-uca-plugin.c plugins/thunar-uca/thunar-uca-provider.c plugins/thunar-uca/uca.xml.in +[type: gettext/glade]plugins/thunar-uca/thunar-uca-editor.ui +[type: gettext/glade]plugins/thunar-uca/thunar-uca-chooser.ui plugins/thunar-wallpaper/twp-provider.c -- GitLab