diff options
author | Jürg Billeter <j@bitron.ch> | 2004-07-16 12:04:29 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2004-07-16 12:04:29 +0000 |
commit | 7b4a12a5b072693062515dbc82befb1a607adf21 (patch) | |
tree | 8beca1528a059ba920209124e57de7143c4e3509 | |
parent | 68b25b6493012008729eb1d8059f7829cb1768c6 (diff) | |
download | nautilus-7b4a12a5b072693062515dbc82befb1a607adf21.tar.gz |
Add preference to choose date format. Set default date format to '%c',
2004-07-15 Jürg Billeter <j@bitron.ch>
* libnautilus-private/apps_nautilus_preferences.schemas.in:
* libnautilus-private/nautilus-directory.c: (add_preferences_callbacks):
* libnautilus-private/nautilus-file.c: (date_format_changed_callback),
(nautilus_file_fit_date_as_string):
* libnautilus-private/nautilus-global-preferences.c:
* libnautilus-private/nautilus-global-preferences.h:
* src/nautilus-file-management-properties.c: (create_date_format_menu),
(nautilus_file_management_properties_dialog_setup):
* src/nautilus-file-management-properties.glade:
Add preference to choose date format. Set default date format to '%c',
'the preferred representation for the current locale'.
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | libnautilus-private/apps_nautilus_preferences.schemas.in | 15 | ||||
-rw-r--r-- | libnautilus-private/nautilus-directory.c | 3 | ||||
-rw-r--r-- | libnautilus-private/nautilus-file.c | 13 | ||||
-rw-r--r-- | libnautilus-private/nautilus-global-preferences.c | 15 | ||||
-rw-r--r-- | libnautilus-private/nautilus-global-preferences.h | 8 | ||||
-rw-r--r-- | src/nautilus-file-management-properties.c | 51 | ||||
-rw-r--r-- | src/nautilus-file-management-properties.glade | 147 |
8 files changed, 265 insertions, 1 deletions
@@ -1,3 +1,17 @@ +2004-07-15 Jürg Billeter <j@bitron.ch> + + * libnautilus-private/apps_nautilus_preferences.schemas.in: + * libnautilus-private/nautilus-directory.c: (add_preferences_callbacks): + * libnautilus-private/nautilus-file.c: (date_format_changed_callback), + (nautilus_file_fit_date_as_string): + * libnautilus-private/nautilus-global-preferences.c: + * libnautilus-private/nautilus-global-preferences.h: + * src/nautilus-file-management-properties.c: (create_date_format_menu), + (nautilus_file_management_properties_dialog_setup): + * src/nautilus-file-management-properties.glade: + Add preference to choose date format. Set default date format to '%c', + 'the preferred representation for the current locale'. + 2004-07-09 Alexander Larsson <alexl@redhat.com> * src/file-manager/fm-directory-view.c (activate_check_mime_types): diff --git a/libnautilus-private/apps_nautilus_preferences.schemas.in b/libnautilus-private/apps_nautilus_preferences.schemas.in index 4728e8da5..62f283e1e 100644 --- a/libnautilus-private/apps_nautilus_preferences.schemas.in +++ b/libnautilus-private/apps_nautilus_preferences.schemas.in @@ -629,6 +629,21 @@ </schema> <schema> + <key>/schemas/apps/nautilus/preferences/date_format</key> + <applyto>/apps/nautilus/preferences/date_format</applyto> + <owner>nautilus</owner> + <type>string</type> + <default>locale</default> + <locale name="C"> + <short>Date Format</short> + <long> + The format of file dates. Possible values are "locale", + "iso", and "informal". + </long> + </locale> + </schema> + + <schema> <key>/schemas/apps/nautilus/preferences/hide_built_in_bookmarks</key> <applyto>/apps/nautilus/preferences/hide_built_in_bookmarks</applyto> <owner>nautilus</owner> diff --git a/libnautilus-private/nautilus-directory.c b/libnautilus-private/nautilus-directory.c index 9a8e5913f..b958b5cdb 100644 --- a/libnautilus-private/nautilus-directory.c +++ b/libnautilus-private/nautilus-directory.c @@ -304,6 +304,9 @@ add_preferences_callbacks (void) eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS, async_data_preference_changed_callback, NULL); + eel_preferences_add_callback (NAUTILUS_PREFERENCES_DATE_FORMAT, + async_data_preference_changed_callback, + NULL); } char * diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c index 0e35a68d1..cf6c6f1ea 100644 --- a/libnautilus-private/nautilus-file.c +++ b/libnautilus-private/nautilus-file.c @@ -111,6 +111,8 @@ enum { LAST_SIGNAL }; +static int date_format_pref; + static guint signals[LAST_SIGNAL]; static GObjectClass *parent_class = NULL; @@ -3018,6 +3020,13 @@ nautilus_file_fit_date_as_string (NautilusFile *file, } file_time = localtime (&file_time_raw); + + if (date_format_pref == NAUTILUS_DATE_FORMAT_LOCALE) { + return eel_strdup_strftime ("%c", file_time); + } else if (date_format_pref == NAUTILUS_DATE_FORMAT_ISO) { + return eel_strdup_strftime ("%Y-%m-%d %H:%M:%S", file_time); + } + file_date = eel_g_date_new_tm (file_time); today = g_date_new (); @@ -6014,6 +6023,10 @@ nautilus_file_class_init (NautilusFileClass *class) G_TYPE_NONE, 0); g_type_class_add_private (class, sizeof (NautilusFileDetails)); + + + eel_preferences_add_auto_enum (NAUTILUS_PREFERENCES_DATE_FORMAT, + &date_format_pref); } static GnomeVFSFileInfo * diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c index 5770cfe32..839b93b8a 100644 --- a/libnautilus-private/nautilus-global-preferences.c +++ b/libnautilus-private/nautilus-global-preferences.c @@ -204,6 +204,14 @@ static EelEnumerationEntry standard_font_size_entries[] = { { NULL } }; +/* These are not translated, because the text is not used in the ui */ +static EelEnumerationEntry date_format_entries[] = { + { "locale", "Locale Default", NAUTILUS_DATE_FORMAT_LOCALE }, + { "iso", "ISO Format", NAUTILUS_DATE_FORMAT_ISO }, + { "informal", "Informal", NAUTILUS_DATE_FORMAT_INFORMAL }, + { NULL } +}; + /* These enumerations are used in the preferences dialog to * populate widgets and route preferences changes between the * storage (GConf) and the displayed values. @@ -218,6 +226,7 @@ static EelEnumerationInfo enumerations[] = { { "search_bar_type", search_bar_type_enum_entries }, { "speed_tradeoff", speed_tradeoff_enum_entries }, { "standard_font_size", standard_font_size_entries }, + { "date_format", date_format_entries }, { NULL } }; @@ -403,6 +412,12 @@ static const PreferenceDefault preference_defaults[] = { PREFERENCE_BOOLEAN, GINT_TO_POINTER (TRUE) }, + { NAUTILUS_PREFERENCES_DATE_FORMAT, + PREFERENCE_STRING, + "locale", + NULL, NULL, + "date_format" + }, /* Home URI */ { NAUTILUS_PREFERENCES_HOME_URI, diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h index e726ff61e..814361702 100644 --- a/libnautilus-private/nautilus-global-preferences.h +++ b/libnautilus-private/nautilus-global-preferences.h @@ -59,6 +59,14 @@ G_BEGIN_DECLS #define NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES "/desktop/gnome/file_views/show_hidden_files" #define NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES "/desktop/gnome/file_views/show_backup_files" #define NAUTILUS_PREFERENCES_SHOW_SPECIAL_FLAGS "preferences/show_special_flags" +#define NAUTILUS_PREFERENCES_DATE_FORMAT "preferences/date_format" + +typedef enum +{ + NAUTILUS_DATE_FORMAT_LOCALE, + NAUTILUS_DATE_FORMAT_ISO, + NAUTILUS_DATE_FORMAT_INFORMAL +} NautilusDateFormat; /* Sidebar panels */ #define NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES "sidebar_panels/tree/show_only_directories" diff --git a/src/nautilus-file-management-properties.c b/src/nautilus-file-management-properties.c index dcef4d787..d44717795 100644 --- a/src/nautilus-file-management-properties.c +++ b/src/nautilus-file-management-properties.c @@ -27,6 +27,7 @@ #include "nautilus-file-management-properties.h" #include <string.h> +#include <time.h> #include <gtk/gtkdialog.h> #include <gtk/gtkmenu.h> #include <gtk/gtkmenuitem.h> @@ -55,6 +56,7 @@ #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ICON_VIEW_ZOOM_WIDGET "iconview_zoom_optionmenu" #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LIST_VIEW_ZOOM_WIDGET "listview_zoom_optionmenu" #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SORT_ORDER_WIDGET "sort_order_optionmenu" +#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET "date_format_optionmenu" #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_TEXT_WIDGET "preview_text_optionmenu" #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_IMAGE_WIDGET "preview_image_optionmenu" #define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_SOUND_WIDGET "preview_sound_optionmenu" @@ -100,6 +102,13 @@ static const char *sort_order_values[] = { NULL }; +static const char *date_format_values[] = { + "locale", + "iso", + "informal", + NULL +}; + static const char *preview_values[] = { "always", "local_only", @@ -454,6 +463,43 @@ nautilus_file_management_properties_dialog_setup_icon_caption_page (GladeXML *xm } static void +create_date_format_menu (GladeXML *xml_dialog) +{ + GtkWidget *option_menu; + GtkWidget *menu; + GtkWidget *menu_item; + gchar *date_string; + time_t now_raw; + struct tm* now; + option_menu = glade_xml_get_widget (xml_dialog, + NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET); + menu = gtk_menu_new (); + + now_raw = time (NULL); + now = localtime (&now_raw); + + date_string = eel_strdup_strftime ("%c", now); + menu_item = gtk_menu_item_new_with_label (date_string); + g_free (date_string); + gtk_widget_show (menu_item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); + + date_string = eel_strdup_strftime ("%Y-%m-%d %H:%M:%S", now); + menu_item = gtk_menu_item_new_with_label (date_string); + g_free (date_string); + gtk_widget_show (menu_item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); + + date_string = eel_strdup_strftime (_("today at %-I:%M:%S %p"), now); + menu_item = gtk_menu_item_new_with_label (date_string); + g_free (date_string); + gtk_widget_show (menu_item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); + + gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu); +} + +static void set_columns_from_gconf (NautilusColumnChooser *chooser) { GList *visible_columns; @@ -525,6 +571,7 @@ nautilus_file_management_properties_dialog_setup (GladeXML *xml_dialog, GtkWindo nautilus_file_management_properties_size_group_create (xml_dialog, "preview_label", 5); + create_date_format_menu (xml_dialog); /* setup preferences */ eel_preferences_glade_connect_bool (xml_dialog, @@ -590,6 +637,10 @@ nautilus_file_management_properties_dialog_setup (GladeXML *xml_dialog, GtkWindo NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_FOLDER_WIDGET, NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS, preview_values); + eel_preferences_glade_connect_string_enum_option_menu (xml_dialog, + NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET, + NAUTILUS_PREFERENCES_DATE_FORMAT, + date_format_values); eel_preferences_glade_connect_string_enum_radio_button (xml_dialog, click_behavior_components, diff --git a/src/nautilus-file-management-properties.glade b/src/nautilus-file-management-properties.glade index cc7530f3b..6fd205c1e 100644 --- a/src/nautilus-file-management-properties.glade +++ b/src/nautilus-file-management-properties.glade @@ -1841,6 +1841,151 @@ <property name="fill">True</property> </packing> </child> + + <child> + <widget class="GtkVBox" id="vbox31"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkLabel" id="label34"> + <property name="visible">True</property> + <property name="label" translatable="yes"><span weight="bold">Date</span></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="hbox32"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkLabel" id="label35"> + <property name="visible">True</property> + <property name="label" translatable="yes"> </property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="hbox33"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">12</property> + + <child> + <widget class="GtkLabel" id="label36"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Format:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">date_format_optionmenu</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkOptionMenu" id="date_format_optionmenu"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="history">0</property> + + <child> + <widget class="GtkMenu" id="menu17"> + + <child> + <widget class="GtkMenuItem" id="locale1"> + <property name="visible">True</property> + <property name="label" translatable="yes">locale</property> + <property name="use_underline">True</property> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="iso1"> + <property name="visible">True</property> + <property name="label" translatable="yes">iso</property> + <property name="use_underline">True</property> + </widget> + </child> + + <child> + <widget class="GtkMenuItem" id="informal1"> + <property name="visible">True</property> + <property name="label" translatable="yes">informal</property> + <property name="use_underline">True</property> + </widget> + </child> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> </widget> <packing> <property name="tab_expand">False</property> @@ -1851,7 +1996,7 @@ <child> <widget class="GtkLabel" id="label24"> <property name="visible">True</property> - <property name="label" translatable="yes">Icon Captions</property> + <property name="label" translatable="yes">Display</property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_LEFT</property> |