From 075ccc00464defe1792bda5cd7210709082fe191 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Tue, 25 Jan 2000 10:30:53 +0000 Subject: [PATCH] 2000-01-26 Federico Mena Quintero * idl/FileManager.idl (Desktop): Added arrange_icons() method and an ArrangeType enum. --- ChangeLog | 5 ++++ gnome/ChangeLog | 14 ++++++++++ gnome/gcorba.c | 42 +++++++++++++++++++++++++++++- gnome/gdesktop-icon.c | 2 +- gnome/gdesktop-prefs.c | 2 +- gnome/gdesktop.c | 6 +++-- gnome/gdesktop.h | 2 ++ gnome/gmc-client.c | 42 ++++++++++++++++++++++++++++++ gnome/gnome-file-property-dialog.c | 40 ++++++++++++++-------------- idl/FileManager.idl | 10 +++++++ 10 files changed, 140 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5f7ded0c1..feb0ce6ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2000-01-26 Federico Mena Quintero + + * idl/FileManager.idl (Desktop): Added arrange_icons() method and + an ArrangeType enum. + 2000-01-03 Aaron Lehmann * gdesktop.c, gdnd.c, gaction.c, gicon.c, diff --git a/gnome/ChangeLog b/gnome/ChangeLog index 1ad65535b..4fc154a74 100644 --- a/gnome/ChangeLog +++ b/gnome/ChangeLog @@ -1,3 +1,17 @@ +2000-01-26 Federico Mena Quintero + + * gmc-client.c (options): Added the --arrange-desktop-icons + option. + (arrange_desktop_icons): Implemented. + + * gcorba.c (Desktop_arrange_icons): Implemented. + (Desktop_class_init): Put the function in the desktop_epv. + + * gdesktop.c (desktop_arrange_icons): Made public. + + * gnome-file-property-dialog.c (align_label_new): Renamed from + label_new() to avoid a conflict with widget.h. + 2000-01-02 Federico Mena Quintero * gaction.c (gmc_open_filename): Use gnome_mime_needsterminal() diff --git a/gnome/gcorba.c b/gnome/gcorba.c index 983dd0c95..caadcdc2a 100644 --- a/gnome/gcorba.c +++ b/gnome/gcorba.c @@ -12,7 +12,6 @@ #include "../vfs/vfs.h" #include #include "FileManager.h" -#include "gcmd.h" #include "gcorba.h" #include "gdesktop.h" #include "global.h" @@ -85,6 +84,46 @@ Desktop_rescan_devices (PortableServer_Servant servant, CORBA_Environment *ev) desktop_rescan_devices (); } +/* Desktop::arrange_icons method */ +static void +Desktop_arrange_icons (PortableServer_Servant servant, + GNOME_FileManager_Desktop_ArrangeType type, + CORBA_Environment *ev) +{ + SortType sort_type; + + switch (type) { + case GNOME_FileManager_Desktop_BY_NAME: + sort_type = SORT_NAME; + break; + + case GNOME_FileManager_Desktop_BY_TYPE: + sort_type = SORT_EXTENSION; + break; + + case GNOME_FileManager_Desktop_BY_SIZE: + sort_type = SORT_SIZE; + break; + + case GNOME_FileManager_Desktop_BY_ATIME: + sort_type = SORT_ACCESS; + break; + + case GNOME_FileManager_Desktop_BY_MTIME: + sort_type = SORT_MODIFY; + break; + + case GNOME_FileManager_Desktop_BY_CTIME: + sort_type = SORT_CHANGE; + break; + + default: + return; /* Should we raise an exception instead? */ + } + + desktop_arrange_icons (sort_type); +} + /* Fills the vepv structure for the desktop object */ static void Desktop_class_init (void) @@ -98,6 +137,7 @@ Desktop_class_init (void) desktop_epv.rescan = Desktop_rescan; desktop_epv.rescan_devices = Desktop_rescan_devices; + desktop_epv.arrange_icons = Desktop_arrange_icons; desktop_vepv._base_epv = &desktop_base_epv; desktop_vepv.GNOME_FileManager_Desktop_epv = &desktop_epv; diff --git a/gnome/gdesktop-icon.c b/gnome/gdesktop-icon.c index 4a2d84b04..dbb194346 100644 --- a/gnome/gdesktop-icon.c +++ b/gnome/gdesktop-icon.c @@ -6,6 +6,7 @@ */ #include +#include "gdesktop.h" #include #include #include @@ -13,7 +14,6 @@ #include #include "gdesktop-icon.h" #include "dir.h" -#include "gdesktop.h" /* Spacing between icon and text */ diff --git a/gnome/gdesktop-prefs.c b/gnome/gdesktop-prefs.c index c449838f1..34a4ad994 100644 --- a/gnome/gdesktop-prefs.c +++ b/gnome/gdesktop-prefs.c @@ -6,9 +6,9 @@ */ #include +#include "gdesktop.h" #include #include "gdesktop-prefs.h" -#include "gdesktop.h" /* Size of the icon position box */ diff --git a/gnome/gdesktop.c b/gnome/gdesktop.c index 7716958c6..fe623eaba 100644 --- a/gnome/gdesktop.c +++ b/gnome/gdesktop.c @@ -56,7 +56,9 @@ int desktop_arr_rows = FALSE; * 1 -- Enable shaped text always * 2 -- Disable shaped text * - * This might seem a bit stra + * This might seem a bit strange, but it is like that for compatibility reasons. + */ + int desktop_use_shaped_text = 0; /* The computed name of the user's desktop directory */ @@ -727,7 +729,7 @@ static WPanel *create_panel_from_desktop(); /* Fwd decl */ static void free_panel_from_desktop(WPanel *panel); /* Perform automatic arrangement of the desktop icons */ -static void +void desktop_arrange_icons (SortType type) { WPanel *panel; diff --git a/gnome/gdesktop.h b/gnome/gdesktop.h index ecfe0460b..34b07ea73 100644 --- a/gnome/gdesktop.h +++ b/gnome/gdesktop.h @@ -10,6 +10,7 @@ #define GDESKTOP_H #include "dir.h" +#include "gcmd.h" /* Snap granularity for desktop icons -- maybe these should be calculated in @@ -73,6 +74,7 @@ gboolean do_eject (char *filename); void desktop_rescan_devices (void); void desktop_recreate_default_icons (void); void desktop_reload_icons (int user_pos, int xpos, int ypos); +void desktop_arrange_icons (SortType type); void desktop_create_url (const char *filename, const char *title, const char *url, const char *icon); extern int desktop_wm_is_gnome_compliant; diff --git a/gnome/gmc-client.c b/gnome/gmc-client.c index fd32d5153..84f4a0f6c 100644 --- a/gnome/gmc-client.c +++ b/gnome/gmc-client.c @@ -119,6 +119,39 @@ rescan_desktop_devices (CORBA_Environment *ev) return TRUE; } +/* Arrange the desktop icons */ +static int +arrange_desktop_icons (const char *type, CORBA_Environment *ev) +{ + CORBA_Object obj; + GNOME_FileManager_Desktop_ArrangeType arr_type; + + if (strcmp (type, "name") == 0) + arr_type = GNOME_FileManager_Desktop_BY_NAME; + else if (strcmp (type, "type") == 0) + arr_type = GNOME_FileManager_Desktop_BY_TYPE; + else if (strcmp (type, "size") == 0) + arr_type = GNOME_FileManager_Desktop_BY_SIZE; + else if (strcmp (type, "atime") == 0) + arr_type = GNOME_FileManager_Desktop_BY_ATIME; + else if (strcmp (type, "mtime") == 0) + arr_type = GNOME_FileManager_Desktop_BY_MTIME; + else if (strcmp (type, "ctime") == 0) + arr_type = GNOME_FileManager_Desktop_BY_CTIME; + else { + fprintf (stderr, _("Unknown arrange type `%s'\n"), type); + return FALSE; + } + + obj = get_desktop (); + if (obj == CORBA_OBJECT_NIL) + return FALSE; + + GNOME_FileManager_Desktop_arrange_icons (obj, arr_type, ev); + CORBA_Object_release (obj, ev); + return TRUE; +} + /* Close invalid windows */ static int close_invalid_windows (CORBA_Environment *ev) @@ -143,11 +176,13 @@ enum { ARG_RESCAN_DIRECTORY, ARG_RESCAN_DESKTOP, ARG_RESCAN_DESKTOP_DEVICES, + ARG_ARRANGE_DESKTOP_ICONS, ARG_CLOSE_INVALID_WINDOWS }; static int selected_option = -1; static char *directory; +static char *arrange_type; /* Parse an argument */ static void @@ -175,6 +210,9 @@ static const struct poptOption options[] = { N_("Rescan the desktop icons"), NULL }, { "rescan-desktop-devices", '\0', POPT_ARG_NONE, NULL, ARG_RESCAN_DESKTOP_DEVICES, N_("Rescan the desktop device icons"), NULL }, + { "arrange-desktop-icons", '\0', POPT_ARG_STRING, &arrange_type, ARG_ARRANGE_DESKTOP_ICONS, + N_("Arrange the desktop icons"), + N_("name | type | size | atime | mtime | ctime") }, { "close-invalid-windows", '\0', POPT_ARG_NONE, NULL, ARG_CLOSE_INVALID_WINDOWS, N_("Close windows whose directories cannot be reached"), NULL }, { NULL, '\0', 0, NULL, 0, NULL, NULL } @@ -215,6 +253,10 @@ main (int argc, char **argv) result = rescan_desktop_devices (&ev); break; + case ARG_ARRANGE_DESKTOP_ICONS: + result = arrange_desktop_icons (arrange_type, &ev); + break; + case ARG_CLOSE_INVALID_WINDOWS: result = close_invalid_windows (&ev); break; diff --git a/gnome/gnome-file-property-dialog.c b/gnome/gnome-file-property-dialog.c index fe92b4f9d..db5851412 100644 --- a/gnome/gnome-file-property-dialog.c +++ b/gnome/gnome-file-property-dialog.c @@ -634,10 +634,9 @@ create_settings_pane (GnomeFilePropertyDialog *fp_dlg) } /* Permissions Pane */ -/* Name changed to dialog_label_new so it doesn't conflict with something -in widget.h */ + static GtkWidget * -dialog_label_new (char *text, double xalign, double yalign) +align_label_new (char *text, double xalign, double yalign) { GtkWidget *label; @@ -731,15 +730,15 @@ gtk_table_attach (GTK_TABLE (table), widget, \ GTK_FILL | GTK_SHRINK, \ 0, 0); -#define PERMSET(name, r, w, x, rmask, wmask, xmask, y) do { \ - r = perm_check_new (NULL, fp_dlg->st.st_mode & rmask, fp_dlg); \ - w = perm_check_new (NULL, fp_dlg->st.st_mode & wmask, fp_dlg); \ - x = perm_check_new (NULL, fp_dlg->st.st_mode & xmask, fp_dlg); \ - \ - ATTACH (table, dialog_label_new (name, 0.0, 0.5), 0, 1, y, y + 1);\ - ATTACH (table, r, 1, 2, y, y + 1); \ - ATTACH (table, w, 2, 3, y, y + 1); \ - ATTACH (table, x, 3, 4, y, y + 1); \ +#define PERMSET(name, r, w, x, rmask, wmask, xmask, y) do { \ + r = perm_check_new (NULL, fp_dlg->st.st_mode & rmask, fp_dlg); \ + w = perm_check_new (NULL, fp_dlg->st.st_mode & wmask, fp_dlg); \ + x = perm_check_new (NULL, fp_dlg->st.st_mode & xmask, fp_dlg); \ + \ + ATTACH (table, align_label_new (name, 0.0, 0.5), 0, 1, y, y + 1); \ + ATTACH (table, r, 1, 2, y, y + 1); \ + ATTACH (table, w, 2, 3, y, y + 1); \ + ATTACH (table, x, 3, 4, y, y + 1); \ } while (0); static GtkWidget * @@ -762,9 +761,10 @@ perm_mode_new (GnomeFilePropertyDialog *fp_dlg) gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); - gtk_box_pack_start (GTK_BOX (hbox), dialog_label_new (_("Current mode: "), 0.0, 0.5), FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), align_label_new (_("Current mode: "), 0.0, 0.5), + FALSE, FALSE, 0); - fp_dlg->mode_label = dialog_label_new ("0000", 0.0, 0.5); + fp_dlg->mode_label = align_label_new ("0000", 0.0, 0.5); gtk_box_pack_start (GTK_BOX (hbox), fp_dlg->mode_label, FALSE, FALSE, 0); table = gtk_table_new (4, 5, FALSE); @@ -777,10 +777,10 @@ perm_mode_new (GnomeFilePropertyDialog *fp_dlg) /* Headings */ - ATTACH (table, dialog_label_new (_("Read"), 0.0, 0.5), 1, 2, 0, 1); - ATTACH (table, dialog_label_new (_("Write"), 0.0, 0.5), 2, 3, 0, 1); - ATTACH (table, dialog_label_new (_("Exec"), 0.0, 0.5), 3, 4, 0, 1); - ATTACH (table, dialog_label_new (_("Special"), 0.0, 0.5), 4, 5, 0, 1); + ATTACH (table, align_label_new (_("Read"), 0.0, 0.5), 1, 2, 0, 1); + ATTACH (table, align_label_new (_("Write"), 0.0, 0.5), 2, 3, 0, 1); + ATTACH (table, align_label_new (_("Exec"), 0.0, 0.5), 3, 4, 0, 1); + ATTACH (table, align_label_new (_("Special"), 0.0, 0.5), 4, 5, 0, 1); /* Permissions */ @@ -939,7 +939,7 @@ perm_ownership_new (GnomeFilePropertyDialog *fp_dlg) /* Owner */ - gtk_table_attach (GTK_TABLE (table), dialog_label_new (_("Owner"), 0.0, 0.5), + gtk_table_attach (GTK_TABLE (table), align_label_new (_("Owner"), 0.0, 0.5), 0, 1, 0, 1, GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 0, 0); @@ -954,7 +954,7 @@ perm_ownership_new (GnomeFilePropertyDialog *fp_dlg) /* Group */ - gtk_table_attach (GTK_TABLE (table), dialog_label_new (_("Group"), 0.0, 0.5), + gtk_table_attach (GTK_TABLE (table), align_label_new (_("Group"), 0.0, 0.5), 0, 1, 1, 2, GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 0, 0); diff --git a/idl/FileManager.idl b/idl/FileManager.idl index 9288e0165..091a8034a 100644 --- a/idl/FileManager.idl +++ b/idl/FileManager.idl @@ -5,8 +5,18 @@ module GNOME { exception POSIX_ERROR { string errorstr; }; interface Desktop { + enum ArrangeType { + BY_NAME, + BY_TYPE, + BY_SIZE, + BY_ATIME, + BY_MTIME, + BY_CTIME + }; + void rescan (); void rescan_devices (); + void arrange_icons (in ArrangeType type); }; interface Window {