Skip to content

Commit 31883c2

Browse files
committed
preferences: Add templates to plugins tab.
This exposes the feature to users and allows them to add, remove and rename New Document templates.
1 parent 3615666 commit 31883c2

10 files changed

+732
-39
lines changed

src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ nemoCommon_sources = [
5757
'nemo-progress-ui-handler.c',
5858
'nemo-properties-window.c',
5959
'nemo-query-editor.c',
60+
'nemo-template-config-widget.c',
6061
'nemo-self-check-functions.c',
6162
'nemo-statusbar.c',
6263
'nemo-thumbnail-problem-bar.c',

src/nemo-action-config-widget.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ nemo_action_config_widget_init (NemoActionConfigWidget *self)
462462

463463
GtkWidget *widget = gtk_button_new_from_icon_name ("folder-symbolic", GTK_ICON_SIZE_BUTTON);
464464

465-
GtkWidget *bb = nemo_config_base_widget_get_buttonbox (NEMO_CONFIG_BASE_WIDGET (self));
465+
GtkWidget *bb = NEMO_CONFIG_BASE_WIDGET (self)->rbuttonbox;
466466
gtk_box_pack_end (GTK_BOX (bb),
467467
widget,
468468
FALSE, FALSE, 0);

src/nemo-config-base-widget.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,25 @@ nemo_config_base_widget_init (NemoConfigBaseWidget *self)
6969
gtk_container_add (GTK_CONTAINER (toolbar_item), w);
7070
context = gtk_widget_get_style_context(w);
7171
gtk_style_context_add_class (context, "linked");
72+
self->lbuttonbox = w;
7273

7374
label = gtk_label_new (_("Disable all"));
7475
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
7576

7677
self->disable_button = gtk_button_new ();
7778
gtk_container_add (GTK_CONTAINER (w), self->disable_button);
7879
gtk_container_add (GTK_CONTAINER (self->disable_button), label);
80+
gtk_widget_show_all (self->disable_button);
81+
gtk_widget_set_no_show_all (self->disable_button, TRUE);
7982

8083
label = gtk_label_new (_("Enable all"));
8184
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
8285

8386
self->enable_button = gtk_button_new ();
8487
gtk_container_add (GTK_CONTAINER (w), self->enable_button);
8588
gtk_container_add (GTK_CONTAINER (self->enable_button), label);
89+
gtk_widget_show_all (self->enable_button);
90+
gtk_widget_set_no_show_all (self->enable_button, TRUE);
8691

8792
toolbar_item = GTK_WIDGET (gtk_tool_item_new ());
8893
gtk_tool_item_set_expand (GTK_TOOL_ITEM (toolbar_item), FALSE);
@@ -92,7 +97,7 @@ nemo_config_base_widget_init (NemoConfigBaseWidget *self)
9297
gtk_container_add (GTK_CONTAINER (toolbar_item), w);
9398
context = gtk_widget_get_style_context(w);
9499
gtk_style_context_add_class (context, "linked");
95-
self->buttonbox = w;
100+
self->rbuttonbox = w;
96101

97102
gtk_widget_show_all (GTK_WIDGET (self));
98103
}
@@ -123,19 +128,6 @@ nemo_config_base_widget_get_listbox (NemoConfigBaseWidget *widget)
123128
return widget->listbox;
124129
}
125130

126-
/**
127-
* nemo_config_base_widget_get_buttonbox:
128-
* @widget: a #NemoConfigBaseWidget
129-
*
130-
* Returns: (transfer none): the buttonbox #GtkWidget
131-
*/
132-
133-
GtkWidget *
134-
nemo_config_base_widget_get_buttonbox (NemoConfigBaseWidget *widget)
135-
{
136-
return widget->buttonbox;
137-
}
138-
139131
/**
140132
* nemo_config_base_widget_get_enable_button:
141133
* @widget: a #NemoConfigBaseWidget

src/nemo-config-base-widget.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ struct _NemoConfigBaseWidget
3232

3333
GtkWidget *label;
3434
GtkWidget *listbox;
35-
GtkWidget *buttonbox;
35+
GtkWidget *lbuttonbox;
36+
GtkWidget *rbuttonbox;
3637
GtkWidget *enable_button;
3738
GtkWidget *disable_button;
3839
};
@@ -46,7 +47,6 @@ GType nemo_config_base_widget_get_type (void);
4647

4748
GtkWidget *nemo_config_base_widget_get_label (NemoConfigBaseWidget *widget);
4849
GtkWidget *nemo_config_base_widget_get_listbox (NemoConfigBaseWidget *widget);
49-
GtkWidget *nemo_config_base_widget_get_buttonbox (NemoConfigBaseWidget *widget);
5050
GtkWidget *nemo_config_base_widget_get_enable_button (NemoConfigBaseWidget *widget);
5151
GtkWidget *nemo_config_base_widget_get_disable_button (NemoConfigBaseWidget *widget);
5252

src/nemo-extension-config-widget.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ nemo_extension_config_widget_init (NemoExtensionConfigWidget *self)
408408

409409
self->restart_button = gtk_button_new_with_label (_("Extensions changed. Restart required."));
410410

411-
GtkWidget *bb = nemo_config_base_widget_get_buttonbox (NEMO_CONFIG_BASE_WIDGET (self));
411+
GtkWidget *bb = NEMO_CONFIG_BASE_WIDGET (self)->rbuttonbox;
412412
gtk_box_pack_end (GTK_BOX (bb),
413413
self->restart_button,
414414
FALSE, FALSE, 0);

src/nemo-interesting-folder-bar.c

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ enum {
4242

4343
enum {
4444
INTERESTING_FOLDER_BAR_ACTION_OPEN_DOC = 1,
45-
INTERESTING_FOLDER_BAR_SCRIPT_OPEN_DOC
45+
INTERESTING_FOLDER_BAR_SCRIPT_OPEN_DOC,
46+
INTERESTING_FOLDER_BAR_TEMPLATE_OPEN_DOC
4647
};
4748

4849
struct NemoInterestingFolderBarPrivate
@@ -137,6 +138,10 @@ nemo_interesting_folder_bar_constructed (GObject *obj)
137138
INTERESTING_FOLDER_BAR_SCRIPT_OPEN_DOC);
138139
gtk_widget_set_tooltip_text (w, _("View additional information about creating scripts"));
139140
break;
141+
case TYPE_TEMPLATES_FOLDER:
142+
label = gtk_label_new (_("Templates: Files in this folder will appear in the Create New Document "
143+
"submenu."));
144+
break;
140145
case TYPE_NONE_FOLDER:
141146
default:
142147
label = gtk_label_new ("undefined");
@@ -179,7 +184,7 @@ nemo_interesting_folder_bar_class_init (NemoInterestingFolderBarClass *klass)
179184
"type",
180185
"the InterestingFolderType",
181186
TYPE_NONE_FOLDER,
182-
TYPE_SCRIPTS_FOLDER,
187+
TYPE_TEMPLATES_FOLDER,
183188
TYPE_NONE_FOLDER,
184189
G_PARAM_WRITABLE |
185190
G_PARAM_CONSTRUCT_ONLY |
@@ -213,24 +218,34 @@ nemo_interesting_folder_bar_new_for_location (NemoView *view, GFile *location)
213218

214219
path = nemo_action_manager_get_user_directory_path ();
215220
tmp_loc = g_file_new_for_path (path);
221+
g_free (path);
216222

217223
if (g_file_equal (location, tmp_loc)) {
218224
type = TYPE_ACTIONS_FOLDER;
219-
goto out;
220225
}
221-
222-
g_free (path);
223226
g_object_unref (tmp_loc);
224227

225-
path = nemo_get_scripts_directory_path ();
226-
tmp_loc = g_file_new_for_path (path);
228+
if (type == TYPE_NONE_FOLDER) {
229+
path = nemo_get_scripts_directory_path ();
230+
tmp_loc = g_file_new_for_path (path);
231+
g_free (path);
227232

228-
if (g_file_equal (location, tmp_loc))
229-
type = TYPE_SCRIPTS_FOLDER;
233+
if (g_file_equal (location, tmp_loc)) {
234+
type = TYPE_SCRIPTS_FOLDER;
235+
}
236+
g_object_unref (tmp_loc);
237+
}
230238

231-
out:
232-
g_free (path);
233-
g_object_unref (tmp_loc);
239+
if (type == TYPE_NONE_FOLDER) {
240+
path = nemo_get_templates_directory ();
241+
tmp_loc = g_file_new_for_path (path);
242+
g_free (path);
243+
244+
if (g_file_equal (location, tmp_loc)) {
245+
type = TYPE_TEMPLATES_FOLDER;
246+
}
247+
g_object_unref (tmp_loc);
248+
}
234249

235250
return type == TYPE_NONE_FOLDER ? NULL : nemo_interesting_folder_bar_new (view, type);
236251
}

src/nemo-interesting-folder-bar.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ typedef struct
4949
typedef enum {
5050
TYPE_NONE_FOLDER = 1,
5151
TYPE_ACTIONS_FOLDER,
52-
TYPE_SCRIPTS_FOLDER
52+
TYPE_SCRIPTS_FOLDER,
53+
TYPE_TEMPLATES_FOLDER
5354
} InterestingFolderType;
5455

5556
GType nemo_interesting_folder_bar_get_type (void) G_GNUC_CONST;

src/nemo-plugin-manager.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <config.h>
88
#include "nemo-plugin-manager.h"
99
#include "nemo-action-config-widget.h"
10+
#include "nemo-template-config-widget.h"
1011
#include "nemo-extension-config-widget.h"
1112
#include <glib.h>
1213

@@ -29,21 +30,24 @@ nemo_plugin_manager_init (NemoPluginManager *self)
2930

3031
grid = gtk_grid_new ();
3132

32-
gtk_widget_set_margin_left (grid, 10);
33-
gtk_widget_set_margin_right (grid, 10);
34-
gtk_widget_set_margin_top (grid, 10);
35-
gtk_widget_set_margin_bottom (grid, 10);
36-
gtk_grid_set_row_spacing (GTK_GRID (grid), 10);
37-
gtk_grid_set_column_spacing (GTK_GRID (grid), 10);
33+
gtk_widget_set_margin_left (grid, 4);
34+
gtk_widget_set_margin_right (grid, 4);
35+
gtk_widget_set_margin_top (grid, 4);
36+
gtk_widget_set_margin_bottom (grid, 4);
37+
gtk_grid_set_row_spacing (GTK_GRID (grid), 4);
38+
gtk_grid_set_column_spacing (GTK_GRID (grid), 4);
3839
gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
3940
gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE);
4041

41-
widget = nemo_action_config_widget_new ();
42+
widget = nemo_template_config_widget_new ();
4243
gtk_grid_attach (GTK_GRID (grid), widget, 0, 0, 2, 1);
4344

44-
widget = nemo_extension_config_widget_new ();
45+
widget = nemo_action_config_widget_new ();
4546
gtk_grid_attach (GTK_GRID (grid), widget, 0, 1, 2, 1);
4647

48+
widget = nemo_extension_config_widget_new ();
49+
gtk_grid_attach (GTK_GRID (grid), widget, 0, 2, 2, 1);
50+
4751
gtk_container_add (GTK_CONTAINER (self), grid);
4852

4953
gtk_widget_show_all (GTK_WIDGET (self));

0 commit comments

Comments
 (0)