diff options
Diffstat (limited to 'capplets')
136 files changed, 0 insertions, 18688 deletions
diff --git a/capplets/desktop-links/Advanced.directory.in.in b/capplets/desktop-links/Advanced.directory.in.in deleted file mode 100644 index e429985f9..000000000 --- a/capplets/desktop-links/Advanced.directory.in.in +++ /dev/null @@ -1,5 +0,0 @@ -[Desktop Entry] -_Name=Advanced -_Comment=Advanced Settings -Type=Directory -Icon=advanced-directory.png diff --git a/capplets/desktop-links/Sawfish/Makefile.am b/capplets/desktop-links/Sawfish/Makefile.am deleted file mode 100644 index 568529a37..000000000 --- a/capplets/desktop-links/Sawfish/Makefile.am +++ /dev/null @@ -1,68 +0,0 @@ -## .desktop files -## -## translate foo.desktop.in and create a foo.desktop file. -## - -capplets = \ - appearance-properties \ - misc-properties \ - bindings-properties \ - move-properties \ - focus-properties \ - placement-properties \ - match-properties \ - sound-properties \ - maximize-properties \ - workspace-properties \ - meta-properties - -## -## Pixmaps -## - -pixmaps_DATA = $(group_icon) -pixmapsdir = $(GNOMECC_ICONS_DIR) - - -## -## dekstop files -## -desktop_files = $(capplets:=.desktop) -desktop_in_files = $(desktop_files:.desktop=.desktop.in) - -cappletsdir = $(datadir)/control-center/capplets/Sawfish -capplets_DATA = $(desktop_files) - -EXTRA_DIST = $(desktop_in_files) Sawfish.directory.in.in $(pixmaps_DATA) - -$(desktop_files): %.desktop: %.desktop.in - $(top_builddir)/xml-i18n-merge -d $(top_srcdir)/po $< $@ - - -## Create the .directory file -## -## foo.directory.in is created from foo.directory.in.in and substituting the Icon field with -## the full path of the icon. -## foo.directory.in is merged with the translations to create foo.directory -## foo.directory is installed and renamed -## -groups = Sawfish -group_icon = sawfish-group.png -groups_files = $(groups:=.directory) -groups_in_files = $(groups_files:.directory=.directory.in) - -Gnomeccdir = $(datadir)/control-center/capplets/$(groups) -Gnomecc_DATA = $(groups_files) - -$(groups_in_files): %.directory.in: %.directory.in.in - sed s#Icon=\.*#Icon=$(GNOMECC_ICONS_DIR)/${group_icon}# < $< > $@ - -$(groups_files): %.directory: %.directory.in - $(top_builddir)/xml-i18n-merge -d $(top_srcdir)/po $< $@ - -## We need to install this ourselves cause we change the name of the -## file to .directory. -install-data-local: - $(mkinstalldirs) $(DESTDIR)$(Gnomeccdirp) - $(INSTALL_DATA) Sawfish.directory $(DESTDIR)$(Gnomeccdir)/.directory - diff --git a/capplets/desktop-links/Sawfish/Sawfish.directory.in.in b/capplets/desktop-links/Sawfish/Sawfish.directory.in.in deleted file mode 100644 index 29098b4f7..000000000 --- a/capplets/desktop-links/Sawfish/Sawfish.directory.in.in +++ /dev/null @@ -1,5 +0,0 @@ -[Desktop Entry] -_Name=Sawfish window manager -_Comment=Control Center Menu -Icon=gnome-ccwindowmanager.png -Type=Directory diff --git a/capplets/desktop-links/Sawfish/appearance-properties.desktop.in b/capplets/desktop-links/Sawfish/appearance-properties.desktop.in deleted file mode 100644 index 68414fc80..000000000 --- a/capplets/desktop-links/Sawfish/appearance-properties.desktop.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=Appearance -_Comment=Configure window appearance -Exec=sawfish-capplet --sawfish-group=appearance -Icon=sawfish-appearance.png -Terminal=0 -Type=Application diff --git a/capplets/desktop-links/Sawfish/bindings-properties.desktop.in b/capplets/desktop-links/Sawfish/bindings-properties.desktop.in deleted file mode 100644 index 1e352a302..000000000 --- a/capplets/desktop-links/Sawfish/bindings-properties.desktop.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=Shortcuts -_Comment=Configure key shortcuts -Exec=sawfish-capplet --sawfish-group=bindings -Icon=sawfish-shortcuts.png -Terminal=0 -Type=Application diff --git a/capplets/desktop-links/Sawfish/focus-properties.desktop.in b/capplets/desktop-links/Sawfish/focus-properties.desktop.in deleted file mode 100644 index b238f46ea..000000000 --- a/capplets/desktop-links/Sawfish/focus-properties.desktop.in +++ /dev/null @@ -1,15 +0,0 @@ -[Desktop Entry] -_Name=Focus behavior -_Comment=Configure window focusing -Exec=sawfish-capplet --sawfish-group=focus -Icon=sawfish-focus.png -Terminal=0 -Type=Application - - - - - - - - diff --git a/capplets/desktop-links/Sawfish/match-properties.desktop.in b/capplets/desktop-links/Sawfish/match-properties.desktop.in deleted file mode 100644 index 3dfe7ef5d..000000000 --- a/capplets/desktop-links/Sawfish/match-properties.desktop.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=Matched Windows -_Comment=Configure window properties -Exec=sawfish-capplet --sawfish-group=match-window -Icon=sawfish-matched.png -Terminal=0 -Type=Application diff --git a/capplets/desktop-links/Sawfish/maximize-properties.desktop.in b/capplets/desktop-links/Sawfish/maximize-properties.desktop.in deleted file mode 100644 index 38e6717f2..000000000 --- a/capplets/desktop-links/Sawfish/maximize-properties.desktop.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=Minimizing and Maximizing -_Comment=Configure window minimization and maximization -Exec=sawfish-capplet --sawfish-group=min-max -Icon=sawfish-minmax.png -Terminal=0 -Type=Application diff --git a/capplets/desktop-links/Sawfish/meta-properties.desktop.in b/capplets/desktop-links/Sawfish/meta-properties.desktop.in deleted file mode 100644 index 921230b3a..000000000 --- a/capplets/desktop-links/Sawfish/meta-properties.desktop.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=Meta -_Comment=Configure window manager configuration properties -Exec=sawfish-capplet --sawfish-no-flatten -Icon=gnome-ccdialog.png -Terminal=0 -Type=Application diff --git a/capplets/desktop-links/Sawfish/misc-properties.desktop.in b/capplets/desktop-links/Sawfish/misc-properties.desktop.in deleted file mode 100644 index e9f2884fd..000000000 --- a/capplets/desktop-links/Sawfish/misc-properties.desktop.in +++ /dev/null @@ -1,8 +0,0 @@ -[Desktop Entry] -_Name=Miscellaneous -_Comment=Configure miscellaneous window features -Exec=sawfish-capplet --sawfish-group=misc -Icon=sawfish-misc.png -Terminal=0 -Type=Application - diff --git a/capplets/desktop-links/Sawfish/move-properties.desktop.in b/capplets/desktop-links/Sawfish/move-properties.desktop.in deleted file mode 100644 index 0d3bb49de..000000000 --- a/capplets/desktop-links/Sawfish/move-properties.desktop.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=Moving and Resizing -_Comment=Configure window move/resize -Exec=sawfish-capplet --sawfish-group=move -Icon=sawfish-moveresize.png -Terminal=0 -Type=Application diff --git a/capplets/desktop-links/Sawfish/placement-properties.desktop.in b/capplets/desktop-links/Sawfish/placement-properties.desktop.in deleted file mode 100644 index 04b0aef2e..000000000 --- a/capplets/desktop-links/Sawfish/placement-properties.desktop.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=Placement -_Comment=Configure window placement -Exec=sawfish-capplet --sawfish-group=placement -Icon=sawfish-placement.png -Terminal=0 -Type=Application diff --git a/capplets/desktop-links/Sawfish/sawfish-group.png b/capplets/desktop-links/Sawfish/sawfish-group.png Binary files differdeleted file mode 100644 index ef95bcd47..000000000 --- a/capplets/desktop-links/Sawfish/sawfish-group.png +++ /dev/null diff --git a/capplets/desktop-links/Sawfish/sound-properties.desktop.in b/capplets/desktop-links/Sawfish/sound-properties.desktop.in deleted file mode 100644 index abbe7e3c4..000000000 --- a/capplets/desktop-links/Sawfish/sound-properties.desktop.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=Sound -_Comment=Enable window manager sound events -Exec=sawfish-capplet --sawfish-group=audio -Icon=gnome-multimedia.png -Terminal=0 -Type=Application diff --git a/capplets/desktop-links/Sawfish/workspace-properties.desktop.in b/capplets/desktop-links/Sawfish/workspace-properties.desktop.in deleted file mode 100644 index 235f5b3bc..000000000 --- a/capplets/desktop-links/Sawfish/workspace-properties.desktop.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=Workspaces -_Comment=Configure workspaces -Exec=sawfish-capplet --sawfish-group=workspace -Icon=sawfish-workspaces.png -Terminal=0 -Type=Application diff --git a/capplets/desktop-links/advanced-directory.png b/capplets/desktop-links/advanced-directory.png Binary files differdeleted file mode 100644 index 4133fc973..000000000 --- a/capplets/desktop-links/advanced-directory.png +++ /dev/null diff --git a/capplets/desktop-links/cd-capplet.png b/capplets/desktop-links/cd-capplet.png Binary files differdeleted file mode 100644 index de95583dc..000000000 --- a/capplets/desktop-links/cd-capplet.png +++ /dev/null diff --git a/capplets/desktop-links/cd.desktop.in.in b/capplets/desktop-links/cd.desktop.in.in deleted file mode 100644 index 9ec12b4d7..000000000 --- a/capplets/desktop-links/cd.desktop.in.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=CD Properties -_Comment=Configure handling of CD devices -Icon=cd-capplet.png -Exec=cd-capplet -Terminal=0 -Type=Application diff --git a/capplets/desktop-links/legacy-applications-capplet.png b/capplets/desktop-links/legacy-applications-capplet.png Binary files differdeleted file mode 100644 index 05182e6ca..000000000 --- a/capplets/desktop-links/legacy-applications-capplet.png +++ /dev/null diff --git a/capplets/desktop-links/legacy-applications.desktop.in.in b/capplets/desktop-links/legacy-applications.desktop.in.in deleted file mode 100644 index aebf6a823..000000000 --- a/capplets/desktop-links/legacy-applications.desktop.in.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=Legacy Applications -_Comment=Legacy applications settings (grdb) -Exec=grdb-capplet -Terminal=0 -Type=Application -Icon=legacy-applications-capplet.png diff --git a/capplets/desktop-links/panel-capplet.png b/capplets/desktop-links/panel-capplet.png Binary files differdeleted file mode 100644 index 592bf308c..000000000 --- a/capplets/desktop-links/panel-capplet.png +++ /dev/null diff --git a/capplets/desktop-links/panel.desktop.in.in b/capplets/desktop-links/panel.desktop.in.in deleted file mode 100644 index 710954d33..000000000 --- a/capplets/desktop-links/panel.desktop.in.in +++ /dev/null @@ -1,8 +0,0 @@ -[Desktop Entry] -_Name=Panel -_Comment=Global panel properties -Exec=gnome-panel-properties-capplet -Icon=panel-capplet.png -Terminal=0 -Type=Application -DocPath=panel/globalpanelprefs.html diff --git a/capplets/desktop-links/session-capplet.png b/capplets/desktop-links/session-capplet.png Binary files differdeleted file mode 100644 index 6ecc32126..000000000 --- a/capplets/desktop-links/session-capplet.png +++ /dev/null diff --git a/capplets/desktop-links/session.desktop.in.in b/capplets/desktop-links/session.desktop.in.in deleted file mode 100644 index 6b99d53eb..000000000 --- a/capplets/desktop-links/session.desktop.in.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=Startup Programs -_Comment=Configure which non-session aware programs are started up -Exec=session-properties-capplet -Icon=session-capplet.png -Terminal=0 -Type=Application diff --git a/capplets/file-types/.cvsignore b/capplets/file-types/.cvsignore deleted file mode 100644 index 5c172d723..000000000 --- a/capplets/file-types/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -Makefile -Makefile.in -.deps -.libs -file-types-capplet -file-types.desktop -file-types.desktop.in diff --git a/capplets/file-types/ChangeLog b/capplets/file-types/ChangeLog deleted file mode 100644 index 9cf1976c7..000000000 --- a/capplets/file-types/ChangeLog +++ /dev/null @@ -1,19 +0,0 @@ -2001-07-27 Bradford Hovinen <hovinen@ximian.com> - - * RELEASE : 1.5.2 - -2001-07-24 Chema Celorio <chema@celorio.com> - - * file-types-capplet.c (create_mime_list_and_scroller): add a usize - the GUI sucks, we need to revisit the gui SOON ! - -2001-07-22 Zbigniew Chyla <cyba@gnome.pl> - - * file-types.desktop.in.in: - s/Name/_Name/ - s/Comment/_Comment/ - -2001-07-20 Chema Celorio <chema@celorio.com> - - * RELEASE : 1.5.0 - diff --git a/capplets/file-types/Makefile.am b/capplets/file-types/Makefile.am deleted file mode 100644 index 610c4183f..000000000 --- a/capplets/file-types/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -SUBDIRS = libuuid - -cappletname = file-types -cappletgroup = "Advanced/" -bin_PROGRAMS = file-types-capplet - -file_types_capplet_LDADD = $(VFS_CAPPLET_LIBS) libuuid/libuuid.a - -file_types_capplet_SOURCES = \ - file-types-capplet.h \ - file-types-capplet-dialogs.h \ - file-types-icon-entry.h \ - file-types-capplet.c \ - file-types-capplet-dialogs.c \ - file-types-icon-entry.c - -pixmap_DATA = - -## -## You should not need to modify anything below this line -## -@XML_I18N_MERGE_DESKTOP_RULE@ -@GNOMECC_CAPPLETS_DESKTOP_IN_RULE@ - -INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS) $(VFS_CAPPLET_CFLAGS) -CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) -EXTRA_DIST = $(GNOMECC_CAPPLETS_EXTRA_DIST) -iconsdir = $(GNOMECC_ICONS_DIR) -Gladedir = $(GNOMECC_GLADE_DIR) -pixmapdir = $(GNOMECC_PIXMAPS_DIR) -Glade_DATA = $(cappletname)-properties.glade -icons_DATA = $(cappletname)-capplet.png -desktop = $(cappletname).desktop -all-local: $(desktop) diff --git a/capplets/file-types/file-types-capplet-dialogs.c b/capplets/file-types/file-types-capplet-dialogs.c deleted file mode 100644 index 34dbe81d3..000000000 --- a/capplets/file-types/file-types-capplet-dialogs.c +++ /dev/null @@ -1,1429 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-mime-type-capplet-dialog.c - * - * Copyright (C) 2000 Eazel, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: Jonathan Blandford <jrb@redhat.com> - * Gene Z. Ragan <gzr@eazel.com> - */ - -#include <config.h> - -#include <capplet-widget.h> -#include <ctype.h> -#include <gnome.h> -#include <gtk/gtk.h> -#include <gtk/gtklist.h> -#include <gtk/gtkbin.h> -#include <gtk/gtklistitem.h> -#include <libgnomevfs/gnome-vfs-mime-handlers.h> -#include <libgnomevfs/gnome-vfs-application-registry.h> -#include <libgnomevfs/gnome-vfs-mime-info.h> -#include <libgnomevfs/gnome-vfs-utils.h> - -#include "libuuid/uuid.h" -#include "file-types-capplet.h" -#include "file-types-capplet-dialogs.h" - -/* gtk_window_set_default_width (and some other functions) use a - * magic undocumented number of -2 to mean "ignore this parameter". - */ -#define NO_DEFAULT_MAGIC_NUMBER -2 - -/* Scrolling list has no idea how tall to make itself. Its - * "natural height" is just enough to draw the scroll bar controls. - * Hardwire an initial window size here, but let user resize - * bigger or smaller. - */ -#define PROGRAM_CHOOSER_DEFAULT_HEIGHT 280 - - -typedef struct { - GtkWidget *window; - GtkWidget *preferred_list; - GtkWidget *default_list; -} edit_dialog_details; - - -/* Global variables */ -static edit_dialog_details *edit_application_details = NULL; -static edit_dialog_details *edit_component_details = NULL; - -/* Local prototypes */ -static void show_new_application_window (GtkWidget *button, GtkWidget *list); -static void show_edit_application_window (GtkWidget *button, GtkWidget *list); -static void delete_selected_application (GtkWidget *button, GtkWidget *list); -static void add_item_to_application_list (GtkWidget *list, const char *id, const char *name, const char *mime_type, - gboolean user_owned, int position); -static void find_message_label_callback (GtkWidget *widget, gpointer callback_data); -static void find_message_label (GtkWidget *widget, const char *message); - - -static void -edit_applications_dialog_destroy (GtkWidget *widget, gpointer data) -{ - g_free (edit_application_details); - edit_application_details = NULL; -} - -static void -edit_component_dialog_destroy (GtkWidget *widget, gpointer data) -{ - g_free (edit_component_details); - edit_component_details = NULL; -} - -static gboolean -application_is_in_list (const char *search_id, GList *application_list) -{ - GList *list_element; - GnomeVFSMimeApplication *application; - - if (application_list == NULL || search_id == NULL) { - return FALSE; - } - - /* Traverse the list looking for a match */ - for (list_element = application_list; list_element != NULL; list_element = list_element->next) { - application = list_element->data; - - if (strcmp (search_id, application->id) == 0) { - return TRUE; - } - } - - return FALSE; -} - - -/* - * application_button_toggled_callback - * - * Check state of button. Based on state, determine whether to add or remove - * application from short list. - */ -static void -application_button_toggled_callback (GtkToggleButton *button, gpointer user_data) -{ - const char *id; - const char *mime_type; - - id = gtk_object_get_data (GTK_OBJECT (button), "application_id"); - mime_type = gtk_object_get_data (GTK_OBJECT (button), "mime_type"); - - if (id == NULL || mime_type == NULL) { - return; - } - - if (gtk_toggle_button_get_active (button)) { - /* Add to preferred list */ - gnome_vfs_mime_add_application_to_short_list (mime_type, id); - - } else { - /* Remove from preferred list */ - gnome_vfs_mime_remove_application_from_short_list (mime_type, id); - } -} - -static void -insert_item (GtkList *list_widget, GtkListItem *item, int position) -{ - GList *singleton_list; - - g_assert (GTK_IS_LIST (list_widget)); - g_assert (GTK_IS_LIST_ITEM (item)); - - /* Due to GTK inheritance stupidity, the "Add" signal, which we - * rely on for widget sensitivity updates, is not sent if you - * use the GtkList API to add items. So when we add new items, - * which always go at the end, we must use the GtkContainer API. - */ - if (position < 0) { - gtk_container_add (GTK_CONTAINER (list_widget), GTK_WIDGET (item)); - } else { - singleton_list = g_list_prepend (NULL, item); - gtk_list_insert_items (list_widget, singleton_list, position); - /* This looks like a leak of a singleton_list, but believe it or not - * gtk_list takes ownership of the list of items. - */ - } -} - -static GtkListItem * -create_application_list_item (const char *id, const char *name, const char *mime_type, - gboolean user_owned, GList *short_list) -{ - GtkWidget *list_item; - GtkWidget *hbox, *check_button, *label; - - list_item = gtk_list_item_new (); - - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (list_item), hbox); - - check_button = gtk_check_button_new (); - gtk_box_pack_start (GTK_BOX (hbox), check_button, FALSE, FALSE, 0); - - label = gtk_label_new (name); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - gtk_widget_show_all (list_item); - - /* Save ID and mime type*/ - gtk_object_set_data_full (GTK_OBJECT (check_button), "application_id", g_strdup (id), g_free); - gtk_object_set_data_full (GTK_OBJECT (check_button), "mime_type", g_strdup (mime_type), g_free); - gtk_object_set_data_full (GTK_OBJECT (list_item), "application_id", g_strdup (id), g_free); - gtk_object_set_data_full (GTK_OBJECT (list_item), "mime_type", g_strdup (mime_type), g_free); - gtk_object_set_data (GTK_OBJECT (list_item), "user_owned", GINT_TO_POINTER(user_owned)); - - /* Check and see if component is in preferred list */ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), - application_is_in_list (id, short_list)); - - /* Connect to toggled signal */ - gtk_signal_connect (GTK_OBJECT (check_button), "toggled", - GTK_SIGNAL_FUNC (application_button_toggled_callback), NULL); - - return GTK_LIST_ITEM (list_item); -} - -static void -populate_default_applications_list (GtkWidget *list, const char *mime_type) -{ - GList *short_list, *app_list, *list_element; - GnomeVFSMimeApplication *application; - GtkListItem *list_item; - - /* Get the application short list */ - short_list = gnome_vfs_mime_get_short_list_applications (mime_type); - - /* Get the list of all applications */ - app_list = gnome_vfs_mime_get_all_applications (mime_type); - if (app_list != NULL) { - for (list_element = app_list; list_element != NULL; list_element = list_element->next) { - application = list_element->data; - - /* Create list item */ - list_item = create_application_list_item (application->id, application->name, - mime_type, - gnome_vfs_application_is_user_owned_application (application), - short_list); - - insert_item (GTK_LIST (list), list_item, -1); - - } - - gnome_vfs_mime_application_list_free (app_list); - - } - - gnome_vfs_mime_application_list_free (short_list); -} - - -static gboolean -component_is_in_list (const char *search_name, GList *component_list) -{ - GList *list_element; - OAF_ServerInfo *info; - gchar *component_name; - - if (component_list == NULL || search_name == NULL) { - return FALSE; - } - - /* Traverse the list looking for a match */ - for (list_element = component_list; list_element != NULL; list_element = list_element->next) { - info = list_element->data; - - component_name = name_from_oaf_server_info (info); - - if (strcmp (search_name, component_name) == 0) { - g_free (component_name); - return TRUE; - } - g_free (component_name); - } - - return FALSE; -} - -/* - * component_button_toggled_callback - * - * Check state of button. Based on state, determine whether to add or remove - * component from short list. - */ -static void -component_button_toggled_callback (GtkToggleButton *button, gpointer user_data) -{ - const char *iid; - const char *mime_type; - - iid = gtk_object_get_data (GTK_OBJECT (button), "component_iid"); - mime_type = gtk_object_get_data (GTK_OBJECT (button), "mime_type"); - - if (iid == NULL || mime_type == NULL) { - return; - } - - if (gtk_toggle_button_get_active (button)) { - /* Add to preferred list */ - gnome_vfs_mime_add_component_to_short_list (mime_type, iid); - - } else { - /* Remove from preferred list */ - gnome_vfs_mime_remove_component_from_short_list (mime_type, iid); - } -} - - -static void -populate_default_components_box (GtkWidget *box, const char *mime_type) -{ - GList *short_component_list; - GList *all_component_list, *list_element; - OAF_ServerInfo *info; - gchar *component_name; - GtkWidget *button; - - /* Get short list of components */ - short_component_list = gnome_vfs_mime_get_short_list_components (mime_type); - - /* Get list of all components */ - all_component_list = gnome_vfs_mime_get_all_components (mime_type); - if (all_component_list != NULL) { - for (list_element = all_component_list; list_element != NULL; list_element = list_element->next) { - info = list_element->data; - - component_name = name_from_oaf_server_info (info); - button = gtk_check_button_new_with_label (component_name); - gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0); - - /* Save IID and mime type*/ - gtk_object_set_data_full (GTK_OBJECT (button), "component_iid", g_strdup (info->iid), g_free); - gtk_object_set_data_full (GTK_OBJECT (button), "mime_type", g_strdup (mime_type), g_free); - - /* Check and see if component is in preferred list */ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), - component_is_in_list (component_name, short_component_list)); - - /* Connect to toggled signal */ - gtk_signal_connect (GTK_OBJECT (button), "toggled", - GTK_SIGNAL_FUNC (component_button_toggled_callback), NULL); - - g_free (component_name); - } - gnome_vfs_mime_component_list_free (all_component_list); - - if (short_component_list != NULL) { - gnome_vfs_mime_component_list_free (short_component_list); - } - } -} - - - typedef struct { - GtkWidget *add_button; - GtkWidget *edit_button; - GtkWidget *delete_button; - } ButtonHolder; - - -static void -check_button_status (GtkList *list, GtkWidget *widget, ButtonHolder *button_holder) -{ - int length = g_list_length (list->children); - - if (length == 0) { - gtk_widget_set_sensitive (button_holder->delete_button, FALSE); - gtk_widget_set_sensitive (button_holder->edit_button, FALSE); - } else { - gtk_widget_set_sensitive (button_holder->edit_button, TRUE); - } -} - -static void -update_delete_button (GtkList *list, GtkWidget *widget, ButtonHolder *button_holder) -{ - gtk_widget_set_sensitive (button_holder->delete_button, - GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), "user_owned"))); -} - - -/* - * initialize_edit_applications_dialog - * - * Set up dialog for default application list editing - */ - -static void -initialize_edit_applications_dialog (const char *mime_type) -{ - GtkWidget *main_vbox, *hbox; - GtkWidget *scroller, *label; - GtkWidget *button, *list; - char *label_text; - ButtonHolder *button_holder; - - edit_application_details = g_new0 (edit_dialog_details, 1); - - edit_application_details->window = gnome_dialog_new (_("Edit Applications List"), - GNOME_STOCK_BUTTON_OK, - NULL, - NULL); - - /* FIXME: dialog should be parented on Control Center window */ - - gtk_container_set_border_width (GTK_CONTAINER (edit_application_details->window), GNOME_PAD); - gtk_window_set_policy (GTK_WINDOW (edit_application_details->window), FALSE, TRUE, FALSE); - gtk_window_set_default_size (GTK_WINDOW (edit_application_details->window), - NO_DEFAULT_MAGIC_NUMBER, - PROGRAM_CHOOSER_DEFAULT_HEIGHT); - - gtk_signal_connect (GTK_OBJECT (edit_application_details->window), - "destroy", - edit_applications_dialog_destroy, - NULL); - - /* Main vertical box */ - main_vbox = GNOME_DIALOG (edit_application_details->window)->vbox; - - /* Add label */ - label_text = g_strdup_printf (_("Select applications to appear in menu for MIME type \"%s\""), mime_type); - label = gtk_label_new (label_text); - g_free (label_text); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0); - - /* Add scrolling list of check buttons */ - scroller = gtk_scrolled_window_new (NULL, NULL); - gtk_box_pack_start_defaults (GTK_BOX (main_vbox), scroller); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroller), - GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); - - list = gtk_list_new (); - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroller), list); - gtk_list_set_selection_mode (GTK_LIST (list), GTK_SELECTION_BROWSE); - - /* Add edit buttons */ - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); - - button_holder = g_new (ButtonHolder, 1); - - button = gtk_button_new_with_label (_("Add Application...")); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - gtk_object_set_data_full (GTK_OBJECT (button), "mime_type", g_strdup (mime_type), g_free); - gtk_signal_connect (GTK_OBJECT (button), "clicked", show_new_application_window, list); - gtk_widget_set_sensitive (GTK_WIDGET (button), TRUE); - button_holder->add_button = button; - - button = gtk_button_new_with_label (_("Edit Application...")); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (button), "clicked", show_edit_application_window, list); - gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE); - button_holder->edit_button = button; - - button = gtk_button_new_with_label (_("Delete Application")); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (button), "clicked", delete_selected_application, list); - gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE); - button_holder->delete_button = button; - - /* Watch container so we can update buttons */ - gtk_signal_connect (GTK_OBJECT (list), "add", check_button_status, button_holder); - gtk_signal_connect_full (GTK_OBJECT (list), "remove", check_button_status, NULL, button_holder, - g_free, FALSE, FALSE); - gtk_signal_connect (GTK_OBJECT (list), "select_child", update_delete_button, button_holder); - - gtk_widget_show_all (main_vbox); - - populate_default_applications_list (list, mime_type); -} - - - -/* - * initialize_edit_components_dialog - * - * Set up dialog for default component list editing - */ - -static void -initialize_edit_components_dialog (const char *mime_type) -{ - GtkWidget *main_vbox, *vbox; - GtkWidget *scroller, *label; - char *label_text; - - edit_component_details = g_new0 (edit_dialog_details, 1); - - edit_component_details->window = gnome_dialog_new (_("Edit Components List"), - GNOME_STOCK_BUTTON_OK, - NULL, - NULL); - - gtk_container_set_border_width (GTK_CONTAINER (edit_component_details->window), GNOME_PAD); - gtk_window_set_policy (GTK_WINDOW (edit_component_details->window), FALSE, TRUE, FALSE); - gtk_window_set_default_size (GTK_WINDOW (edit_component_details->window), - NO_DEFAULT_MAGIC_NUMBER, - PROGRAM_CHOOSER_DEFAULT_HEIGHT); - - gtk_signal_connect (GTK_OBJECT (edit_component_details->window), - "destroy", - edit_component_dialog_destroy, - NULL); - - /* Main vertical box */ - main_vbox = GNOME_DIALOG (edit_component_details->window)->vbox; - - /* Add label */ - label_text = g_strdup_printf (_("Select views to appear in menu for MIME type \"%s\""), mime_type); - label = gtk_label_new (label_text); - g_free (label_text); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0); - - /* Add scrolling list of check buttons */ - scroller = gtk_scrolled_window_new (NULL, NULL); - gtk_box_pack_start_defaults (GTK_BOX (main_vbox), scroller); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroller), - GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); - - vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroller), vbox); - - populate_default_components_box (vbox, mime_type); - - gtk_widget_show_all (main_vbox); -} - - -/* - * show_edit_applications_dialog - * - * Setup and display edit application list dialog - */ - -void -show_edit_applications_dialog (const char *mime_type) -{ - if (edit_application_details == NULL) { - initialize_edit_applications_dialog (mime_type); - } - - /* FIXME: This is a modal dialog with no Cancel button, so the close box - * has to do the same thing as the OK button, which is pretty darn confusing. - * It would be better to make it modeless someday. - */ - gnome_dialog_run_and_close (GNOME_DIALOG (edit_application_details->window)); - nautilus_mime_type_capplet_update_application_info (mime_type); -} - - -/* - * show_edit_components_dialog - * - * Setup and display edit component list dialog - */ - -void -show_edit_components_dialog (const char *mime_type) -{ - if (edit_component_details == NULL) { - initialize_edit_components_dialog (mime_type); - } - - /* FIXME: This is a modal dialog with no Cancel button, so the close box - * has to do the same thing as the OK button, which is pretty darn confusing. - * It would be better to make it modeless someday. - */ - gnome_dialog_run_and_close (GNOME_DIALOG (edit_component_details->window)); - - nautilus_mime_type_capplet_update_viewer_info (mime_type); -} - - -static GSList * -get_lang_list (void) -{ - GSList *retval; - char *lang; - char * equal_char; - - retval = NULL; - - lang = g_getenv ("LANGUAGE"); - - if (!lang) { - lang = g_getenv ("LANG"); - } - - - if (lang) { - equal_char = strchr (lang, '='); - if (equal_char != NULL) { - lang = equal_char + 1; - } - - retval = g_slist_prepend (retval, lang); - } - - return retval; -} - -static gboolean -str_has_prefix (const char *haystack, const char *needle) -{ - const char *h, *n; - - /* Eat one character at a time. */ - h = haystack == NULL ? "" : haystack; - n = needle == NULL ? "" : needle; - do { - if (*n == '\0') { - return TRUE; - } - if (*h == '\0') { - return FALSE; - } - } while (*h++ == *n++); - return FALSE; -} - -char * -name_from_oaf_server_info (OAF_ServerInfo *server) -{ - const char *view_as_name; - char *display_name; - GSList *langs; - - display_name = NULL; - - langs = get_lang_list (); - view_as_name = oaf_server_info_prop_lookup (server, "nautilus:view_as_name", langs); - - if (view_as_name == NULL) { - view_as_name = oaf_server_info_prop_lookup (server, "name", langs); - } - - if (view_as_name == NULL) { - view_as_name = server->iid; - } - - g_slist_free (langs); - - /* if the name is an OAFIID, clean it up for display */ - if (str_has_prefix (view_as_name, "OAFIID:")) { - char *display_name, *colon_ptr; - display_name = g_strdup (view_as_name + 7); - colon_ptr = strchr (display_name, ':'); - if (colon_ptr) { - *colon_ptr = '\0'; - } - return display_name; - } - - - return g_strdup(view_as_name); -} - - -static void -find_message_label_callback (GtkWidget *widget, gpointer callback_data) -{ - find_message_label (widget, callback_data); -} - -static void -find_message_label (GtkWidget *widget, const char *message) -{ - char *text; - - /* Turn on the flag if we find a label with the message - * in it. - */ - if (GTK_IS_LABEL (widget)) { - gtk_label_get (GTK_LABEL (widget), &text); - if (strcmp (text, message) == 0) { - gtk_object_set_data (GTK_OBJECT (gtk_widget_get_toplevel (widget)), - "message label", widget); - } - } - - /* Recurse for children. */ - if (GTK_IS_CONTAINER (widget)) { - gtk_container_foreach (GTK_CONTAINER (widget), - find_message_label_callback, - (char *) message); - } -} - -static GnomeDialog * -show_message_box (const char *message, - const char *dialog_title, - const char *type, - const char *button_one, - const char *button_two, - GtkWindow *parent) -{ - GtkWidget *box; - GtkLabel *message_label; - - g_assert (dialog_title != NULL); - - box = gnome_message_box_new (message, type, button_one, button_two, NULL); - gtk_window_set_title (GTK_WINDOW (box), dialog_title); - - /* A bit of a hack. We want to use gnome_message_box_new, - * but we want the message to be wrapped. So, we search - * for the label with this message so we can mark it. - */ - find_message_label (box, message); - message_label = GTK_LABEL (gtk_object_get_data (GTK_OBJECT (box), "message label")); - gtk_label_set_line_wrap (message_label, TRUE); - - if (parent != NULL) { - gnome_dialog_set_parent (GNOME_DIALOG (box), parent); - } - gtk_widget_show (box); - return GNOME_DIALOG (box); -} - -static void -display_upper_case_dialog (void) -{ - char *message; - GnomeDialog *dialog; - - message = _("The MIME type entered contained upper case characters. " - "Upper case characters were changed to lower case for you."); - - dialog = show_message_box (message, _("Add New MIME Type"), - GNOME_MESSAGE_BOX_INFO, GNOME_STOCK_BUTTON_OK, - NULL, NULL); - - gnome_dialog_run_and_close (dialog); -} - -/* Do some basic validation of the text entry and enable the OK button if the text is - * determined to be a valid string. - */ -static void -validate_text_and_update_button (GtkEntry *entry, gpointer data) -{ - char *text, *token; - gboolean sensitize; - - sensitize = TRUE; - - text = gtk_entry_get_text (entry); - if (text == NULL) { - sensitize = FALSE; - } else { - token = strtok (text, " "); - if (token == NULL || strlen (token) <= 0) { - /* Entered text is invalid as best as we can detect. */ - sensitize = FALSE; - } - } - - gtk_widget_set_sensitive (GTK_WIDGET (data), sensitize); -} - -char * -nautilus_mime_type_capplet_show_new_mime_window (void) -{ - GtkWidget *dialog; - GtkWidget *mime_entry; - GtkWidget *label; - GtkWidget *desc_entry; - const char *description; - char *mime_type, *tmp_str, c; - gboolean upper_case_alert; - - mime_type = NULL; - upper_case_alert = FALSE; - - dialog = gnome_dialog_new (_("Add MIME Type"), GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, NULL); - gnome_dialog_set_default (GNOME_DIALOG (dialog), 1); - - label = gtk_label_new (_("New MIME type (e.g. image/x-thumper):")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label, TRUE, TRUE, 0); - - mime_entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), mime_entry, TRUE, TRUE, 0); - - label = gtk_label_new (_("Description (e.g. Thumper image):")); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label, TRUE, TRUE, 0); - - desc_entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), desc_entry, TRUE, TRUE, 0); - - /* Set up text entry validation signal */ - gtk_signal_connect (GTK_OBJECT (mime_entry), "changed", - GTK_SIGNAL_FUNC (validate_text_and_update_button), GNOME_DIALOG (dialog)->buttons->data); - - /* Set initial OK button state to desensitized */ - gtk_widget_set_sensitive (GTK_WIDGET (GNOME_DIALOG (dialog)->buttons->data), FALSE); - - /* Set focus to text entry widget */ - gtk_widget_grab_focus (mime_entry); - - gtk_widget_show_all (GNOME_DIALOG (dialog)->vbox); - - if (gnome_dialog_run (GNOME_DIALOG (dialog)) == GNOME_OK) { - mime_type = g_strdup (gtk_entry_get_text (GTK_ENTRY (mime_entry))); - g_assert (mime_type != NULL); - - /* Handle illegal mime types as best we can */ - for (tmp_str = mime_type; (c = *tmp_str) != '\0'; tmp_str++) { - if (isascii ((guchar) c) && isupper ((guchar) c)) { - *tmp_str = tolower (c); - upper_case_alert = TRUE; - } - } - - description = gtk_entry_get_text (GTK_ENTRY (desc_entry)); - - /* Add new mime type here */ - if (strlen (mime_type) > 3) { - /* This call creates the key */ - gnome_vfs_mime_set_registered_type_key (mime_type, - "description", - description); - - /* Ths call sets the user information */ - gnome_vfs_mime_set_value (mime_type, - "description", - description); - } - } - - gnome_dialog_close (GNOME_DIALOG (dialog)); - - if (upper_case_alert) { - display_upper_case_dialog (); - } - - return mime_type; -} - -static void -add_extension_clicked (GtkWidget *widget, gpointer data) -{ - GtkList *extension_list; - char *new_extension; - GtkWidget *new_list_item; - GList *items_list; - - g_assert (GTK_IS_LIST (data)); - - extension_list = GTK_LIST (data); - - new_extension = nautilus_mime_type_capplet_show_new_extension_window (); - - /* Filter out bogus extensions */ - if (new_extension == NULL || strlen (new_extension) <= 0 || new_extension[0] == ' ') { - g_free (new_extension); - return; - } - - new_list_item = gtk_list_item_new_with_label (new_extension); - gtk_widget_show (new_list_item); - - items_list = g_list_append (NULL, new_list_item); - gtk_list_append_items (GTK_LIST (extension_list), items_list); - g_free (new_extension); - /* GtkList takes ownership of the List we append. DO NOT free it. */ -} - -static void -remove_extension_clicked (GtkWidget *widget, gpointer data) -{ - GtkList *list; - GList *selection_copy, *temp; - - g_assert (GTK_IS_LIST (data)); - - list = GTK_LIST (data); - - /* this is so fucking crapy !!! */ - /* you have to make a copy of the selection list before - passing it to remove_items because before removing the - widget from the List, it modifies the list. - So, when you remove it, the list is not valid anymore */ - selection_copy = NULL; - for (temp = list->selection; temp != NULL; temp = temp->next) { - selection_copy = g_list_prepend (selection_copy, temp->data); - } - - if (list->selection != NULL) { - gtk_list_remove_items (GTK_LIST (list), selection_copy); - gtk_list_select_item (GTK_LIST (list), 0); - } - - g_list_free (selection_copy); -} - -static void -extension_list_selected (GtkWidget *list, GtkWidget *child, gpointer data) -{ - GtkWidget *button; - - g_assert (GTK_IS_BUTTON (data)); - - button = GTK_WIDGET (data); - - gtk_widget_set_sensitive (GTK_WIDGET (button), TRUE); -} - -static void -extension_list_deselected (GtkWidget *list, GtkWidget *child, gpointer data) -{ - GtkWidget *button; - - g_assert (GTK_IS_BUTTON (data)); - - button = GTK_WIDGET (data); - - gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE); -} - -static char * -get_extensions_from_gtk_list (GtkList *list) -{ - GList *temp; - GtkLabel *label; - char *extension, *extensions, *temp_text; - - extensions = NULL; - for (temp = list->children; temp != NULL; temp = temp->next) { - label = GTK_LABEL (GTK_BIN (temp->data)->child); - gtk_label_get (GTK_LABEL (label), &extension); - temp_text = g_strconcat (extension, " ", extensions, NULL); - g_free (extensions); - extensions = temp_text; - } - - return extensions; -} - -char * -nautilus_mime_type_capplet_show_change_extension_window (const char *mime_type, gboolean *new_list) -{ - GtkWidget *dialog; - GtkWidget *hbox; - GtkWidget *button; - GtkWidget *list; - char *extensions_list_str; - - *new_list = FALSE; - - dialog = gnome_dialog_new (_("File Extensions "), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, - NULL); - gnome_dialog_set_default (GNOME_DIALOG (dialog), 1); - gnome_dialog_set_close (GNOME_DIALOG (dialog), FALSE); - - hbox = gtk_hbox_new (FALSE, GNOME_PAD_BIG); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0); - - - list = gtk_list_new (); - - /* the right buttons */ - { - GtkWidget *vbox; - - vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_end (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); - - button = gtk_button_new_with_label (_("Add...")); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - add_extension_clicked, list); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - - button = gtk_button_new_with_label (_(" Remove ")); - gtk_widget_set_sensitive (button, FALSE); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - remove_extension_clicked, list); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new (""), FALSE, FALSE, 0); - } - - /* The left list */ - { - GtkWidget *viewport; - GList *extensions_list, *widget_list, *temp; - - viewport = gtk_viewport_new (NULL, NULL); - gtk_box_pack_start (GTK_BOX (hbox), viewport, TRUE, TRUE, 0); - - gtk_signal_connect (GTK_OBJECT (list), "select_child", - extension_list_selected, button); - gtk_signal_connect (GTK_OBJECT (list), "unselect_child", - extension_list_deselected, button); - gtk_list_set_selection_mode (GTK_LIST (list), GTK_SELECTION_SINGLE); - gtk_container_add (GTK_CONTAINER (viewport), list); - - - extensions_list = gnome_vfs_mime_get_extensions_list (mime_type); - if (extensions_list != NULL) { - widget_list = NULL; - for (temp = extensions_list; temp != NULL; temp = temp->next) { - widget_list = g_list_append (widget_list, - gtk_list_item_new_with_label ((char *) temp->data)); - } - gtk_list_append_items (GTK_LIST (list), widget_list); - } - - gtk_list_select_item (GTK_LIST (list), 0); - } - - - - gtk_widget_show_all (GNOME_DIALOG (dialog)->vbox); - - extensions_list_str = NULL; - if (gnome_dialog_run (GNOME_DIALOG (dialog)) == GNOME_OK) { - *new_list = TRUE; - extensions_list_str = get_extensions_from_gtk_list (GTK_LIST (list)); - if (extensions_list_str == NULL) { - extensions_list_str = g_strdup (""); - } - } - if (extensions_list_str == NULL) { - extensions_list_str = g_strdup (""); - } - gnome_dialog_close (GNOME_DIALOG (dialog)); - - - return extensions_list_str; -} - - -char * -nautilus_mime_type_capplet_show_new_extension_window (void) -{ - GtkWidget *mime_entry; - GtkWidget *label; - GtkWidget *hbox; - GtkWidget *dialog; - char *new_extension; - - dialog = gnome_dialog_new (_("Add New Extension"), GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, NULL); - gnome_dialog_set_default (GNOME_DIALOG (dialog), 0); - gnome_dialog_set_close (GNOME_DIALOG (dialog), FALSE); - label = gtk_label_new (_("Type in the extensions for this mime-type (without dot).\n" - "You can enter several extensions seperated by a space,\n" - "for example: html htm")); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0); - label = gtk_label_new (_("Extension:")); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - mime_entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (hbox), mime_entry, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0); - - gtk_widget_show_all (GNOME_DIALOG (dialog)->vbox); - - /* Set focus to text entry widget */ - gtk_widget_grab_focus (mime_entry); - - if (gnome_dialog_run (GNOME_DIALOG (dialog)) == GNOME_OK) { - new_extension = g_strdup (gtk_entry_get_text (GTK_ENTRY (mime_entry))); - } else { - new_extension = g_strdup (""); - } - - gnome_dialog_close (GNOME_DIALOG (dialog)); - - return new_extension; -} - -/* add_or_update_application - * - * Create or update a GnomeVFSMimeApplication and register - * it with the mime database. - */ -static char * -add_or_update_application (GtkWidget *list, const char *name, const char *command, - gboolean multiple, gboolean expects_uris, - gboolean update) -{ - GnomeVFSMimeApplication app, *original; - const char *mime_type; - uuid_t app_uuid; - char app_uuid_string[100]; - - /* Check for empty strings. Command can be empty. */ - if (name[0] == '\0') { - return NULL; - } - - mime_type = nautilus_mime_type_capplet_get_selected_item_mime_type (); - g_assert (mime_type != NULL); - - /* It's ok to cast, we don't modify the application - * structure and thus the name/command, this should really - * use the application registry explicitly */ - - /* Generate unique application id */ - uuid_generate(app_uuid); - uuid_unparse(app_uuid, app_uuid_string); - app.id = app_uuid_string; - app.name = (char *)name; - app.command = (char *)command; - app.can_open_multiple_files = multiple; - app.expects_uris = expects_uris; - /* FIXME: We should be getting this information */ - app.supported_uri_schemes = NULL; - app.requires_terminal = FALSE; - - if (update) { - original = gnome_vfs_mime_application_new_from_id (app.id); - if (original == NULL) { - const char *original_id; - GList *selection; - GtkListItem *item; - int position; - - /* If there isn't a selection we cannot allow an edit */ - selection = GTK_LIST (list)->selection; - if (selection == NULL || g_list_length (selection) <= 0) { - return NULL; - } - - /* Get application id and info */ - item = GTK_LIST_ITEM (selection->data); - if (item == NULL) { - return NULL; - } - - original_id = gtk_object_get_data (GTK_OBJECT (item), "application_id"); - if (original_id == NULL) { - return NULL; - } - - /* Remove original application data */ - gnome_vfs_application_registry_remove_mime_type (original_id, mime_type); - gnome_vfs_application_registry_sync (); - gnome_vfs_mime_remove_application_from_short_list (mime_type, original_id); - - /* Remove widget from list */ - position = gtk_list_child_position (GTK_LIST (list), GTK_WIDGET (item)); - gtk_container_remove (GTK_CONTAINER (list), GTK_WIDGET (item)); - - /* Add new widget and restore position */ - add_item_to_application_list (list, original_id, name, mime_type, - gnome_vfs_application_is_user_owned_application (original), - position); - } - } - - gnome_vfs_application_registry_save_mime_application (&app); - gnome_vfs_application_registry_add_mime_type (app.id, mime_type); - gnome_vfs_application_registry_sync (); - - gnome_vfs_mime_add_application_to_short_list (mime_type, app.id); - - return g_strdup (app.id); -} - -static void -add_item_to_application_list (GtkWidget *list, const char *id, const char *name, const char *mime_type, - gboolean user_owned, int position) -{ - GtkListItem *list_item; - GList *short_list; - - short_list = gnome_vfs_mime_get_short_list_applications (mime_type); - list_item = create_application_list_item (id, name, mime_type, user_owned, short_list); - gnome_vfs_mime_application_list_free (short_list); - - insert_item (GTK_LIST (list), list_item, position); - gtk_list_select_child (GTK_LIST (list), GTK_WIDGET (list_item)); -} - -static gboolean -handle_invalid_application_input (GtkWindow *parent_window, const char *name, const char *command) -{ - char *message; - char *stripped_name; - GnomeDialog *error_dialog; - gboolean error_in_name; - - message = NULL; - error_in_name = FALSE; - - stripped_name = g_strstrip (g_strdup (name)); - - if (strlen (stripped_name) == 0) { - message = g_strdup (_("You must enter a name.")); - error_in_name = TRUE; - } else if (strlen (command) == 0) { - message = g_strdup (_("You must enter a command.")); - } else if (!gnome_vfs_is_executable_command_string (command)) { - if (command[0] == '/') { - /* FIXME: Should strip parameters off before using in this message. */ - /* FIXME: Should use separate messages for doesn't exist/isn't executable. */ - /* Both of these FIXMEs would need to handle quoting to work correctly, - * since otherwise a space might be part of path or separator before parameters. - */ - /* FIXME: Should use some line-wrapping technology a la nautilus-stock-dialogs.c */ - message = g_strdup_printf - (_("\"%s\" does not exist or is not executable.\n" - "Check your spelling and make sure you have\n" - "the right permissions to execute this file."), command); - } else { - /* FIXME: Should strip parameters off before using in this message */ - message = g_strdup_printf - (_("The command \"%s\" cannot be found.\n" - "You must use a command that can work from any command line."), command); - } - } - - g_free (stripped_name); - - if (message != NULL) { - error_dialog = GNOME_DIALOG (gnome_error_dialog_parented (message, - parent_window)); - gtk_window_set_title (GTK_WINDOW (error_dialog), - error_in_name - ? _("Bad Application Name") - : _("Bad Application Command")); - - gnome_dialog_run (error_dialog); - g_free (message); - - return TRUE; - } - - return FALSE; -} - -static void -run_edit_or_new_application_dialog (const char *mime_type, GtkWidget *list, GnomeVFSMimeApplication *application) -{ - GtkWidget *dialog; - GtkWidget *app_entry, *command_entry; - GtkWidget *label; - GtkWidget *behavior_frame, *frame_vbox; - GtkWidget *multiple_check_box, *uri_check_box; - GtkWidget *table; - gboolean initial_toggle_state; - const char *name; - const char *command; - int dialog_result; - gboolean entry_validated; - char *invalid_entry_message, *app_id; - - g_assert (mime_type != NULL || application != NULL); - g_assert (GTK_IS_WIDGET (list)); - - dialog = gnome_dialog_new ( - application == NULL - ? _("Add Application") - : _("Edit Application"), - GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); - - /* FIXME: Dialog should be parented on Edit Applications dialog */ - - /* Create table */ - table = gtk_table_new (4, 2, FALSE); - gtk_container_add (GTK_CONTAINER (GNOME_DIALOG (dialog)->vbox), table); - gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL); - gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL); - - /* Application Name label and entry */ - label = gtk_label_new (_("Application Name:")); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1); - - app_entry = gtk_entry_new (); - gtk_table_attach_defaults ( GTK_TABLE (table), app_entry, 1, 2, 0, 1); - if (application != NULL) { - gtk_entry_set_text (GTK_ENTRY (app_entry), application->name); - } - - /* Application Command label and entry */ - label = gtk_label_new (_("Application Command:")); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2); - - command_entry = gtk_entry_new (); - gtk_table_attach_defaults (GTK_TABLE (table), command_entry, 1, 2, 1, 2); - if (application != NULL) { - gtk_entry_set_text (GTK_ENTRY (command_entry), application->command); - } - - /* Open Behavior frame */ - behavior_frame = gtk_frame_new (_("Open Behavior")); - gtk_table_attach_defaults ( GTK_TABLE (table), behavior_frame, 0, 2, 2, 3); - - frame_vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (behavior_frame), frame_vbox); - - multiple_check_box = gtk_check_button_new_with_label (_("Can open multiple files")); - gtk_box_pack_start (GTK_BOX (frame_vbox), multiple_check_box, FALSE, FALSE, 0); - initial_toggle_state = application == NULL - ? FALSE - : application->can_open_multiple_files; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (multiple_check_box), initial_toggle_state); - - /* FIXME bugzilla.eazel.com 6066: This needs to be three options now: "yes", "no", and "use uris for non-file locations" */ - uri_check_box = gtk_check_button_new_with_label (_("Can open from URI")); - gtk_box_pack_start (GTK_BOX (frame_vbox), uri_check_box, FALSE, FALSE, 0); - initial_toggle_state = application == NULL - ? FALSE - : application->expects_uris; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (uri_check_box), initial_toggle_state); - - - gtk_widget_show_all (GNOME_DIALOG (dialog)->vbox); - - /* Set focus to text entry widget */ - gtk_widget_grab_focus (app_entry); - - do { - dialog_result = gnome_dialog_run (GNOME_DIALOG (dialog)); - entry_validated = FALSE; - - if (dialog_result == GNOME_OK) { - name = gtk_entry_get_text (GTK_ENTRY (app_entry)); - command = gtk_entry_get_text (GTK_ENTRY (command_entry)); - - invalid_entry_message = NULL; - - if (!handle_invalid_application_input (GTK_WINDOW (dialog), name, command)) { - entry_validated = TRUE; - app_id = add_or_update_application (list, - name, - command, - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (multiple_check_box)), - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (uri_check_box)), - application != NULL); - if (application == NULL && app_id != NULL) { - add_item_to_application_list (list, app_id, name, mime_type, TRUE, -1); - } - g_free (app_id); - } - } - } while (dialog_result == GNOME_OK && !entry_validated); - - /* FIXME: Close box is treated like Cancel, which loses user changes silently. - * Would be better to either do nothing at all (force use of OK or Cancel) or - * even put up a little dialog telling them they have to use OK or Cancel. - * Too bad we can't prevent the close box from appearing. Window Managers suck. - */ - if (dialog_result >= 0) { - gnome_dialog_close (GNOME_DIALOG (dialog)); - } -} - -static void -show_new_application_window (GtkWidget *button, GtkWidget *list) -{ - run_edit_or_new_application_dialog (gtk_object_get_data (GTK_OBJECT (button), "mime_type"), list, NULL); -} - -static void -show_edit_application_window (GtkWidget *button, GtkWidget *list) -{ - GList *selection; - const char *id; - GnomeVFSMimeApplication *application; - GtkListItem *item; - - /* If there isn't a selection we cannot allow an edit */ - selection = GTK_LIST (list)->selection; - if (selection == NULL || g_list_length (selection) <= 0) { - return; - } - - /* Get application id and info */ - item = GTK_LIST_ITEM (selection->data); - if (item == NULL) { - return; - } - - id = gtk_object_get_data (GTK_OBJECT (item), "application_id"); - if (id == NULL) { - return; - } - - application = gnome_vfs_mime_application_new_from_id (id); - if (application == NULL) { - return; - } - - run_edit_or_new_application_dialog (NULL, list, application); - - gnome_vfs_mime_application_free (application); -} - -static void -delete_selected_application (GtkWidget *button, GtkWidget *list) -{ - GtkListItem *item; - const char *mime_type, *id; - GList *selection; - - /* Get selected list item */ - selection = GTK_LIST (list)->selection; - if (selection == NULL) { - return; - } - - item = GTK_LIST_ITEM (selection->data); - if (item == NULL) { - return; - } - - g_return_if_fail (GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (item), "user_owned"))); - - id = gtk_object_get_data (GTK_OBJECT (item), "application_id"); - mime_type = gtk_object_get_data (GTK_OBJECT (item), "mime_type"); - - /* Remove application if it is user owned */ - if (id != NULL && mime_type != NULL) { - gnome_vfs_application_registry_remove_mime_type (id, mime_type); - gnome_vfs_application_registry_sync (); - gnome_vfs_mime_remove_application_from_short_list (mime_type, id); - } - - /* Remove widget from list */ - gtk_container_remove (GTK_CONTAINER (list), GTK_WIDGET (item)); -} diff --git a/capplets/file-types/file-types-capplet-dialogs.h b/capplets/file-types/file-types-capplet-dialogs.h deleted file mode 100644 index 5567b6141..000000000 --- a/capplets/file-types/file-types-capplet-dialogs.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* nautilus-mime-type-capplet.h - * - * Copyright (C) 2000 Free Software Foundaton - * Copyright (C) 2000 Eazel, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Gene Z. Ragan <gzr@eazel.com> - */ - -#ifndef NAUTILUS_MIME_TYPE_CAPPLET_DIALOGS_H -#define NAUTILUS_MIME_TYPE_CAPPLET_DIALOGS_H - -void show_edit_applications_dialog (const char *mime_type); -void show_edit_components_dialog (const char *mime_type); -char *name_from_oaf_server_info (OAF_ServerInfo *server); -char *nautilus_mime_type_capplet_show_new_mime_window (void); -char *nautilus_mime_type_capplet_show_new_extension_window (void); -char *nautilus_mime_type_capplet_show_change_extension_window (const char *mime_type, - gboolean *new_list); - -#endif /* NAUTILUS_MIME_TYPE_CAPPLET_DIALOGS_H */ diff --git a/capplets/file-types/file-types-capplet.c b/capplets/file-types/file-types-capplet.c deleted file mode 100644 index 49c6828f6..000000000 --- a/capplets/file-types/file-types-capplet.c +++ /dev/null @@ -1,2119 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-mime-type-capplet.h - * - * Copyright (C) 1998 Redhat Software Inc. - * Copyright (C) 2000 Free Software Foundaton - * Copyright (C) 2000 Eazel, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: Jonathan Blandford <jrb@redhat.com> - * Gene Z. Ragan <gzr@eazel.com> - */ - -#include <config.h> -#include <ctype.h> -#include <dirent.h> -#include <math.h> -#include <sys/types.h> -#include <regex.h> -#include <string.h> - -#include <capplet-widget.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <gdk/gdkprivate.h> -#include <gnome.h> -#include <gtk/gtk.h> -#include <libgnomevfs/gnome-vfs-mime-handlers.h> -#include <libgnomevfs/gnome-vfs-mime-info.h> -#include <libgnomevfs/gnome-vfs-init.h> -#include <libgnomevfs/gnome-vfs-utils.h> - -#include "file-types-capplet-dialogs.h" -#include "file-types-icon-entry.h" - -#include "file-types-capplet.h" - -#define DEFAULT_REGULAR_ICON "nautilus/i-regular-24.png" -#define DEFAULT_ACTION_ICON "nautilus/i-executable.png" - -#define MAX_ICON_WIDTH_IN_LIST 18 -#define MAX_ICON_HEIGHT_IN_LIST 18 - -enum { - COLUMN_DESCRIPTION = 0, - COLUMN_MIME_TYPE, - COLUMN_EXTENSION, - COLUMN_ACTION, - TOTAL_COLUMNS -}; - -/* Local Prototypes */ -static void init_mime_capplet (const char *scroll_to_mime_type); -static void populate_application_menu (GtkWidget *menu, - const char *mime_string); -static void populate_viewer_menu (GtkWidget *menu, - const char *mime_string); -static void revert_mime_clicked (GtkWidget *widget, - gpointer data); -static void delete_mime_clicked (GtkWidget *widget, - gpointer data); -static void add_mime_clicked (GtkWidget *widget, - gpointer data); -static void edit_default_clicked (GtkWidget *widget, - gpointer data); -static GtkWidget *create_mime_list_and_scroller (void); -static void ok_callback (void); -static void gtk_widget_make_bold (GtkWidget *widget); -static GdkFont *gdk_font_get_bold (const GdkFont *plain_font); -static void gtk_widget_set_font (GtkWidget *widget, - GdkFont *font); -static void gtk_style_set_font (GtkStyle *style, - GdkFont *font); -static GdkPixbuf *capplet_gdk_pixbuf_scale_to_fit (GdkPixbuf *pixbuf, - int max_width, - int max_height); -static void update_mime_list_action (const char *mime_string); -static void populate_mime_list (GList *type_list, - GtkCList *clist); -static GdkPixbuf *capplet_get_icon_pixbuf (const char *mime_string, - gboolean is_executable); - - -/* FIXME: Using global variables here is yucky */ -GtkWidget *capplet; -GtkWidget *delete_button; -GtkWidget *remove_button; -GtkWidget *add_button; -GtkWidget *icon_entry, *extension_list, *mime_list; -GtkWidget *default_menu; -GtkWidget *application_button, *viewer_button; -GtkLabel *mime_label; -GtkWidget *description_entry; -gboolean description_has_changed; -gboolean sort_column_clicked [TOTAL_COLUMNS]; - -/* - * main - * - * Display capplet - */ - -#define MATHIEU_DEBUG - -#ifdef MATHIEU_DEBUG -#include <signal.h> - -static void -nautilus_stop_in_debugger (void) -{ - void (* saved_handler) (int); - - saved_handler = signal (SIGINT, SIG_IGN); - raise (SIGINT); - signal (SIGINT, saved_handler); -} - -static void -nautilus_stop_after_default_log_handler (const char *domain, - GLogLevelFlags level, - const char *message, - gpointer data) -{ - g_log_default_handler (domain, level, message, data); - nautilus_stop_in_debugger (); -} - -static void -nautilus_set_stop_after_default_log_handler (const char *domain) -{ - g_log_set_handler (domain, G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING, - nautilus_stop_after_default_log_handler, NULL); -} - -static void -nautilus_make_warnings_and_criticals_stop_in_debugger (const char *first_domain, ...) -{ - va_list domains; - const char *domain; - - nautilus_set_stop_after_default_log_handler (first_domain); - - va_start (domains, first_domain); - - for (;;) { - domain = va_arg (domains, const char *); - if (domain == NULL) { - break; - } - nautilus_set_stop_after_default_log_handler (domain); - } - - va_end (domains); -} -#endif /* MATHIEU_DEBUG */ - -int -main (int argc, char **argv) -{ - int init_results; - char *mime_type; - - mime_type = NULL; - - /* */ - if (argc >= 1) { - mime_type = g_strdup (argv[1]); - } - - bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE); - - - init_results = gnome_capplet_init ("file-types-capplet", VERSION, argc, argv, NULL, 0, NULL); - - if (init_results < 0) { - exit (0); - } - - gnome_vfs_init (); - -#ifdef MATHIEU_DEBUG - nautilus_make_warnings_and_criticals_stop_in_debugger (G_LOG_DOMAIN, g_log_domain_glib, - "Bonobo", - "Gdk", - "GnomeUI", - "GnomeVFS", - "GnomeVFS-CORBA", - "GnomeVFS-pthread", - "Gtk", - "Nautilus", - "Nautilus-Authenticate", - "Nautilus-Tree", - "ORBit", - NULL); - -#endif /* MATHIEU_DEBUG */ - if (init_results == 0) { - init_mime_capplet (mime_type); - capplet_gtk_main (); - } - return 0; -} - -static void -ok_callback () -{ -} - -static void -populate_extension_list (const char *mime_type, GtkCList *list) -{ - GList *extensions, *element; - gchar *extension[1]; - gint row; - - if (mime_type == NULL || list == NULL) { - return; - } - - /* Clear out old items */ - gtk_clist_clear (list); - - extensions = gnome_vfs_mime_get_extensions_list (mime_type); - if (extensions == NULL) { - return; - } - - for (element = extensions; element != NULL; element = element->next) { - extension[0] = (char *)element->data; - if (strlen (element->data) > 0) { - row = gtk_clist_append (list, extension); - - /* Set to deletable */ - gtk_clist_set_row_data (list, row, GINT_TO_POINTER (FALSE)); - } - } - - gnome_vfs_mime_extensions_list_free (extensions); - - /* Select first item in extension list */ - gtk_clist_select_row (list, 0, 0); -} - -void -nautilus_mime_type_capplet_add_extension (const char *extension) -{ - gchar *title[1]; - gchar *token, *search_string; - gint rownumber; - const char *mime_type; - - /* Check for empty string */ - if (strlen (extension) <= 0) { - return; - } - - /* Copy only contiguous part of string. No spaces allowed. */ - search_string = g_strdup (extension); - token = strtok (search_string, " "); - - if (token == NULL) { - title[0] = g_strdup (extension); - } else if (strlen (token) <= 0) { - return; - } else { - title[0] = g_strdup (token); - } - g_free (search_string); - - rownumber = gtk_clist_append (GTK_CLIST (extension_list), title); - gtk_clist_set_row_data (GTK_CLIST (extension_list), rownumber, - GINT_TO_POINTER (TRUE)); - - mime_type = nautilus_mime_type_capplet_get_selected_item_mime_type (); - g_assert (mime_type != NULL); - gnome_vfs_mime_add_extension (mime_type, extension); - - /* Select new item in list */ - gtk_clist_select_row (GTK_CLIST (extension_list), rownumber, 0); - -} - - -static void -mime_list_selected_row_callback (GtkWidget *widget, gint row, gint column, GdkEvent *event, gpointer data) -{ - const char *mime_type; - - mime_type = (const char *) gtk_clist_get_row_data (GTK_CLIST (widget),row); - - /* Update info on selection */ - nautilus_mime_type_capplet_update_info (mime_type); -} - -static void -application_button_toggled (GtkToggleButton *button, gpointer user_data) -{ - const char *mime_type; - - if (gtk_toggle_button_get_active (button)) { - - mime_type = nautilus_mime_type_capplet_get_selected_item_mime_type (); - - gnome_vfs_mime_set_default_action_type (mime_type, GNOME_VFS_MIME_ACTION_TYPE_APPLICATION); - - /* Populate menu with application items */ - populate_application_menu (default_menu, mime_type); - - /* Update mime list */ - update_mime_list_action (mime_type); - } -} - -static void -viewer_button_toggled (GtkToggleButton *button, gpointer user_data) -{ - const char *mime_type; - - if (gtk_toggle_button_get_active (button)) { - mime_type = nautilus_mime_type_capplet_get_selected_item_mime_type (); - - gnome_vfs_mime_set_default_action_type (mime_type, GNOME_VFS_MIME_ACTION_TYPE_COMPONENT); - - /* Populate menu with viewer items */ - populate_viewer_menu (default_menu, mime_type); - - /* Update mime list */ - update_mime_list_action (mime_type); - } -} - -static int -get_selected_row_number (void) -{ - gint row; - - if (GTK_CLIST (mime_list)->selection == NULL) { - return -1; - } - - row = GPOINTER_TO_INT ((GTK_CLIST (mime_list)->selection)->data); - return row; -} -static const char * -get_selected_mime_type (void) -{ - gint row = 0; - const char *mime_type; - - - if (GTK_CLIST (mime_list)->selection == NULL) { - return NULL; - } - - row = get_selected_row_number (); - if (row == -1) { - return NULL; - } - - mime_type = (const char *) gtk_clist_get_row_data (GTK_CLIST (mime_list), row); - - return mime_type; -} - -static void -really_change_icon (gpointer user_data) -{ - NautilusMimeIconEntry *icon_entry; - char *filename; - const char *mime_type; - - g_assert (NAUTILUS_MIME_IS_ICON_ENTRY (user_data)); - - mime_type = get_selected_mime_type (); - if (mime_type == NULL) { - return; - } - - icon_entry = NAUTILUS_MIME_ICON_ENTRY (user_data); - - filename = nautilus_mime_type_icon_entry_get_relative_filename (icon_entry); - if (filename == NULL) { - filename = nautilus_mime_type_icon_entry_get_full_filename (icon_entry); - } - - gnome_vfs_mime_set_icon (mime_type, filename); - - nautilus_mime_type_capplet_update_mime_list_icon_and_description (mime_type); - nautilus_mime_type_capplet_update_info (mime_type); - - g_free (filename); -} - -static void -icon_chosen_callback (GnomeIconList *gil, gint num, GdkEvent *event, gpointer user_data) -{ - NautilusMimeIconEntry *icon_entry; - const gchar * icon; - GnomeIconSelection * gis; - GtkWidget *gtk_entry; - - g_return_if_fail (user_data != NULL); - g_return_if_fail (NAUTILUS_MIME_IS_ICON_ENTRY (user_data)); - - icon_entry = NAUTILUS_MIME_ICON_ENTRY (user_data); - - gis = gtk_object_get_user_data (GTK_OBJECT(icon_entry)); - icon = gnome_icon_selection_get_icon(gis, TRUE); - - if (icon != NULL) { - gtk_entry = nautilus_mime_type_icon_entry_gtk_entry(icon_entry); - gtk_entry_set_text(GTK_ENTRY(gtk_entry),icon); - - } - - if(event && event->type == GDK_2BUTTON_PRESS && ((GdkEventButton *)event)->button == 1) { - gnome_icon_selection_stop_loading(gis); - really_change_icon (user_data); - gtk_widget_hide(icon_entry->pick_dialog); - } - - -} - -static void -change_icon_clicked_cb_real (GnomeDialog *dialog, gint button_number, gpointer user_data) -{ - if (button_number == GNOME_OK) { - really_change_icon (user_data); - } -} - -static void -change_icon_clicked (GtkWidget *entry, gpointer user_data) -{ - GnomeDialog *dialog; - GnomeIconSelection * gis; - - nautilus_mime_type_show_icon_selection (NAUTILUS_MIME_ICON_ENTRY (user_data)); - - dialog = GNOME_DIALOG (NAUTILUS_MIME_ICON_ENTRY (user_data)->pick_dialog); - - gtk_signal_connect (GTK_OBJECT (dialog), "clicked", change_icon_clicked_cb_real, user_data); - - gis = gtk_object_get_user_data(GTK_OBJECT(user_data)); - gtk_signal_connect_after (GTK_OBJECT(GNOME_ICON_SELECTION(gis)->gil), - "select_icon", icon_chosen_callback, user_data); - -} - -static void -update_extensions_list (const char *mime_type) -{ - int row; - char *pretty_string; - - row = get_selected_row_number (); - - pretty_string = gnome_vfs_mime_get_extensions_pretty_string (mime_type); - if (pretty_string == NULL) { - pretty_string = g_strdup (" "); - } - gtk_clist_set_text (GTK_CLIST (mime_list), - row, 2, pretty_string); - - g_free (pretty_string); - -} - -static void -change_file_extensions_clicked (GtkWidget *widget, gpointer user_data) -{ - const char *mime_type; - char *new_extensions; - gboolean use_new_list; - - mime_type = get_selected_mime_type (); - if (mime_type == NULL) { - return; - } - - new_extensions = nautilus_mime_type_capplet_show_change_extension_window (mime_type, &use_new_list); - if (use_new_list) { - gnome_vfs_mime_set_extensions_list (mime_type, new_extensions); - } - - update_extensions_list (mime_type); -} - -/* The following are copied from gtkclist.c and nautilusclist.c */ -#define CELL_SPACING 1 - -/* gives the top pixel of the given row in context of - * the clist's voffset */ -#define ROW_TOP_YPIXEL(clist, row) (((clist)->row_height * (row)) + \ - (((row) + 1) * CELL_SPACING) + \ - (clist)->voffset) -static void -list_move_vertical (GtkCList *clist, gint row, gfloat align) -{ - gfloat value; - - g_return_if_fail (clist != NULL); - - if (!clist->vadjustment) { - return; - } - - value = (ROW_TOP_YPIXEL (clist, row) - clist->voffset - - align * (clist->clist_window_height - clist->row_height) + - (2 * align - 1) * CELL_SPACING); - - if (value + clist->vadjustment->page_size > clist->vadjustment->upper) { - value = clist->vadjustment->upper - clist->vadjustment->page_size; - } - - gtk_adjustment_set_value (clist->vadjustment, value); -} - -static void -list_moveto (GtkCList *clist, gint row, gint column, gfloat row_align, gfloat col_align) -{ - g_return_if_fail (clist != NULL); - - if (row < -1 || row >= clist->rows) { - return; - } - - if (column < -1 || column >= clist->columns) { - return; - } - - row_align = CLAMP (row_align, 0, 1); - col_align = CLAMP (col_align, 0, 1); - - /* adjust vertical scrollbar */ - if (clist->vadjustment && row >= 0) { - list_move_vertical (clist, row, row_align); - } -} - -static void -list_reveal_row (GtkCList *clist, int row_index) -{ - g_return_if_fail (row_index >= 0 && row_index < clist->rows); - - if (ROW_TOP_YPIXEL (clist, row_index) + clist->row_height > clist->clist_window_height) { - list_moveto (clist, row_index, -1, 1, 0); - } else if (ROW_TOP_YPIXEL (clist, row_index) < 0) { - list_moveto (clist, row_index, -1, 0, 0); - } -} - - - -static int -find_row_for_mime_type (const char *mime_type, GtkCList *mime_list) -{ - gboolean found_one; - int index; - const char *row_data; - - if (mime_type == NULL) { - return -1; - } - - found_one = FALSE; - - for (index = 0; index < mime_list->rows; index++) { - row_data = gtk_clist_get_row_data (mime_list, index); - if (row_data != NULL && strcmp (row_data, mime_type) == 0) { - found_one = TRUE; - break; - } - } - - if (found_one) { - return index; - } - - return -1; -} - - -static void -update_description_from_input (GtkEntry *entry) -{ - char *new_description; - const char *mime_type; - - g_assert (GTK_IS_ENTRY (entry)); - g_assert ((gpointer)entry == (gpointer)description_entry); - - description_has_changed = FALSE; - - mime_type = get_selected_mime_type (); - if (mime_type == NULL) { - return; - } - - new_description = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); - gnome_vfs_mime_set_description (mime_type, new_description); - nautilus_mime_type_capplet_update_mime_list_icon_and_description (mime_type); - g_free (new_description); -} - -static void -description_entry_activate (GtkEntry *entry, gpointer user_data) -{ - g_assert (GTK_IS_ENTRY (entry)); - g_assert ((gpointer)entry == (gpointer)description_entry); - g_assert (user_data == NULL); - - if (description_has_changed) { - update_description_from_input (entry); - } -} - -static void -description_entry_changed (GtkEntry *entry, gpointer user_data) -{ - g_assert (GTK_IS_ENTRY (entry)); - g_assert ((gpointer)entry == (gpointer)description_entry); - g_assert (user_data == NULL); - - description_has_changed = TRUE; -} - -static gboolean -description_entry_lost_focus (GtkEntry *entry, - GdkEventFocus *event, - gpointer user_data) -{ - g_assert (GTK_IS_ENTRY (entry)); - g_assert ((gpointer)entry == (gpointer)description_entry); - g_assert (user_data == NULL); - - if (description_has_changed) { - update_description_from_input (entry); - } - - return FALSE; -} - -static void -init_mime_capplet (const char *scroll_to_mime_type) -{ - GtkWidget *main_vbox; - GtkWidget *vbox, *hbox, *left_vbox; - GtkWidget *button; - GtkWidget *mime_list_container; - GtkWidget *frame; - GtkWidget *table; - int index, list_width, column_width, found_index; - - capplet = capplet_widget_new (); - - /* Main vertical box */ - main_vbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (main_vbox), GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (capplet), main_vbox); - - /* Main horizontal box and mime list */ - hbox = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_box_pack_start (GTK_BOX (main_vbox), hbox, TRUE, TRUE, 0); - mime_list_container = create_mime_list_and_scroller (); - gtk_box_pack_start (GTK_BOX (hbox), mime_list_container, TRUE, TRUE, 0); - - vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); - - /* Create table */ - table = gtk_table_new (2, 2, FALSE); - gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0); - gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL); - gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL); - - - left_vbox = gtk_vbox_new (FALSE, 0); - /* Set up top left area. */ - { - GtkWidget *small_table; - - small_table = gtk_table_new (1, 2, FALSE); - gtk_table_set_col_spacings (GTK_TABLE (small_table), 7); - - gtk_table_attach ( GTK_TABLE (table), small_table, 0, 1, 0, 1, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - icon_entry = nautilus_mime_type_icon_entry_new ("mime_icon_entry", NULL); - gtk_table_attach (GTK_TABLE (small_table), icon_entry, 0, 1, 0, 1, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_table_attach (GTK_TABLE (small_table), vbox, 1, 2, 0, 1, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (GTK_FILL), 0, 0); - - description_entry = gtk_entry_new (); - description_has_changed = FALSE; - gtk_box_pack_start (GTK_BOX (vbox), description_entry, FALSE, FALSE, 0); - gtk_widget_make_bold (GTK_WIDGET (description_entry)); - - gtk_signal_connect (GTK_OBJECT (description_entry), "activate", - GTK_SIGNAL_FUNC (description_entry_activate), - NULL); - - gtk_signal_connect (GTK_OBJECT (description_entry), "changed", - GTK_SIGNAL_FUNC (description_entry_changed), - NULL); - - gtk_signal_connect (GTK_OBJECT (description_entry), "focus_out_event", - GTK_SIGNAL_FUNC (description_entry_lost_focus), - NULL); - - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (hbox), FALSE, FALSE, 0); - - mime_label = GTK_LABEL (gtk_label_new (_("MIME Type"))); - gtk_label_set_justify (GTK_LABEL (mime_label), GTK_JUSTIFY_LEFT); - gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (mime_label), FALSE, FALSE, 0); - - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - button = gtk_button_new_with_label (_("Change Icon")); - gtk_signal_connect (GTK_OBJECT (button), "clicked", change_icon_clicked, icon_entry); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - - /* spacer */ - gtk_box_pack_start (GTK_BOX (hbox), gtk_vbox_new (FALSE, 0), FALSE, FALSE, 10); - - button = gtk_button_new_with_label (_("Change File Extensions")); - gtk_signal_connect (GTK_OBJECT (button), "clicked", change_file_extensions_clicked, NULL); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - - } - - /* Set up bottom left area. */ - { - frame = gtk_frame_new (_("Default Action:")); - gtk_table_attach ( GTK_TABLE (table), frame, 0, 1, 1, 2, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (frame), vbox); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); - - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - viewer_button = gtk_radio_button_new_with_label (NULL, _("Use Viewer")); - gtk_box_pack_start (GTK_BOX (hbox), viewer_button, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (viewer_button), "toggled", - GTK_SIGNAL_FUNC (viewer_button_toggled), NULL); - - application_button = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (viewer_button), - _("Open With Application")); - gtk_box_pack_start (GTK_BOX (hbox), application_button, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (application_button), "toggled", - GTK_SIGNAL_FUNC (application_button_toggled), NULL); - - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - default_menu = gtk_option_menu_new(); - gtk_box_pack_start (GTK_BOX (hbox), default_menu, TRUE, TRUE, 0); - - button = gtk_button_new_with_label (_("Edit List")); - gtk_misc_set_padding (GTK_MISC (GTK_BIN(button)->child), 2, 1); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (button), "clicked", edit_default_clicked, mime_list); - } - - /* Set up top right area. */ - { - GtkWidget *separator; - GtkWidget *small_table; - - hbox = gtk_hbox_new (FALSE, 0); - gtk_table_attach_defaults ( GTK_TABLE (table), hbox, 1, 2, 0, 1); - - small_table = gtk_table_new (5, 1, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (small_table), 7); - gtk_box_pack_end (GTK_BOX (hbox), small_table, FALSE, FALSE, 0); - - /* Placed to space top button with top of left table */ - hbox = gtk_hbox_new (FALSE, 0); - gtk_table_attach (GTK_TABLE (small_table), hbox, 0, 1, 0, 1, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_widget_set_usize (hbox, 1, 11); - - button = gtk_button_new_with_label (_("Add New MIME Type...")); - gtk_signal_connect (GTK_OBJECT (button), "clicked", add_mime_clicked, NULL); - gtk_table_attach (GTK_TABLE (small_table), button, 0, 1, 1, 2, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - button = gtk_button_new_with_label (_("Delete This MIME Type")); - gtk_signal_connect (GTK_OBJECT (button), "clicked", delete_mime_clicked, NULL); - gtk_table_attach (GTK_TABLE (small_table), button, 0, 1, 2, 3, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - separator = gtk_hseparator_new (); - gtk_table_attach (GTK_TABLE (small_table), separator, 0, 1, 3, 4, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (GTK_FILL), 0, 0); - - button = gtk_button_new_with_label (_("Revert to System Defaults")); - gtk_signal_connect (GTK_OBJECT (button), "clicked", revert_mime_clicked, NULL); - gtk_table_attach (GTK_TABLE (small_table), button, 0, 1, 4, 5, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - } - - /* Yes, show all widgets */ - gtk_widget_show_all (capplet); - - /* Make columns all fit within capplet list view bounds */ - list_width = GTK_WIDGET (mime_list)->allocation.width; - column_width = list_width / TOTAL_COLUMNS; - for (index = 0; index < TOTAL_COLUMNS; index++) - gtk_clist_set_column_auto_resize (GTK_CLIST (mime_list), index, TRUE); -#if 0 - /* This is not working */ - for (index = 0; index < TOTAL_COLUMNS; index++) { - g_print ("Setting column %i with to %d\n", index, column_width); - gtk_clist_set_column_width (GTK_CLIST (mime_list), index, column_width); - } -#endif - - /* Setup capplet signals */ - gtk_signal_connect(GTK_OBJECT(capplet), "ok", - GTK_SIGNAL_FUNC(ok_callback), NULL); - - gtk_signal_connect (GTK_OBJECT (mime_list),"select_row", - GTK_SIGNAL_FUNC (mime_list_selected_row_callback), NULL); - - /* Sort by description. The description is the first column in the list. */ - gtk_clist_set_sort_column (GTK_CLIST (mime_list), COLUMN_DESCRIPTION); - gtk_clist_sort (GTK_CLIST (mime_list)); - GTK_CLIST (mime_list)->sort_type = GTK_SORT_ASCENDING; - - /* Set up initial column click tracking state. We do this so the initial clicks on - * columns will allow us to set the proper sort state for the user. - */ - sort_column_clicked[0] = TRUE; /* First sort column has been click by us in setup code */ - for (index = 1; index < TOTAL_COLUMNS; index++) { - sort_column_clicked[index] = FALSE; - } - - /* Attempt to select specified mime type in list */ - if (scroll_to_mime_type != NULL) { - found_index = find_row_for_mime_type (scroll_to_mime_type, GTK_CLIST (mime_list)); - if (found_index != -1) { - gtk_clist_select_row (GTK_CLIST (mime_list), found_index, 1); - list_reveal_row (GTK_CLIST (mime_list), found_index); - } else { - gtk_clist_select_row (GTK_CLIST (mime_list), 0, 1); - list_reveal_row (GTK_CLIST (mime_list), 0); - } - } else { - gtk_clist_select_row (GTK_CLIST (mime_list), 0, 0); - list_reveal_row (GTK_CLIST (mime_list), 0); - } - - /* Inform control center that our changes are immediate */ - capplet_widget_changes_are_immediate (CAPPLET_WIDGET (capplet)); -} - -static gboolean -is_full_path (const char *path_or_name) -{ - return path_or_name[0] == '/'; -} - -static char * -capplet_get_icon_path (const char *path_or_name) -{ - char *result; - char *alternate_relative_filename; - - if (is_full_path (path_or_name) && g_file_exists (path_or_name)) { - return g_strdup (path_or_name); - } - - result = gnome_vfs_icon_path_from_filename (path_or_name); - if (result != NULL) { - return result; - } - - /* FIXME bugzilla.eazel.com 639: - * It is somewhat evil to special-case the nautilus directory here. - * We should clean this up if/when we come up with a way to handle - * Nautilus themes here. - */ - alternate_relative_filename = g_strconcat ("nautilus/", path_or_name, NULL); - result = gnome_vfs_icon_path_from_filename (alternate_relative_filename); - g_free (alternate_relative_filename); - if (result != NULL) { - return result; - } - - /* FIXME bugzilla.eazel.com 639: - * To work correctly with Nautilus themed icons, if there's no - * suffix we will also try looking in the nautilus dir for a ".png" name. - * This will return the icon for the default theme; there is no - * mechanism for getting a themed icon in the capplet. - */ - alternate_relative_filename = g_strconcat ("nautilus/", path_or_name, ".png", NULL); - result = gnome_vfs_icon_path_from_filename (alternate_relative_filename); - g_free (alternate_relative_filename); - - return result; -} - -/* - * nautilus_mime_type_capplet_update_info - * - * Update controls with info based on mime type - */ - -void -nautilus_mime_type_capplet_update_info (const char *mime_type) { - - GnomeVFSMimeAction *action; - const char *icon_name, *description; - char *path; - - /* Update text items */ - gtk_label_set_text (GTK_LABEL (mime_label), mime_type); - - description = gnome_vfs_mime_get_description (mime_type); - gtk_entry_set_text (GTK_ENTRY (description_entry), description != NULL ? description : ""); - description_has_changed = FALSE; - - /* Update menus */ - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (application_button))) { - populate_application_menu (default_menu, mime_type); - } else { - populate_viewer_menu (default_menu, mime_type); - } - - /* Update extensions list */ - if (extension_list != NULL) { - populate_extension_list (mime_type, GTK_CLIST (extension_list)); - } - - /* Set icon for mime type */ - icon_name = gnome_vfs_mime_get_icon (mime_type); - path = NULL; - if (icon_name != NULL) { - path = capplet_get_icon_path (icon_name); - } - if (path == NULL) { - /* No custom icon specified, or custom icon not found, use default */ - path = capplet_get_icon_path (DEFAULT_REGULAR_ICON); - } - nautilus_mime_type_icon_entry_set_icon (NAUTILUS_MIME_ICON_ENTRY (icon_entry), path); - g_free (path); - - /* Indicate default action */ - action = gnome_vfs_mime_get_default_action (mime_type); - if (action != NULL) { - switch (action->action_type) { - case GNOME_VFS_MIME_ACTION_TYPE_APPLICATION: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (application_button), TRUE); - break; - - case GNOME_VFS_MIME_ACTION_TYPE_COMPONENT: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (viewer_button), TRUE); - break; - - default: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (application_button), TRUE); - break; - } - } else { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (application_button), TRUE); - } - -} - -static void -application_menu_activated (GtkWidget *menu_item, gpointer data) -{ - const char *id; - const char *mime_type; - - /* Get our stashed data */ - id = gtk_object_get_data (GTK_OBJECT (menu_item), "id"); - mime_type = gtk_object_get_data (GTK_OBJECT (menu_item), "mime_type"); - - if (id == NULL || mime_type == NULL) { - return; - } - gnome_vfs_mime_set_default_application (mime_type, id); - update_mime_list_action (mime_type); -} - -static void -populate_application_menu (GtkWidget *application_menu, const char *mime_type) -{ - GtkWidget *new_menu, *menu_item; - GList *app_list, *copy_list; - GnomeVFSMimeApplication *default_app, *application; - gboolean has_none, found_match; - char *mime_copy; - const char *id; - GList *children; - int index; - - has_none = TRUE; - found_match = FALSE; - - mime_copy = g_strdup (mime_type); - - new_menu = gtk_menu_new (); - - /* Get the default application */ - default_app = gnome_vfs_mime_get_default_application (mime_type); - - /* Get the application short list */ - app_list = gnome_vfs_mime_get_short_list_applications (mime_type); - if (app_list != NULL) { - for (copy_list = app_list; copy_list != NULL; copy_list = copy_list->next) { - has_none = FALSE; - - application = copy_list->data; - menu_item = gtk_menu_item_new_with_label (application->name); - - /* Store copy of application name and mime type in item; free when item destroyed. */ - gtk_object_set_data_full (GTK_OBJECT (menu_item), - "id", - g_strdup (application->id), - g_free); - - gtk_object_set_data_full (GTK_OBJECT (menu_item), - "mime_type", - g_strdup (mime_type), - g_free); - - gtk_menu_append (GTK_MENU (new_menu), menu_item); - gtk_widget_show (menu_item); - - gtk_signal_connect (GTK_OBJECT (menu_item), "activate", - application_menu_activated, NULL); - } - - gnome_vfs_mime_application_list_free (app_list); - } - - /* Find all applications or add a "None" item */ - if (has_none && default_app == NULL) { - menu_item = gtk_menu_item_new_with_label (_("None")); - gtk_menu_append (GTK_MENU (new_menu), menu_item); - gtk_widget_show (menu_item); - } else { - /* Check and see if default is in the short list */ - if (default_app != NULL) { - /* Iterate */ - children = gtk_container_children (GTK_CONTAINER (new_menu)); - for (index = 0; children != NULL; children = children->next, ++index) { - id = (const char *)(gtk_object_get_data (GTK_OBJECT (children->data), "id")); - if (id != NULL) { - if (strcmp (default_app->id, id) == 0) { - found_match = TRUE; - break; - } - } - } - g_list_free (children); - - /* See if we have a match */ - if (found_match) { - /* Have menu appear with default application selected */ - gtk_menu_set_active (GTK_MENU (new_menu), index); - } else { - /* No match found. We need to insert a menu item - * and add the application to the default list */ - menu_item = gtk_menu_item_new_with_label (default_app->name); - - /* Store copy of application name and mime type in item; free when item destroyed. */ - gtk_object_set_data_full (GTK_OBJECT (menu_item), - "id", - g_strdup (default_app->id), - g_free); - - gtk_object_set_data_full (GTK_OBJECT (menu_item), - "mime_type", - g_strdup (mime_type), - g_free); - - gtk_menu_append (GTK_MENU (new_menu), menu_item); - gtk_widget_show (menu_item); - - gtk_signal_connect (GTK_OBJECT (menu_item), "activate", - application_menu_activated, NULL); - - - /* Iterate */ - children = gtk_container_children (GTK_CONTAINER (new_menu)); - for (index = 0; children != NULL; children = children->next, ++index) { - id = (const char *)(gtk_object_get_data (GTK_OBJECT (children->data), "id")); - if (id != NULL) { - if (strcmp (default_app->id, id) == 0) { - found_match = TRUE; - break; - } - } - } - g_list_free (children); - - /* Set it as active */ - gtk_menu_set_active (GTK_MENU (new_menu), index); - } - gnome_vfs_mime_application_free (default_app); - } - } - - gtk_option_menu_set_menu (GTK_OPTION_MENU (default_menu), new_menu); -} - -static void -component_menu_activated (GtkWidget *menu_item, gpointer data) -{ - const char *iid; - const char *mime_type; - - /* Get our stashed data */ - iid = gtk_object_get_data (GTK_OBJECT (menu_item), "iid"); - mime_type = gtk_object_get_data (GTK_OBJECT (menu_item), "mime_type"); - - if (iid == NULL || mime_type == NULL) { - return; - } - - gnome_vfs_mime_set_default_component (mime_type, iid); - update_mime_list_action (mime_type); -} - -static void -populate_viewer_menu (GtkWidget *component_menu, const char *mime_type) -{ - GtkWidget *new_menu, *menu_item; - GList *component_list, *copy_list; - OAF_ServerInfo *default_component; - OAF_ServerInfo *info; - gboolean has_none, found_match; - char *mime_copy, *component_name; - const char *iid; - GList *children; - int index; - - has_none = TRUE; - found_match = FALSE; - - mime_copy = g_strdup (mime_type); - - new_menu = gtk_menu_new (); - - /* Get the default component */ - default_component = gnome_vfs_mime_get_default_component (mime_type); - - /* Get the component short list */ - component_list = gnome_vfs_mime_get_short_list_components (mime_type); - if (component_list != NULL) { - for (copy_list = component_list; copy_list != NULL; copy_list = copy_list->next) { - has_none = FALSE; - - component_name = name_from_oaf_server_info (copy_list->data); - menu_item = gtk_menu_item_new_with_label (component_name); - g_free (component_name); - - /* Store copy of component name and mime type in item; free when item destroyed. */ - info = copy_list->data; - gtk_object_set_data_full (GTK_OBJECT (menu_item), - "iid", - g_strdup (info->iid), - g_free); - - gtk_object_set_data_full (GTK_OBJECT (menu_item), - "mime_type", - g_strdup (mime_type), - g_free); - - gtk_menu_append (GTK_MENU (new_menu), menu_item); - gtk_widget_show (menu_item); - - gtk_signal_connect (GTK_OBJECT (menu_item), "activate", - component_menu_activated, NULL); - } - - gnome_vfs_mime_component_list_free (component_list); - } - - /* Find all components or add a "None" item */ - if (has_none && default_component == NULL) { - menu_item = gtk_menu_item_new_with_label (_("None")); - gtk_menu_append (GTK_MENU (new_menu), menu_item); - gtk_widget_show (menu_item); - } else { - /* Check and see if default is in the short list */ - if (default_component != NULL) { - /* Iterate */ - children = gtk_container_children (GTK_CONTAINER (new_menu)); - for (index = 0; children != NULL; children = children->next, ++index) { - iid = (const char *)(gtk_object_get_data (GTK_OBJECT (children->data), "iid")); - if (iid != NULL) { - if (strcmp (default_component->iid, iid) == 0) { - found_match = TRUE; - break; - } - } - } - g_list_free (children); - - /* See if we have a match */ - if (found_match) { - /* Have menu appear with default component selected */ - gtk_menu_set_active (GTK_MENU (new_menu), index); - } else { - /* No match found. We need to insert a menu item - * and add the component to the default list */ - component_name = name_from_oaf_server_info (default_component); - menu_item = gtk_menu_item_new_with_label (component_name); - g_free (component_name); - - /* Store copy of component name and mime type in item; free when item destroyed. */ - gtk_object_set_data_full (GTK_OBJECT (menu_item), - "iid", - g_strdup (default_component->iid), - g_free); - - gtk_object_set_data_full (GTK_OBJECT (menu_item), - "mime_type", - g_strdup (mime_type), - g_free); - - gtk_menu_append (GTK_MENU (new_menu), menu_item); - gtk_widget_show (menu_item); - - gtk_signal_connect (GTK_OBJECT (menu_item), "activate", - component_menu_activated, NULL); - - - /* Iterate */ - children = gtk_container_children (GTK_CONTAINER (new_menu)); - for (index = 0; children != NULL; children = children->next, ++index) { - iid = (const char *)(gtk_object_get_data (GTK_OBJECT (children->data), "iid")); - if (iid != NULL) { - if (strcmp (default_component->iid, iid) == 0) { - found_match = TRUE; - break; - } - } - } - g_list_free (children); - - /* Set it as active */ - gtk_menu_set_active (GTK_MENU (new_menu), index); - } - CORBA_free (default_component); - } - } - - gtk_option_menu_set_menu (GTK_OPTION_MENU (default_menu), new_menu); -} - -static void -revert_real_cb (gint reply, gpointer data) -{ - if (reply == 0) { - /* YES */ - GList *mime_types_list; - gnome_vfs_mime_reset (); - - gnome_vfs_mime_info_reload (); - - mime_types_list = gnome_vfs_get_registered_mime_types (); - - gtk_clist_freeze (GTK_CLIST (mime_list)); - gtk_clist_clear (GTK_CLIST (mime_list)); - populate_mime_list (mime_types_list, GTK_CLIST (mime_list)); - - /* Sort list using current sort type and select the first item. */ - gtk_clist_sort (GTK_CLIST (mime_list)); - gtk_clist_select_row (GTK_CLIST (mime_list), 0, 0); - list_reveal_row (GTK_CLIST (mime_list), 0); - - gtk_clist_thaw (GTK_CLIST (mime_list)); - - } else { - /* NO */ - } - -} - -static void -revert_mime_clicked (GtkWidget *widget, gpointer data) -{ - GtkWidget *dialog; - - dialog = gnome_question_dialog_modal (_("Reverting to system settings will lose any changes\n" - "you have ever made to File Types and Programs.\n" - "Revert anyway?"), - revert_real_cb, NULL); - -} -/* - * delete_mime_clicked - * - * Delete mime type if it is a user defined type. - */ - -static void -delete_mime_clicked (GtkWidget *widget, gpointer data) -{ - const char *mime_type; - gint row = 0; - - if (GTK_CLIST (mime_list)->selection) - row = GPOINTER_TO_INT ((GTK_CLIST (mime_list)->selection)->data); - else - return; - mime_type = (const char *) gtk_clist_get_row_data (GTK_CLIST (mime_list), row); - - gtk_clist_remove (GTK_CLIST (mime_list), row); - - gnome_vfs_mime_registered_mime_type_delete (mime_type); -} - -static void -add_mime_clicked (GtkWidget *widget, gpointer data) -{ - char *text[4], *tmp_text; - const char *description; - char *extensions, *mime_string, *filename; - gint row; - GdkPixbuf *pixbuf; - GdkPixmap *pixmap; - GdkBitmap *bitmap; - GnomeVFSMimeAction *action; - GnomeVFSMimeApplication *default_app; - OAF_ServerInfo *default_component; - int found_index; - - mime_string = nautilus_mime_type_capplet_show_new_mime_window (); - if (mime_string != NULL && mime_string[0] != '\0') { - /* Add new type to mime list */ - pixbuf = NULL; - - /* Add description to first column */ - description = gnome_vfs_mime_get_description (mime_string); - if (description != NULL && strlen (description) > 0) { - text[0] = g_strdup (description); - } else { - text[0] = g_strdup (""); - } - - /* Add mime type to second column */ - text[1] = g_strdup (mime_string); - - /* Add extension to third columns */ - extensions = gnome_vfs_mime_get_extensions_pretty_string (mime_string); - if (extensions != NULL) { - text[2] = g_strdup (extensions); - } else { - text[2] = g_strdup (""); - } - - /* Add default action to fourth column */ - text[3] = g_strdup(_("none")); - - /* Insert item into list */ - row = gtk_clist_insert (GTK_CLIST (mime_list), 1, text); - gtk_clist_set_row_data (GTK_CLIST (mime_list), row, g_strdup (mime_string)); - - /* Set description column icon */ - pixbuf = capplet_get_icon_pixbuf (mime_string, FALSE); - - if (pixbuf != NULL) { - pixbuf = capplet_gdk_pixbuf_scale_to_fit (pixbuf, MAX_ICON_WIDTH_IN_LIST, MAX_ICON_HEIGHT_IN_LIST); - gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &bitmap, 100); - gtk_clist_set_pixtext (GTK_CLIST (mime_list), row, 0, text[0], 5, pixmap, bitmap); - gdk_pixbuf_unref (pixbuf); - } - - /* Set up action column */ - pixbuf = NULL; - action = gnome_vfs_mime_get_default_action (mime_string); - if (action != NULL) { - switch (action->action_type) { - case GNOME_VFS_MIME_ACTION_TYPE_APPLICATION: - /* Get the default application */ - default_app = gnome_vfs_mime_get_default_application (mime_string); - g_free (text[3]); - text[3] = g_strdup (default_app->name); - - filename = capplet_get_icon_path (DEFAULT_ACTION_ICON); - if (filename != NULL) { - pixbuf = gdk_pixbuf_new_from_file (filename); - g_free (filename); - } - - gnome_vfs_mime_application_free (default_app); - break; - - case GNOME_VFS_MIME_ACTION_TYPE_COMPONENT: - /* Get the default component */ - default_component = gnome_vfs_mime_get_default_component (mime_string); - g_free (text[3]); - tmp_text = name_from_oaf_server_info (default_component); - text[3] = g_strdup_printf (_("View as %s"), tmp_text); - g_free (tmp_text); - filename = capplet_get_icon_path ("nautilus/gnome-library.png"); - if (filename != NULL) { - pixbuf = gdk_pixbuf_new_from_file (filename); - g_free (filename); - } - CORBA_free (default_component); - break; - - default: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (application_button), TRUE); - break; - } - } - - /* Set column icon */ - if (pixbuf != NULL) { - pixbuf = capplet_gdk_pixbuf_scale_to_fit (pixbuf, MAX_ICON_WIDTH_IN_LIST, MAX_ICON_HEIGHT_IN_LIST); - gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &bitmap, 100); - gtk_clist_set_pixtext (GTK_CLIST (mime_list), row, 3, text[3], 5, pixmap, bitmap); - gdk_pixbuf_unref (pixbuf); - } - - /* Sort, select and scroll to new mime type */ - gtk_clist_sort (GTK_CLIST (mime_list)); - found_index = find_row_for_mime_type (mime_string, GTK_CLIST (mime_list)); - if (found_index != -1) { - gtk_clist_select_row (GTK_CLIST (mime_list), found_index, 1); - list_reveal_row (GTK_CLIST (mime_list), found_index); - } - - g_free (text[0]); - g_free (text[1]); - g_free (text[2]); - g_free (text[3]); - g_free (extensions); - g_free (mime_string); - } - -} - -static void -edit_default_clicked (GtkWidget *widget, gpointer data) -{ - GtkWidget *list; - const char *mime_type; - GList *p; - GtkCListRow *row; - - g_return_if_fail (GTK_IS_CLIST (data)); - - list = data; - row = NULL; - - /* Get first selected row. This will be the only selection for this list */ - for (p = GTK_CLIST (list)->row_list; p != NULL; p = p->next) { - row = p->data; - if (row->state == GTK_STATE_SELECTED) { - break; - } - } - - if (row == NULL) { - return; - } - - /* Show dialog */ - mime_type = (const char *) row->data; - - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (application_button))) { - show_edit_applications_dialog (mime_type); - } else { - show_edit_components_dialog (mime_type); - } -} - - -void -nautilus_mime_type_capplet_update_mime_list_icon_and_description (const char *mime_string) -{ - char *text; - const char *description; - gint row; - GdkPixbuf *pixbuf; - GdkPixmap *pixmap; - GdkBitmap *bitmap; - GtkCList *clist; - - clist = GTK_CLIST (mime_list); - - pixbuf = NULL; - - row = GPOINTER_TO_INT (clist->selection->data); - - gnome_vfs_mime_info_reload (); - - /* Get description text */ - description = gnome_vfs_mime_get_description (mime_string); - if (description != NULL && strlen (description) > 0) { - text = g_strdup (description); - } else { - text = g_strdup (""); - } - - /* Set description column icon */ - pixbuf = capplet_get_icon_pixbuf (mime_string, FALSE); - - if (pixbuf != NULL) { - pixbuf = capplet_gdk_pixbuf_scale_to_fit (pixbuf, MAX_ICON_WIDTH_IN_LIST, MAX_ICON_HEIGHT_IN_LIST); - gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &bitmap, 100); - gtk_clist_set_pixtext (clist, row, 0, text, 5, pixmap, bitmap); - gdk_pixbuf_unref (pixbuf); - } - - g_free (text); -} - -/* - * nautilus_mime_type_capplet_update_application_info - * - * Update state of the applications menu. This function is called - * when the Edit Applications dialog is closed with an OK. - */ - -void -nautilus_mime_type_capplet_update_application_info (const char *mime_type) -{ - populate_application_menu (default_menu, mime_type); -} - -/* - * nautilus_mime_type_capplet_update_component_info - * - * Update state of the components menu. This function is called - * when the Edit Componests dialog is closed with an OK. - */ - -void -nautilus_mime_type_capplet_update_viewer_info (const char *mime_type) -{ - populate_viewer_menu (default_menu, mime_type); -} - -static void -update_mime_list_action (const char *mime_string) -{ - GdkPixbuf *pixbuf; - GdkPixmap *pixmap; - GdkBitmap *bitmap; - GnomeVFSMimeAction *action; - GnomeVFSMimeApplication *default_app; - OAF_ServerInfo *default_component; - char *text, *tmp_text, *icon_path; - int row; - - pixbuf = NULL; - row = GPOINTER_TO_INT (GTK_CLIST (mime_list)->selection->data); - - text = g_strdup(_("none")); - - action = gnome_vfs_mime_get_default_action (mime_string); - if (action != NULL) { - switch (action->action_type) { - /* FIXME: Big hunks of this code are copied/pasted in several - * places in this file. Need to use common routines. One way - * to find them is to search for "nautilus/gnome-library.png" - */ - case GNOME_VFS_MIME_ACTION_TYPE_APPLICATION: - /* Get the default application */ - default_app = gnome_vfs_mime_get_default_application (mime_string); - g_free (text); - text = g_strdup (default_app->name); - icon_path = capplet_get_icon_path (DEFAULT_ACTION_ICON); - if (icon_path != NULL) { - pixbuf = gdk_pixbuf_new_from_file (icon_path); - g_free (icon_path); - } - gnome_vfs_mime_application_free (default_app); - break; - - case GNOME_VFS_MIME_ACTION_TYPE_COMPONENT: - /* Get the default component */ - default_component = gnome_vfs_mime_get_default_component (mime_string); - g_free (text); - tmp_text = name_from_oaf_server_info (default_component); - text = g_strdup_printf (_("View as %s"), tmp_text); - g_free (tmp_text); - icon_path = capplet_get_icon_path ("nautilus/gnome-library.png"); - if (icon_path != NULL) { - pixbuf = gdk_pixbuf_new_from_file (icon_path); - g_free (icon_path); - } - CORBA_free (default_component); - break; - - default: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (application_button), TRUE); - break; - } - } - - /* Set column icon */ - if (pixbuf != NULL) { - pixbuf = capplet_gdk_pixbuf_scale_to_fit (pixbuf, MAX_ICON_WIDTH_IN_LIST, MAX_ICON_HEIGHT_IN_LIST); - gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &bitmap, 100); - gtk_clist_set_pixtext (GTK_CLIST (mime_list), row, 3, text, 5, pixmap, bitmap); - gdk_pixbuf_unref (pixbuf); - } else { - /* Just set text with no icon */ - gtk_clist_set_text (GTK_CLIST (mime_list), row, 3, text); - } - g_free (text); -} - -/* FIXME: - * This routine is never called with is_executable TRUE anymore. It - * could be simplified, possibly out of existence. - */ -static GdkPixbuf * -capplet_get_icon_pixbuf (const char *mime_string, gboolean is_executable) -{ - const char *icon_name; - char *icon_path; - GdkPixbuf *pixbuf; - - pixbuf = NULL; - - icon_name = gnome_vfs_mime_get_icon (mime_string); - if (icon_name == NULL) { - icon_name = is_executable - ? DEFAULT_ACTION_ICON - : DEFAULT_REGULAR_ICON; - } - - icon_path = capplet_get_icon_path (icon_name); - if (icon_path != NULL) { - pixbuf = gdk_pixbuf_new_from_file (icon_path); - g_free (icon_path); - } - - return pixbuf; -} - -static void -populate_mime_list (GList *type_list, GtkCList *clist) -{ - char *text[4], *tmp_text; - const char *description; - char *icon_path; - char *extensions, *mime_string; - gint row; - GList *element; - GdkPixbuf *pixbuf; - GdkPixmap *pixmap; - GdkBitmap *bitmap; - GnomeVFSMimeAction *action; - GnomeVFSMimeApplication *default_app; - OAF_ServerInfo *default_component; - - for (element = type_list; element != NULL; element= element->next) { - mime_string = (char *)element->data; - - pixbuf = NULL; - - /* Add description to first column */ - description = gnome_vfs_mime_get_description (mime_string); - if (description != NULL && strlen (description) > 0) { - text[0] = g_strdup (description); - } else { - text[0] = g_strdup (""); - } - - /* Add mime type to second column */ - text[1] = mime_string; - - /* Add extension to third columns */ - extensions = gnome_vfs_mime_get_extensions_pretty_string (mime_string); - if (extensions != NULL) { - text[2] = extensions; - } else { - text[2] = ""; - } - - /* Add default action to fourth column */ - text[3] = g_strdup(_("none")); - - /* Insert item into list */ - row = gtk_clist_insert (GTK_CLIST (clist), 1, text); - gtk_clist_set_row_data (GTK_CLIST (clist), row, g_strdup (mime_string)); - - /* Set description column icon */ - pixbuf = capplet_get_icon_pixbuf (mime_string, FALSE); - - if (pixbuf != NULL) { - /* FIXME: Big hunks of this code are copied/pasted in several - * places in this file. Need to use common routines. One way - * to find them is to search for MAX_ICON_WIDTH_IN_LIST - */ - pixbuf = capplet_gdk_pixbuf_scale_to_fit (pixbuf, MAX_ICON_WIDTH_IN_LIST, MAX_ICON_HEIGHT_IN_LIST); - gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &bitmap, 100); - gtk_clist_set_pixtext (clist, row, 0, text[0], 5, pixmap, bitmap); - gdk_pixbuf_unref (pixbuf); - } - - /* Set up action column */ - pixbuf = NULL; - action = gnome_vfs_mime_get_default_action (mime_string); - if (action != NULL) { - switch (action->action_type) { - case GNOME_VFS_MIME_ACTION_TYPE_APPLICATION: - /* Get the default application */ - default_app = gnome_vfs_mime_get_default_application (mime_string); - g_free (text[3]); - text[3] = g_strdup (default_app->name); - - icon_path = capplet_get_icon_path (DEFAULT_ACTION_ICON); - if (icon_path != NULL) { - pixbuf = gdk_pixbuf_new_from_file (icon_path); - g_free (icon_path); - } - gnome_vfs_mime_application_free (default_app); - break; - - case GNOME_VFS_MIME_ACTION_TYPE_COMPONENT: - /* Get the default component */ - default_component = gnome_vfs_mime_get_default_component (mime_string); - g_free (text[3]); - tmp_text = name_from_oaf_server_info (default_component); - text[3] = g_strdup_printf (_("View as %s"), tmp_text); - g_free (tmp_text); - icon_path = capplet_get_icon_path ("nautilus/gnome-library.png"); - if (icon_path != NULL) { - pixbuf = gdk_pixbuf_new_from_file (icon_path); - g_free (icon_path); - } - CORBA_free (default_component); - break; - - default: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (application_button), TRUE); - break; - } - } - - /* Set column icon */ - if (pixbuf != NULL) { - pixbuf = capplet_gdk_pixbuf_scale_to_fit (pixbuf, MAX_ICON_WIDTH_IN_LIST, MAX_ICON_HEIGHT_IN_LIST); - gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &bitmap, 100); - gtk_clist_set_pixtext (clist, row, 3, text[3], 5, pixmap, bitmap); - gdk_pixbuf_unref (pixbuf); - } - - g_free (text[0]); - g_free (text[3]); - g_free (extensions); - } -} - -static gint -sort_case_insensitive (GtkCList *clist, gpointer ptr1, gpointer ptr2) -{ - const char *text1 = NULL; - const char *text2 = NULL; - - GtkCListRow *row1 = (GtkCListRow *) ptr1; - GtkCListRow *row2 = (GtkCListRow *) ptr2; - - switch (row1->cell[clist->sort_column].type) { - case GTK_CELL_TEXT: - text1 = GTK_CELL_TEXT (row1->cell[clist->sort_column])->text; - break; - - case GTK_CELL_PIXTEXT: - text1 = GTK_CELL_PIXTEXT (row1->cell[clist->sort_column])->text; - break; - - default: - break; - } - - switch (row2->cell[clist->sort_column].type) { - case GTK_CELL_TEXT: - text2 = GTK_CELL_TEXT (row2->cell[clist->sort_column])->text; - break; - - case GTK_CELL_PIXTEXT: - text2 = GTK_CELL_PIXTEXT (row2->cell[clist->sort_column])->text; - break; - - default: - break; - } - - if (text2 == NULL) { - return (text1 != NULL); - } - - if (text1 == NULL) { - return -1; - } - - return strcasecmp (text1, text2); -} - -static void -column_clicked (GtkCList *clist, gint column, gpointer user_data) -{ - gtk_clist_set_sort_column (clist, column); - - /* If the user has not clicked the column yet, make sure - * that the sort type is descending the first time. - */ - if (!sort_column_clicked [column]) { - clist->sort_type = GTK_SORT_DESCENDING; - sort_column_clicked [column] = TRUE; - } - - /* Toggle sort type */ - if (clist->sort_type == GTK_SORT_ASCENDING) { - gtk_clist_set_sort_type (clist, GTK_SORT_DESCENDING); - } else { - gtk_clist_set_sort_type (clist, GTK_SORT_ASCENDING); - } - - gtk_clist_sort (clist); -} - -static void -mime_list_reset_row_height (GtkCList *list) -{ - guint height_for_icon; - guint height_for_text; - - height_for_icon = MAX_ICON_HEIGHT_IN_LIST + 1; - height_for_text = GTK_WIDGET (list)->style->font->ascent + - GTK_WIDGET (list)->style->font->descent + 1; - gtk_clist_set_row_height (list, MAX (height_for_icon, height_for_text)); -} - -static GtkWidget * -create_mime_list_and_scroller (void) -{ - GtkWidget *window; - gchar *titles[TOTAL_COLUMNS]; - GList *type_list; - int index; - - titles[0] = _("Description"); - titles[1] = _("MIME Type"); - titles[2] = _("Extension"); - titles[3] = _("Default Action"); - - window = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_set_usize (window, 500, 200); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (window), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - mime_list = gtk_clist_new_with_titles (TOTAL_COLUMNS, titles); - gtk_clist_set_selection_mode (GTK_CLIST (mime_list), GTK_SELECTION_BROWSE); - gtk_clist_set_compare_func (GTK_CLIST (mime_list), (GtkCListCompareFunc) sort_case_insensitive); - - type_list = gnome_vfs_get_registered_mime_types (); - populate_mime_list (type_list, GTK_CLIST (mime_list)); - gnome_vfs_mime_registered_mime_type_list_free (type_list); - - gtk_clist_columns_autosize (GTK_CLIST (mime_list)); - gtk_clist_select_row (GTK_CLIST (mime_list), 0, 0); - gtk_container_add (GTK_CONTAINER (window), mime_list); - - /* Enable all titles */ - gtk_clist_column_titles_active (GTK_CLIST (mime_list)); - gtk_signal_connect (GTK_OBJECT (mime_list), "click_column", - column_clicked, NULL); - - /* Turn off autoresizing of columns */ - for (index = 0; index < TOTAL_COLUMNS; index++) { - gtk_clist_set_column_auto_resize (GTK_CLIST (mime_list), index, FALSE); - } - - /* Make height tall enough for icons to look good. - * This must be done after the list widget is realized, due to - * a bug/design flaw in nautilus_clist_set_row_height. Connecting to - * the "realize" signal is slightly too early, so we connect to - * "map". - */ - gtk_signal_connect (GTK_OBJECT (mime_list), - "map", - mime_list_reset_row_height, - NULL); - - return window; -} - -const char * -nautilus_mime_type_capplet_get_selected_item_mime_type (void) -{ - const char *mime_type; - int row; - GtkCList *clist; - - clist = GTK_CLIST (mime_list); - - if (clist->selection == NULL) { - return NULL; - } - - /* This is a single selection list, so we just use the first item in - * the list to retrieve the data */ - row = GPOINTER_TO_INT (clist->selection->data); - - mime_type = (const char *) gtk_clist_get_row_data (clist, row); - - return mime_type; -} - -/** - * gtk_label_make_bold. - * - * Switches the font of label to a bold equivalent. - * @label: The label. - **/ - -static void -gtk_widget_make_bold (GtkWidget *widget) -{ - GtkStyle *style; - GdkFont *bold_font; - - g_return_if_fail (GTK_IS_WIDGET (widget)); - style = gtk_widget_get_style (widget); - - bold_font = gdk_font_get_bold (style->font); - - if (bold_font == NULL) { - return; - } - - gtk_widget_set_font (widget, bold_font); - gdk_font_unref (bold_font); -} - -/** - * gtk_widget_set_font - * - * Sets the font for a widget's style, managing the style objects. - * @widget: The widget. - * @font: The font. - **/ -static void -gtk_widget_set_font (GtkWidget *widget, GdkFont *font) -{ - GtkStyle *new_style; - - g_return_if_fail (GTK_IS_WIDGET (widget)); - g_return_if_fail (font != NULL); - - new_style = gtk_style_copy (gtk_widget_get_style (widget)); - - gtk_style_set_font (new_style, font); - - gtk_widget_set_style (widget, new_style); - gtk_style_unref (new_style); -} - -/** - * gtk_style_set_font - * - * Sets the font in a style object, managing the ref. counts. - * @style: The style to change. - * @font: The new font. - **/ -static void -gtk_style_set_font (GtkStyle *style, GdkFont *font) -{ - g_return_if_fail (style != NULL); - g_return_if_fail (font != NULL); - - gdk_font_ref (font); - gdk_font_unref (style->font); - style->font = font; -} - -/** - * gdk_font_get_bold - * @plain_font: A font. - * Returns: A bold variant of @plain_font or NULL. - * - * Tries to find a bold flavor of a given font. Returns NULL if none is available. - */ -static GdkFont * -gdk_font_get_bold (const GdkFont *plain_font) -{ - const char *plain_name; - const char *scanner; - char *bold_name; - int count; - GSList *p; - GdkFont *result; - GdkFontPrivate *private_plain; - - private_plain = (GdkFontPrivate *)plain_font; - - if (private_plain->names == NULL) { - return NULL; - } - - - /* -foundry-family-weight-slant-sel_width-add-style-pixels-points-hor_res-ver_res-spacing-average_width-char_set_registry-char_set_encoding */ - - bold_name = NULL; - for (p = private_plain->names; p != NULL; p = p->next) { - plain_name = (const char *)p->data; - scanner = plain_name; - - /* skip past foundry and family to weight */ - for (count = 2; count > 0; count--) { - scanner = strchr (scanner + 1, '-'); - if (!scanner) { - break; - } - } - - if (!scanner) { - /* try the other names in the list */ - continue; - } - g_assert (*scanner == '-'); - - /* copy "-foundry-family-" over */ - scanner++; - bold_name = g_strndup (plain_name, scanner - plain_name); - - /* skip weight */ - scanner = strchr (scanner, '-'); - g_assert (scanner != NULL); - - /* add "bold" and copy everything past weight over */ - bold_name = g_strconcat (bold_name, "bold", scanner, NULL); - break; - } - - if (bold_name == NULL) { - return NULL; - } - - result = gdk_font_load (bold_name); - g_free (bold_name); - - return result; -} - - -/* scale the passed in pixbuf to conform to the passed-in maximum width and height */ -/* utility routine to scale the passed-in pixbuf to be smaller than the maximum allowed size, if necessary */ -static GdkPixbuf * -capplet_gdk_pixbuf_scale_to_fit (GdkPixbuf *pixbuf, int max_width, int max_height) -{ - double scale_factor; - double h_scale = 1.0; - double v_scale = 1.0; - - int width = gdk_pixbuf_get_width(pixbuf); - int height = gdk_pixbuf_get_height(pixbuf); - - if (width > max_width) { - h_scale = max_width / (double) width; - } - if (height > max_height) { - v_scale = max_height / (double) height; - } - scale_factor = MIN (h_scale, v_scale); - - if (scale_factor < 1.0) { - GdkPixbuf *scaled_pixbuf; - /* the width and scale factor are always > 0, so it's OK to round by adding here */ - int scaled_width = floor(width * scale_factor + .5); - int scaled_height = floor(height * scale_factor + .5); - - scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf, scaled_width, scaled_height, GDK_INTERP_BILINEAR); - gdk_pixbuf_unref (pixbuf); - pixbuf = scaled_pixbuf; - } - - return pixbuf; -} diff --git a/capplets/file-types/file-types-capplet.desktop.in b/capplets/file-types/file-types-capplet.desktop.in deleted file mode 100644 index 63ce82810..000000000 --- a/capplets/file-types/file-types-capplet.desktop.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=File Types and Programs -_Comment=Specify which programs are used to open or view each file type -Icon=gnome-ccmime.png -Exec=file-types-capplet -Terminal=0 -Type=Application diff --git a/capplets/file-types/file-types-capplet.h b/capplets/file-types/file-types-capplet.h deleted file mode 100644 index 914a2cb58..000000000 --- a/capplets/file-types/file-types-capplet.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* nautilus-mime-type-capplet.h - * - * Copyright (C) 2000 Free Software Foundaton - * Copyright (C) 2000 Eazel, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Gene Z. Ragan <gzr@eazel.com> - */ - -#ifndef NAUTILUS_MIME_TYPE_CAPPLET_H -#define NAUTILUS_MIME_TYPE_CAPPLET_H - -void nautilus_mime_type_capplet_update_info (const char *mime_type); -void nautilus_mime_type_capplet_update_application_info (const char *mime_type); -void nautilus_mime_type_capplet_update_viewer_info (const char *mime_type); -void nautilus_mime_type_capplet_add_extension (const char *extension); -const char *nautilus_mime_type_capplet_get_selected_item_mime_type (void); -void nautilus_mime_type_capplet_update_mime_list_icon_and_description (const char *mime_string); - -#endif /* NAUTILUS_MIME_TYPE_CAPPLET_H */ diff --git a/capplets/file-types/file-types-capplet.png b/capplets/file-types/file-types-capplet.png Binary files differdeleted file mode 100644 index bfe643589..000000000 --- a/capplets/file-types/file-types-capplet.png +++ /dev/null diff --git a/capplets/file-types/file-types-icon-entry.c b/capplets/file-types/file-types-icon-entry.c deleted file mode 100644 index 1633011a2..000000000 --- a/capplets/file-types/file-types-icon-entry.c +++ /dev/null @@ -1,658 +0,0 @@ -/* NautilusMimeIconEntry widget - Combo box with "Browse" button for files and - * A pick button which can display a list of icons - * in a current directory, the browse button displays - * same dialog as pixmap-entry - * - * Copyright (C) 1998 The Free Software Foundation - * - * Author: George Lebl <jirka@5z.com> - * icon selection based on original dentry-edit code which was: - * Written by: Havoc Pennington, based on code by John Ellis. - */ -#include <config.h> - -#include "file-types-icon-entry.h" -#include "file-types-capplet.h" - -#include <gdk_imlib.h> -#include <gnome.h> -#include <gtk/gtkbutton.h> -#include <gtk/gtkdnd.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkfilesel.h> -#include <gtk/gtkframe.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkmain.h> -#include <gtk/gtksignal.h> -#include <gtk/gtkpixmap.h> -#include <gtk/gtkscrolledwindow.h> -#include <libgnomevfs/gnome-vfs-mime-handlers.h> - -#include <string.h> -#include <sys/stat.h> -#include <unistd.h> - - - -static void nautilus_mime_type_icon_entry_class_init (GnomeIconEntryClass *class); -static void nautilus_mime_type_icon_entry_init (NautilusMimeIconEntry *ientry); - -static GtkVBoxClass *parent_class; - -static GtkTargetEntry drop_types[] = { { "text/uri-list", 0, 0 } }; - -guint -nautilus_mime_type_icon_entry_get_type (void) -{ - static guint icon_entry_type = 0; - - if (!icon_entry_type) { - GtkTypeInfo icon_entry_info = { - "NautilusMimeIconEntry", - sizeof (NautilusMimeIconEntry), - sizeof (GnomeIconEntryClass), - (GtkClassInitFunc) nautilus_mime_type_icon_entry_class_init, - (GtkObjectInitFunc) nautilus_mime_type_icon_entry_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - icon_entry_type = gtk_type_unique (gtk_vbox_get_type (), - &icon_entry_info); - } - - return icon_entry_type; -} - -static void -nautilus_mime_type_icon_entry_class_init (GnomeIconEntryClass *class) -{ - parent_class = gtk_type_class (gtk_hbox_get_type ()); -} - -static void -entry_changed(GtkWidget *widget, NautilusMimeIconEntry *ientry) -{ - gchar *t; - GdkImlibImage *im; - GtkWidget *child; - int w,h; - - g_return_if_fail (ientry != NULL); - g_return_if_fail (NAUTILUS_MIME_IS_ICON_ENTRY (ientry)); - - t = gnome_file_entry_get_full_path(GNOME_FILE_ENTRY(ientry->fentry), - FALSE); - - child = GTK_BIN(ientry->frame)->child; - - if (!t || !g_file_test (t, G_FILE_TEST_ISLINK|G_FILE_TEST_ISFILE) || - !(im = gdk_imlib_load_image (t))) { - if (GNOME_IS_PIXMAP (child)) { - gtk_drag_source_unset (ientry->frame); - gtk_widget_destroy (child); - } - g_free(t); - return; - } - g_free(t); - w = im->rgb_width; - h = im->rgb_height; - if(w>h) { - if(w>48) { - h = h*(48.0/w); - w = 48; - } - } else { - if(h>48) { - w = w*(48.0/h); - h = 48; - } - } - if(GNOME_IS_PIXMAP (child)) { - gnome_pixmap_load_imlib_at_size (GNOME_PIXMAP(child),im, w, h); - } else { - if (child != NULL) { - gtk_widget_destroy (child); - } - - child = gnome_pixmap_new_from_imlib_at_size (im, w, h); - gtk_widget_show (child); - gtk_container_add (GTK_CONTAINER(ientry->frame), child); - - if(!GTK_WIDGET_NO_WINDOW(child)) { - gtk_drag_source_set (child, - GDK_BUTTON1_MASK|GDK_BUTTON3_MASK, - drop_types, 1, - GDK_ACTION_COPY); - } - } - gdk_imlib_destroy_image(im); - - /*gtk_drag_source_set (ientry->frame, - GDK_BUTTON1_MASK|GDK_BUTTON3_MASK, - drop_types, 1, - GDK_ACTION_COPY); - */ -} - -static void -entry_activated(GtkWidget *widget, NautilusMimeIconEntry *ientry) -{ - struct stat buf; - GnomeIconSelection * gis; - gchar *filename; - GtkButton *OK_button; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_ENTRY (widget)); - g_return_if_fail (ientry != NULL); - g_return_if_fail (NAUTILUS_MIME_IS_ICON_ENTRY (ientry)); - - filename = gtk_entry_get_text (GTK_ENTRY (widget)); - - if (!filename) - return; - - stat (filename, &buf); - if (S_ISDIR (buf.st_mode)) { - gis = gtk_object_get_user_data(GTK_OBJECT(ientry)); - gnome_icon_selection_clear (gis, TRUE); - gnome_icon_selection_add_directory (gis, filename); - if (gis->file_list) - gnome_icon_selection_show_icons(gis); - } else { - /* FIXME: This is a hack to act exactly like we've clicked the - * OK button. This should be structured more cleanly. - */ - OK_button = GTK_BUTTON (GNOME_DIALOG (ientry->pick_dialog)->buttons->data); - gtk_button_clicked (OK_button); - } -} - -static void -setup_preview(GtkWidget *widget) -{ - gchar *p; - GList *l; - GtkWidget *pp = NULL; - GdkImlibImage *im; - int w,h; - GtkWidget *frame; - GtkFileSelection *fs; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_WIDGET (widget)); - - frame = gtk_object_get_data(GTK_OBJECT(widget),"frame"); - fs = gtk_object_get_data(GTK_OBJECT(frame),"fs"); - - if((l = gtk_container_children(GTK_CONTAINER(frame))) != NULL) { - pp = l->data; - g_list_free(l); - } - - if(pp) - gtk_widget_destroy(pp); - - p = gtk_file_selection_get_filename(fs); - if(!p || !g_file_test (p,G_FILE_TEST_ISLINK|G_FILE_TEST_ISFILE) || - !(im = gdk_imlib_load_image (p))) - return; - - w = im->rgb_width; - h = im->rgb_height; - if(w>h) { - if(w>100) { - h = h*(100.0/w); - w = 100; - } - } else { - if(h>100) { - w = w*(100.0/h); - h = 100; - } - } - pp = gnome_pixmap_new_from_imlib_at_size (im, w, h); - gtk_widget_show(pp); - gtk_container_add(GTK_CONTAINER(frame),pp); - - gdk_imlib_destroy_image(im); -} - -static void -ientry_destroy(NautilusMimeIconEntry *ientry) -{ - g_return_if_fail (ientry != NULL); - g_return_if_fail (NAUTILUS_MIME_IS_ICON_ENTRY (ientry)); - - if(ientry->fentry) - gtk_widget_unref (ientry->fentry); - if(ientry->pick_dialog) - gtk_widget_destroy(ientry->pick_dialog); - g_free(ientry->pick_dialog_dir); -} - - -static void -browse_clicked (GnomeFileEntry *fentry, NautilusMimeIconEntry *ientry) -{ - GtkWidget *w; - GtkWidget *hbox; - - GtkFileSelection *fs; - - g_return_if_fail (fentry != NULL); - g_return_if_fail (GNOME_IS_FILE_ENTRY (fentry)); - g_return_if_fail (ientry != NULL); - g_return_if_fail (NAUTILUS_MIME_IS_ICON_ENTRY (ientry)); - - if(!fentry->fsw) - return; - fs = GTK_FILE_SELECTION(fentry->fsw); - - hbox = fs->file_list; - do { - hbox = hbox->parent; - if(!hbox) { - g_warning(_("Can't find an hbox, using a normal file " - "selection")); - return; - } - } while(!GTK_IS_HBOX(hbox)); - - w = gtk_frame_new(_("Preview")); - gtk_widget_show(w); - gtk_box_pack_end(GTK_BOX(hbox),w,FALSE,FALSE,0); - gtk_widget_set_usize(w,110,110); - gtk_object_set_data(GTK_OBJECT(w),"fs",fs); - - gtk_object_set_data(GTK_OBJECT(fs->file_list),"frame",w); - gtk_signal_connect(GTK_OBJECT(fs->file_list),"select_row", - GTK_SIGNAL_FUNC(setup_preview),NULL); - gtk_object_set_data(GTK_OBJECT(fs->selection_entry),"frame",w); - gtk_signal_connect_while_alive(GTK_OBJECT(fs->selection_entry), - "changed", - GTK_SIGNAL_FUNC(setup_preview),NULL, - GTK_OBJECT(fs)); -} - -static void -cancel_pressed (GtkButton * button, NautilusMimeIconEntry * icon_entry) -{ - GnomeIconSelection * gis; - - g_return_if_fail (icon_entry != NULL); - g_return_if_fail (NAUTILUS_MIME_IS_ICON_ENTRY (icon_entry)); - - gis = gtk_object_get_user_data(GTK_OBJECT(icon_entry)); - gnome_icon_selection_stop_loading(gis); -} - - -void -nautilus_mime_type_show_icon_selection (NautilusMimeIconEntry *icon_entry) -{ - GnomeFileEntry *fe; - gchar *p; - gchar *curfile; - GtkWidget *tl; - - g_return_if_fail (icon_entry != NULL); - g_return_if_fail (NAUTILUS_MIME_IS_ICON_ENTRY (icon_entry)); - - fe = GNOME_FILE_ENTRY (icon_entry->fentry); - p = gnome_file_entry_get_full_path (fe, FALSE); - curfile = nautilus_mime_type_icon_entry_get_full_filename (icon_entry); - - /* Are we part of a modal window? If so, we need to be modal too. */ - tl = gtk_widget_get_toplevel (GTK_WIDGET (icon_entry->frame)); - - if (!p) { - if (fe->default_path) { - p = g_strdup (fe->default_path); - } else { - /* get around the g_free/free issue */ - gchar *cwd = g_get_current_dir (); - p = g_strdup (cwd); - g_free (cwd); - } - gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (icon_entry->fentry))), - p); - } - - /* figure out the directory */ - if (!g_file_test (p, G_FILE_TEST_ISDIR)) { - gchar *d; - d = g_dirname (p); - g_free (p); - p = d; - if (!g_file_test (p, G_FILE_TEST_ISDIR)) { - g_free (p); - if (fe->default_path) { - p = g_strdup (fe->default_path); - } else { - /*get around the g_free/free issue*/ - gchar *cwd = g_get_current_dir (); - p = g_strdup (cwd); - free(cwd); - } - gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (icon_entry->fentry))), - p); - g_return_if_fail (g_file_test (p,G_FILE_TEST_ISDIR)); - } - } - - - if (icon_entry->pick_dialog == NULL || icon_entry->pick_dialog_dir == NULL || - strcmp(p, icon_entry->pick_dialog_dir) != 0) { - GtkWidget *iconsel; - - if (icon_entry->pick_dialog) { - gtk_container_remove (GTK_CONTAINER (icon_entry->fentry->parent), icon_entry->fentry); - gtk_widget_destroy (icon_entry->pick_dialog); - } - - g_free(icon_entry->pick_dialog_dir); - icon_entry->pick_dialog_dir = NULL; - - icon_entry->pick_dialog_dir = p; - icon_entry->pick_dialog = - gnome_dialog_new(GNOME_FILE_ENTRY(icon_entry->fentry)->browse_dialog_title, - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, - NULL); - if (GTK_WINDOW (tl)->modal) { - gtk_window_set_modal (GTK_WINDOW (icon_entry->pick_dialog), TRUE); - gnome_dialog_set_parent (GNOME_DIALOG (icon_entry->pick_dialog), GTK_WINDOW (tl)); - } - gnome_dialog_close_hides(GNOME_DIALOG(icon_entry->pick_dialog), TRUE); - gnome_dialog_set_close (GNOME_DIALOG(icon_entry->pick_dialog), TRUE); - - gtk_window_set_policy(GTK_WINDOW(icon_entry->pick_dialog), - TRUE, TRUE, TRUE); - - iconsel = gnome_icon_selection_new(); - - gtk_object_set_user_data(GTK_OBJECT(icon_entry), iconsel); - - gnome_icon_selection_add_directory (GNOME_ICON_SELECTION(iconsel), icon_entry->pick_dialog_dir); - - gtk_window_set_title (GTK_WINDOW (icon_entry->pick_dialog), _("Select an icon")); - - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (icon_entry->pick_dialog)->vbox), - icon_entry->fentry, FALSE, FALSE, 0); - - gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(icon_entry->pick_dialog)->vbox), - iconsel, TRUE, TRUE, 0); - - gtk_widget_show_all(icon_entry->pick_dialog); - - gnome_icon_selection_show_icons(GNOME_ICON_SELECTION(iconsel)); - - if(curfile) - gnome_icon_selection_select_icon(GNOME_ICON_SELECTION(iconsel), - g_filename_pointer(curfile)); - - /* FIXME: - * OK button is handled by caller, Cancel button is handled here. - * This could be cleaned up further. - */ - gnome_dialog_button_connect(GNOME_DIALOG(icon_entry->pick_dialog), - 1, /* Cancel button */ - GTK_SIGNAL_FUNC(cancel_pressed), - icon_entry); - - } else { - GnomeIconSelection *gis = - gtk_object_get_user_data(GTK_OBJECT(icon_entry)); - if(!GTK_WIDGET_VISIBLE(icon_entry->pick_dialog)) - gtk_widget_show(icon_entry->pick_dialog); - if(gis) { - gnome_icon_selection_show_icons(gis); - } - } -} - -gchar * -nautilus_mime_type_icon_entry_get_relative_filename (NautilusMimeIconEntry *ientry) -{ - char *filename; - char *result; - char **path_parts; - - result = NULL; - filename = nautilus_mime_type_icon_entry_get_full_filename (NAUTILUS_MIME_ICON_ENTRY (ientry)); - if (filename != NULL) { - path_parts = g_strsplit (filename, "/share/pixmaps/", 0); - g_free (filename); - - if (path_parts[1] != NULL) { - result = g_strdup (path_parts[1]); - } - - g_strfreev (path_parts); - } - - return result; -} - -static void -nautilus_mime_type_icon_entry_init (NautilusMimeIconEntry *ientry) -{ - GtkWidget *w; - gchar *p; - - gtk_box_set_spacing (GTK_BOX (ientry), 4); - - gtk_signal_connect(GTK_OBJECT(ientry),"destroy", - GTK_SIGNAL_FUNC(ientry_destroy), NULL); - - ientry->pick_dialog = NULL; - ientry->pick_dialog_dir = NULL; - - w = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); - gtk_widget_show(w); - gtk_box_pack_start (GTK_BOX (ientry), w, TRUE, TRUE, 0); - ientry->frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (ientry->frame), GTK_SHADOW_IN); - gtk_drag_dest_set (GTK_WIDGET (ientry->frame), - GTK_DEST_DEFAULT_MOTION | - GTK_DEST_DEFAULT_HIGHLIGHT | - GTK_DEST_DEFAULT_DROP, - drop_types, 1, GDK_ACTION_COPY); - - /*60x60 is just larger then default 48x48, though icon sizes - are supposed to be selectable I guess*/ - gtk_widget_set_usize (ientry->frame,60,60); - gtk_container_add (GTK_CONTAINER (w), ientry->frame); - gtk_widget_show (ientry->frame); - - ientry->fentry = gnome_file_entry_new (NULL,NULL); - gnome_file_entry_set_modal (GNOME_FILE_ENTRY (ientry->fentry), TRUE); - gtk_widget_ref (ientry->fentry); - gtk_signal_connect_after(GTK_OBJECT(ientry->fentry),"browse_clicked", - GTK_SIGNAL_FUNC(browse_clicked), - ientry); - - gtk_widget_show (ientry->fentry); - - p = gnome_pixmap_file ("."); - gnome_file_entry_set_default_path (GNOME_FILE_ENTRY(ientry->fentry), p); - g_free (p); - - w = gnome_file_entry_gtk_entry(GNOME_FILE_ENTRY(ientry->fentry)); -/* gtk_signal_connect_while_alive(GTK_OBJECT(w), "changed", - GTK_SIGNAL_FUNC(entry_changed), - ientry, GTK_OBJECT(ientry));*/ - gtk_signal_connect_while_alive(GTK_OBJECT(w), "activate", - GTK_SIGNAL_FUNC(entry_activated), - ientry, GTK_OBJECT(ientry)); - - - /*just in case there is a default that is an image*/ - entry_changed(w,ientry); -} - -/** - * nautilus_mime_type_icon_entry_new: - * @history_id: the id given to #gnome_entry_new - * @browse_dialog_title: title of the browse dialog and icon selection dialog - * - * Description: Creates a new icon entry widget - * - * Returns: Returns the new object - **/ -GtkWidget * -nautilus_mime_type_icon_entry_new (const gchar *history_id, const gchar *browse_dialog_title) -{ - NautilusMimeIconEntry *ientry; - GtkWidget *gentry; - - ientry = gtk_type_new (nautilus_mime_type_icon_entry_get_type ()); - - /* Keep in sync with gnome_entry_new() - or better yet, - add a _construct() method once we are in development - branch. - */ - - gentry = gnome_file_entry_gnome_entry(GNOME_FILE_ENTRY(ientry->fentry)); - - gnome_entry_set_history_id (GNOME_ENTRY (gentry), history_id); - gnome_entry_load_history (GNOME_ENTRY (gentry)); - gnome_file_entry_set_title (GNOME_FILE_ENTRY(ientry->fentry), - browse_dialog_title); - - return GTK_WIDGET (ientry); -} - -/** - * nautilus_mime_type_icon_entry_gnome_file_entry: - * @ientry: the NautilusMimeIconEntry to work with - * - * Description: Get the GnomeFileEntry widget that's part of the entry - * - * Returns: Returns GnomeFileEntry widget - **/ -GtkWidget * -nautilus_mime_type_icon_entry_gnome_file_entry (NautilusMimeIconEntry *ientry) -{ - g_return_val_if_fail (ientry != NULL, NULL); - g_return_val_if_fail (NAUTILUS_MIME_IS_ICON_ENTRY (ientry), NULL); - - return ientry->fentry; -} - -/** - * nautilus_mime_type_icon_entry_gnome_entry: - * @ientry: the NautilusMimeIconEntry to work with - * - * Description: Get the GnomeEntry widget that's part of the entry - * - * Returns: Returns GnomeEntry widget - **/ -GtkWidget * -nautilus_mime_type_icon_entry_gnome_entry (NautilusMimeIconEntry *ientry) -{ - g_return_val_if_fail (ientry != NULL, NULL); - g_return_val_if_fail (NAUTILUS_MIME_IS_ICON_ENTRY (ientry), NULL); - - return gnome_file_entry_gnome_entry(GNOME_FILE_ENTRY(ientry->fentry)); -} - -/** - * nautilus_mime_type_icon_entry_gtk_entry: - * @ientry: the NautilusMimeIconEntry to work with - * - * Description: Get the GtkEntry widget that's part of the entry - * - * Returns: Returns GtkEntry widget - **/ -GtkWidget * -nautilus_mime_type_icon_entry_gtk_entry (NautilusMimeIconEntry *ientry) -{ - g_return_val_if_fail (ientry != NULL, NULL); - g_return_val_if_fail (NAUTILUS_MIME_IS_ICON_ENTRY (ientry), NULL); - - return gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (ientry->fentry)); -} - -/** - * nautilus_mime_type_icon_entry_set_pixmap_subdir: - * @ientry: the NautilusMimeIconEntry to work with - * @subdir: subdirectory - * - * Description: Sets the subdirectory below gnome's default - * pixmap directory to use as the default path for the file - * entry. - * - * Returns: - **/ -void -nautilus_mime_type_icon_entry_set_pixmap_subdir(NautilusMimeIconEntry *ientry, const gchar *subdir) -{ - gchar *p; - g_return_if_fail (ientry != NULL); - g_return_if_fail (NAUTILUS_MIME_IS_ICON_ENTRY (ientry)); - - if(!subdir) - subdir = "."; - - p = gnome_pixmap_file (subdir); - gnome_file_entry_set_default_path(GNOME_FILE_ENTRY(ientry->fentry),p); - g_free(p); -} - -/** - * nautilus_mime_type_icon_entry_set_icon: - * @ientry: the NautilusMimeIconEntry to work with - * @filename: a filename - * - * Description: Sets the icon of NautilusMimeIconEntry to be the one pointed to by - * @filename (in the current subdirectory). - * - * Returns: - **/ -void -nautilus_mime_type_icon_entry_set_icon (NautilusMimeIconEntry *ientry, const gchar *filename) -{ - g_return_if_fail (ientry != NULL); - g_return_if_fail (NAUTILUS_MIME_IS_ICON_ENTRY (ientry)); - - if(!filename) { - filename = ""; - } - - gtk_entry_set_text (GTK_ENTRY (nautilus_mime_type_icon_entry_gtk_entry (ientry)), filename); - entry_changed (NULL, ientry); -} - -/** - * nautilus_mime_type_icon_entry_get_full_filename: - * @ientry: the NautilusMimeIconEntry to work with - * - * Description: Gets the file name of the image if it was possible - * to load it into the preview. That is, it will only return a filename - * if the image exists and it was possible to load it as an image. - * - * Returns: a newly allocated string with the path or %NULL if it - * couldn't load the file - **/ -gchar * -nautilus_mime_type_icon_entry_get_full_filename (NautilusMimeIconEntry *ientry) -{ - GtkWidget *child; - - g_return_val_if_fail (ientry != NULL,NULL); - g_return_val_if_fail (NAUTILUS_MIME_IS_ICON_ENTRY (ientry),NULL); - - child = GTK_BIN(ientry->frame)->child; - - /* this happens if it doesn't exist or isn't an image */ - if (!GNOME_IS_PIXMAP (child)) { - return NULL; - } - - return gnome_file_entry_get_full_path(GNOME_FILE_ENTRY(ientry->fentry), - TRUE); -} diff --git a/capplets/file-types/file-types-icon-entry.h b/capplets/file-types/file-types-icon-entry.h deleted file mode 100644 index 1ffb954fe..000000000 --- a/capplets/file-types/file-types-icon-entry.h +++ /dev/null @@ -1,72 +0,0 @@ -/* NautilusMimeIconEntry widget - Combo box with "Browse" button for files and - * A pick button which can display a list of icons - * in a current directory, the browse button displays - * same dialog as pixmap-entry - * - * Copyright (C) 1998 The Free Software Foundation - * - * Author: George Lebl <jirka@5z.com> - * icon selection based on original dentry-edit code which was: - * Written by: Havoc Pennington, based on code by John Ellis. - */ - -#ifndef NAUTILUS_MIME_TYPE_ICON_ENTRY_H -#define NAUTILUS_MIME_TYPE_ICON_ENTRY_H - -#include <gtk/gtkframe.h> -#include <gtk/gtkvbox.h> -#include <libgnome/gnome-defs.h> -#include <libgnomeui/gnome-file-entry.h> - - -BEGIN_GNOME_DECLS - - -#define NAUTILUS_TYPE_MIME_ICON_ENTRY (nautilus_mime_type_icon_entry_get_type ()) -#define NAUTILUS_MIME_ICON_ENTRY(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_MIME_ICON_ENTRY, NautilusMimeIconEntry)) -#define NAUTILUS_MIME_ICON_ENTRY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_MIME_ICON_ENTRY, NautilusMimeIconEntryClass)) -#define NAUTILUS_MIME_IS_ICON_ENTRY(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_MIME_ICON_ENTRY)) -#define NAUTILUS_MIME_IS_ICON_ENTRY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_MIME_ICON_ENTRY)) - - -typedef struct _NautilusMimeIconEntry NautilusMimeIconEntry; -typedef struct _NautilusMimeIconEntryClass NautilusMimeIconEntryClass; - -struct _NautilusMimeIconEntry { - GtkVBox vbox; - - GtkWidget *fentry; - GtkWidget *frame; - - GtkWidget *pick_dialog; - gchar *pick_dialog_dir; -}; - -struct _NautilusMimeIconEntryClass { - GtkVBoxClass parent_class; -}; - - -guint nautilus_mime_type_icon_entry_get_type (void); -GtkWidget *nautilus_mime_type_icon_entry_new (const gchar *history_id, - const gchar *browse_dialog_title); - -/*by default gnome_pixmap entry sets the default directory to the - gnome pixmap directory, this will set it to a subdirectory of that, - or one would use the file_entry functions for any other path*/ -void nautilus_mime_type_icon_entry_set_pixmap_subdir(NautilusMimeIconEntry *ientry, - const gchar *subdir); -void nautilus_mime_type_icon_entry_set_icon(NautilusMimeIconEntry *ientry, - const gchar *filename); -GtkWidget *nautilus_mime_type_icon_entry_gnome_file_entry(NautilusMimeIconEntry *ientry); -GtkWidget *nautilus_mime_type_icon_entry_gnome_entry (NautilusMimeIconEntry *ientry); -GtkWidget *nautilus_mime_type_icon_entry_gtk_entry (NautilusMimeIconEntry *ientry); - -/*only return a file if it was possible to load it with imlib*/ -gchar *nautilus_mime_type_icon_entry_get_full_filename (NautilusMimeIconEntry *ientry); -gchar *nautilus_mime_type_icon_entry_get_relative_filename (NautilusMimeIconEntry *ientry); -void nautilus_mime_type_show_icon_selection (NautilusMimeIconEntry * ientry); - -END_GNOME_DECLS - -#endif diff --git a/capplets/file-types/file-types-properties.glade b/capplets/file-types/file-types-properties.glade deleted file mode 100644 index e69de29bb..000000000 --- a/capplets/file-types/file-types-properties.glade +++ /dev/null diff --git a/capplets/file-types/file-types.desktop.in.in b/capplets/file-types/file-types.desktop.in.in deleted file mode 100644 index 63ce82810..000000000 --- a/capplets/file-types/file-types.desktop.in.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=File Types and Programs -_Comment=Specify which programs are used to open or view each file type -Icon=gnome-ccmime.png -Exec=file-types-capplet -Terminal=0 -Type=Application diff --git a/capplets/file-types/file-types.desktop.in.in-10478 b/capplets/file-types/file-types.desktop.in.in-10478 deleted file mode 100644 index 63ce82810..000000000 --- a/capplets/file-types/file-types.desktop.in.in-10478 +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=File Types and Programs -_Comment=Specify which programs are used to open or view each file type -Icon=gnome-ccmime.png -Exec=file-types-capplet -Terminal=0 -Type=Application diff --git a/capplets/file-types/libuuid/.cvsignore b/capplets/file-types/libuuid/.cvsignore deleted file mode 100644 index 051d1bd50..000000000 --- a/capplets/file-types/libuuid/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -Makefile -Makefile.in -.deps diff --git a/capplets/file-types/libuuid/Makefile.am b/capplets/file-types/libuuid/Makefile.am deleted file mode 100644 index 2d29f918e..000000000 --- a/capplets/file-types/libuuid/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -NULL = - -noinst_LIBRARIES = libuuid.a - - -noinst_HEADERS = \ - uuid.h \ - uuidP.h \ - $(NULL) - -libuuid_a_SOURCES = \ - clear.c \ - compare.c \ - copy.c \ - gen_uuid.c \ - isnull.c \ - pack.c \ - parse.c \ - unpack.c \ - unparse.c \ - uuid_time.c \ - $(NULL) - -INCLUDES = \ - @GLIB_CFLAGS@ \ - $(WERROR) \ - $(NULL) diff --git a/capplets/file-types/libuuid/clear.c b/capplets/file-types/libuuid/clear.c deleted file mode 100644 index 32e26d4fb..000000000 --- a/capplets/file-types/libuuid/clear.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * clear.c -- Clear a UUID - * - * Copyright (C) 1996, 1997 Theodore Ts'o. - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Public - * License. - * %End-Header% - */ - -#include "string.h" - -#include "uuidP.h" - -void uuid_clear(uuid_t uu) -{ - memset(uu, 0, 16); -} - diff --git a/capplets/file-types/libuuid/compare.c b/capplets/file-types/libuuid/compare.c deleted file mode 100644 index 3d07b5dbc..000000000 --- a/capplets/file-types/libuuid/compare.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * compare.c --- compare whether or not two UUID's are the same - * - * Returns 0 if the two UUID's are different, and 1 if they are the same. - * - * Copyright (C) 1996, 1997 Theodore Ts'o. - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Public - * License. - * %End-Header% - */ - -#include "uuidP.h" -#include <string.h> - -#define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1); - -int uuid_compare(uuid_t uu1, uuid_t uu2) -{ - struct uuid uuid1, uuid2; - - uuid_unpack(uu1, &uuid1); - uuid_unpack(uu2, &uuid2); - - UUCMP(uuid1.time_low, uuid2.time_low); - UUCMP(uuid1.time_mid, uuid2.time_mid); - UUCMP(uuid1.time_hi_and_version, uuid2.time_hi_and_version); - UUCMP(uuid1.clock_seq, uuid2.clock_seq); - return memcmp(uuid1.node, uuid2.node, 6); -} - diff --git a/capplets/file-types/libuuid/copy.c b/capplets/file-types/libuuid/copy.c deleted file mode 100644 index 5d0efc4aa..000000000 --- a/capplets/file-types/libuuid/copy.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * copy.c --- copy UUIDs - * - * Copyright (C) 1996, 1997 Theodore Ts'o. - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Public - * License. - * %End-Header% - */ - -#include "uuidP.h" - -void uuid_copy(uuid_t uu1, uuid_t uu2) -{ - unsigned char *cp1, *cp2; - int i; - - for (i=0, cp1 = uu1, cp2 = uu2; i < 16; i++) - *cp1++ = *cp2++; -} diff --git a/capplets/file-types/libuuid/gen_uuid.c b/capplets/file-types/libuuid/gen_uuid.c deleted file mode 100644 index 1b3b88105..000000000 --- a/capplets/file-types/libuuid/gen_uuid.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * gen_uuid.c --- generate a DCE-compatible uuid - * - * Copyright (C) 1996, 1997 Theodore Ts'o. - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Public - * License. - * %End-Header% - */ - -#include <config.h> -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sys/stat.h> -#include <sys/file.h> -#include <sys/ioctl.h> -#include <sys/socket.h> -#ifdef HAVE_SYS_SOCKIO_H -#include <sys/sockio.h> -#endif -#ifdef HAVE_NET_IF_H -#include <net/if.h> -#endif -#ifdef HAVE_NETINET_IN_H -#include <netinet/in.h> -#endif - -#include "uuidP.h" - -#ifdef HAVE_SRANDOM -#define srand(x) srandom(x) -#define rand() random() -#endif - -/* - * Generate a series of random bytes. Use /dev/urandom if possible, - * and if not, use srandom/random. - */ -static void get_random_bytes(void *buf, int nbytes) -{ - static int fd = -2; - int i; - char *cp = (char *) buf; - - if (fd == -2) { - fd = open("/dev/urandom", O_RDONLY); - srand((getpid() << 16) ^ getuid() ^ time(0)); - } - if (fd >= 0) { - while (nbytes > 0) { - i = read(fd, cp, nbytes); - if (i < 0) { - if ((errno == EINTR) || (errno == EAGAIN)) - continue; - break; - } - nbytes -= i; - cp += i; - } - } - if (nbytes == 0) - return; - - /* XXX put something better here if no /dev/random! */ - for (i=0; i < nbytes; i++) - *cp++ = rand() & 0xFF; - return; - -} - -/* - * Get the ethernet hardware address, if we can find it... - */ -static int get_node_id(unsigned char *node_id) -{ -#ifdef HAVE_NET_IF_H - int sd; - struct ifreq ifr, *ifrp; - struct ifconf ifc; - char buf[1024]; - int n, i; - unsigned char *a; - -/* - * BSD 4.4 defines the size of an ifreq to be - * max(sizeof(ifreq), sizeof(ifreq.ifr_name)+ifreq.ifr_addr.sa_len - * However, under earlier systems, sa_len isn't present, so the size is - * just sizeof(struct ifreq) - */ -#ifdef HAVE_SA_LEN -#ifndef max -#define max(a,b) ((a) > (b) ? (a) : (b)) -#endif -#define ifreq_size(i) max(sizeof(struct ifreq),\ - sizeof((i).ifr_name)+(i).ifr_addr.sa_len) -#else -#define ifreq_size(i) sizeof(struct ifreq) -#endif /* HAVE_SA_LEN*/ - - sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); - if (sd < 0) { - return -1; - } - memset(buf, 0, sizeof(buf)); - ifc.ifc_len = sizeof(buf); - ifc.ifc_buf = buf; - if (ioctl (sd, SIOCGIFCONF, (char *)&ifc) < 0) { - close(sd); - return -1; - } - n = ifc.ifc_len; - for (i = 0; i < n; i+= ifreq_size(*ifr) ) { - ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i); - strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ); -#ifdef SIOCGIFHWADDR - if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0) - continue; - a = (unsigned char *) &ifr.ifr_hwaddr.sa_data; -#else -#ifdef SIOCGENADDR - if (ioctl(sd, SIOCGENADDR, &ifr) < 0) - continue; - a = (unsigned char *) ifr.ifr_enaddr; -#else - /* - * XXX we don't have a way of getting the hardware - * address - */ - close(sd); - return 0; -#endif /* SIOCGENADDR */ -#endif /* SIOCGIFHWADDR */ - if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5]) - continue; - if (node_id) { - memcpy(node_id, a, 6); - close(sd); - return 1; - } - } - close(sd); -#endif - return 0; -} - -/* Assume that the gettimeofday() has microsecond granularity */ -#define MAX_ADJUSTMENT 10 - -static int get_clock(guint32 *clock_high, guint32 *clock_low, guint16 *ret_clock_seq) -{ - static int adjustment = 0; - static struct timeval last = {0, 0}; - static guint16 clock_seq; - struct timeval tv; - unsigned long long clock_reg; - -try_again: - gettimeofday(&tv, 0); - if ((last.tv_sec == 0) && (last.tv_usec == 0)) { - get_random_bytes(&clock_seq, sizeof(clock_seq)); - clock_seq &= 0x1FFF; - last = tv; - last.tv_sec--; - } - if ((tv.tv_sec < last.tv_sec) || - ((tv.tv_sec == last.tv_sec) && - (tv.tv_usec < last.tv_usec))) { - clock_seq = (clock_seq+1) & 0x1FFF; - adjustment = 0; - } else if ((tv.tv_sec == last.tv_sec) && - (tv.tv_usec == last.tv_usec)) { - if (adjustment >= MAX_ADJUSTMENT) - goto try_again; - adjustment++; - } else - adjustment = 0; - - clock_reg = tv.tv_usec*10 + adjustment; - clock_reg += ((unsigned long long) tv.tv_sec)*10000000; - clock_reg += (((unsigned long long) 0x01B21DD2) << 32) + 0x13814000; - - *clock_high = clock_reg >> 32; - *clock_low = clock_reg; - *ret_clock_seq = clock_seq; - return 0; -} - -void uuid_generate_time(uuid_t out) -{ - static unsigned char node_id[6]; - static int has_init = 0; - struct uuid uu; - guint32 clock_mid; - - if (!has_init) { - if (get_node_id(node_id) <= 0) { - get_random_bytes(node_id, 6); - /* - * Set multicast bit, to prevent conflicts - * with IEEE 802 addresses obtained from - * network cards - */ - node_id[0] |= 0x80; - } - has_init = 1; - } - get_clock(&clock_mid, &uu.time_low, &uu.clock_seq); - uu.clock_seq |= 0x8000; - uu.time_mid = (guint16) clock_mid; - uu.time_hi_and_version = (clock_mid >> 16) | 0x1000; - memcpy(uu.node, node_id, 6); - uuid_pack(&uu, out); -} - -void uuid_generate_random(uuid_t out) -{ - uuid_t buf; - struct uuid uu; - - get_random_bytes(buf, sizeof(buf)); - uuid_unpack(buf, &uu); - - uu.clock_seq = (uu.clock_seq & 0x3FFF) | 0x8000; - uu.time_hi_and_version = (uu.time_hi_and_version & 0x0FFF) | 0x4000; - uuid_pack(&uu, out); -} - -/* - * This is the generic front-end to uuid_generate_random and - * uuid_generate_time. It uses uuid_generate_random only if - * /dev/urandom is available, since otherwise we won't have - * high-quality randomness. - */ -void uuid_generate(uuid_t out) -{ - static int has_random = -1; - - if (has_random < 0) { - if (access("/dev/urandom", R_OK) == 0) - has_random = 1; - else - has_random = 0; - } - if (has_random) - uuid_generate_random(out); - else - uuid_generate_time(out); -} - diff --git a/capplets/file-types/libuuid/gen_uuid_nt.c b/capplets/file-types/libuuid/gen_uuid_nt.c deleted file mode 100644 index 6092c070d..000000000 --- a/capplets/file-types/libuuid/gen_uuid_nt.c +++ /dev/null @@ -1,92 +0,0 @@ -/*
- * gen_uuid_nt.c -- Use NT api to generate uuid
- *
- * Written by Andrey Shedel (andreys@ns.cr.cyco.com)
- */
-
-
-#include "uuidP.h"
-
-#pragma warning(push,4)
-
-#pragma comment(lib, "ntdll.lib")
-
-//
-// Here is a nice example why it's not a good idea
-// to use native API in ordinary applications.
-// Number of parameters in function below was changed from 3 to 4
-// for NT5.
-//
-//
-// NTSYSAPI
-// NTSTATUS
-// NTAPI
-// NtAllocateUuids(
-// OUT PULONG p1,
-// OUT PULONG p2,
-// OUT PULONG p3,
-// OUT PUCHAR Seed // 6 bytes
-// );
-//
-//
-
-unsigned long
-__stdcall
-NtAllocateUuids(
- void* p1, // 8 bytes
- void* p2, // 4 bytes
- void* p3 // 4 bytes
- );
-
-typedef
-unsigned long
-(__stdcall*
-NtAllocateUuids_2000)(
- void* p1, // 8 bytes
- void* p2, // 4 bytes
- void* p3, // 4 bytes
- void* seed // 6 bytes
- );
-
-
-
-//
-// Nice, but instead of including ntddk.h ot winnt.h
-// I should define it here because they MISSED __stdcall in those headers.
-//
-
-__declspec(dllimport)
-struct _TEB*
-__stdcall
-NtCurrentTeb(void);
-
-
-//
-// The only way to get version information from the system is to examine
-// one stored in PEB. But it's pretty dangerouse because this value could
-// be altered in image header.
-//
-
-static
-int
-Nt5(void)
-{
- //return NtCuttentTeb()->Peb->OSMajorVersion >= 5;
- return (int)*(int*)((char*)(int)(*(int*)((char*)NtCurrentTeb() + 0x30)) + 0xA4) >= 5;
-}
-
-
-
-
-void uuid_generate(uuid_t out)
-{
- if(Nt5())
- {
- unsigned char seed[6];
- ((NtAllocateUuids_2000)NtAllocateUuids)(out, ((char*)out)+8, ((char*)out)+12, &seed[0] );
- }
- else
- {
- NtAllocateUuids(out, ((char*)out)+8, ((char*)out)+12);
- }
-}
diff --git a/capplets/file-types/libuuid/isnull.c b/capplets/file-types/libuuid/isnull.c deleted file mode 100644 index 43b81f879..000000000 --- a/capplets/file-types/libuuid/isnull.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * isnull.c --- Check whether or not the UUID is null - * - * Copyright (C) 1996, 1997 Theodore Ts'o. - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Public - * License. - * %End-Header% - */ - -#include "uuidP.h" - -/* Returns 1 if the uuid is the NULL uuid */ -int uuid_is_null(uuid_t uu) -{ - unsigned char *cp; - int i; - - for (i=0, cp = uu; i < 16; i++) - if (*cp++) - return 0; - return 1; -} - diff --git a/capplets/file-types/libuuid/pack.c b/capplets/file-types/libuuid/pack.c deleted file mode 100644 index 94be488aa..000000000 --- a/capplets/file-types/libuuid/pack.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Internal routine for packing UUID's - * - * Copyright (C) 1996, 1997 Theodore Ts'o. - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Public - * License. - * %End-Header% - */ - -#include <string.h> -#include "uuidP.h" - -void uuid_pack(struct uuid *uu, uuid_t ptr) -{ - guint32 tmp; - unsigned char *out = ptr; - - tmp = uu->time_low; - out[3] = (unsigned char) tmp; - tmp >>= 8; - out[2] = (unsigned char) tmp; - tmp >>= 8; - out[1] = (unsigned char) tmp; - tmp >>= 8; - out[0] = (unsigned char) tmp; - - tmp = uu->time_mid; - out[5] = (unsigned char) tmp; - tmp >>= 8; - out[4] = (unsigned char) tmp; - - tmp = uu->time_hi_and_version; - out[7] = (unsigned char) tmp; - tmp >>= 8; - out[6] = (unsigned char) tmp; - - tmp = uu->clock_seq; - out[9] = (unsigned char) tmp; - tmp >>= 8; - out[8] = (unsigned char) tmp; - - memcpy(out+10, uu->node, 6); -} - diff --git a/capplets/file-types/libuuid/parse.c b/capplets/file-types/libuuid/parse.c deleted file mode 100644 index ea6ce7909..000000000 --- a/capplets/file-types/libuuid/parse.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * parse.c --- UUID parsing - * - * Copyright (C) 1996, 1997 Theodore Ts'o. - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Public - * License. - * %End-Header% - */ - -#include <stdlib.h> -#include <stdio.h> -#include <ctype.h> -#include <string.h> - -#include "uuidP.h" - -int uuid_parse(char *in, uuid_t uu) -{ - struct uuid uuid; - int i; - char *cp, buf[3]; - - if (strlen(in) != 36) - return -1; - for (i=0, cp = in; i <= 36; i++,cp++) { - if ((i == 8) || (i == 13) || (i == 18) || - (i == 23)) - if (*cp == '-') - continue; - if (i== 36) - if (*cp == 0) - continue; - if (!isxdigit((guchar) *cp)) - return -1; - } - uuid.time_low = strtoul(in, NULL, 16); - uuid.time_mid = strtoul(in+9, NULL, 16); - uuid.time_hi_and_version = strtoul(in+14, NULL, 16); - uuid.clock_seq = strtoul(in+19, NULL, 16); - cp = in+24; - buf[2] = 0; - for (i=0; i < 6; i++) { - buf[0] = *cp++; - buf[1] = *cp++; - uuid.node[i] = strtoul(buf, NULL, 16); - } - - uuid_pack(&uuid, uu); - return 0; -} diff --git a/capplets/file-types/libuuid/tst_uuid.c b/capplets/file-types/libuuid/tst_uuid.c deleted file mode 100644 index b9fc5f69a..000000000 --- a/capplets/file-types/libuuid/tst_uuid.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * tst_uuid.c --- test program from the UUID library - * - * Copyright (C) 1996, 1997, 1998 Theodore Ts'o. - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Public - * License. - * %End-Header% - */ - -#include <stdio.h> -#include <linux/ext2_fs.h> - -#include "uuid.h" - -int -main(int argc, char **argv) -{ - uuid_t buf, tst; - char str[100]; - struct timeval tv; - time_t time_reg; - unsigned char *cp; - int i; - int failed = 0; - int type, variant; - - uuid_generate(buf); - uuid_unparse(buf, str); - printf("UUID generate = %s\n", str); - printf("UUID: "); - for (i=0, cp = (unsigned char *) &buf; i < 16; i++) { - printf("%02x", *cp++); - } - printf("\n"); - type = uuid_type(buf); variant = uuid_variant(buf); - printf("UUID type = %d, UUID variant = %d\n", type, variant); - if (variant != UUID_VARIANT_DCE) { - printf("Incorrect UUID Variant; was expecting DCE!\n"); - failed++; - } - printf("\n"); - - uuid_generate_random(buf); - uuid_unparse(buf, str); - printf("UUID random string = %s\n", str); - printf("UUID: "); - for (i=0, cp = (unsigned char *) &buf; i < 16; i++) { - printf("%02x", *cp++); - } - printf("\n"); - type = uuid_type(buf); variant = uuid_variant(buf); - printf("UUID type = %d, UUID variant = %d\n", type, variant); - if (variant != UUID_VARIANT_DCE) { - printf("Incorrect UUID Variant; was expecting DCE!\n"); - failed++; - } - if (type != 4) { - printf("Incorrect UUID type; was expecting " - "4 (random type)!\n"); - failed++; - } - printf("\n"); - - uuid_generate_time(buf); - uuid_unparse(buf, str); - printf("UUID string = %s\n", str); - printf("UUID time: "); - for (i=0, cp = (unsigned char *) &buf; i < 16; i++) { - printf("%02x", *cp++); - } - printf("\n"); - type = uuid_type(buf); variant = uuid_variant(buf); - printf("UUID type = %d, UUID variant = %d\n", type, variant); - if (variant != UUID_VARIANT_DCE) { - printf("Incorrect UUID Variant; was expecting DCE!\n"); - failed++; - } - if (type != 1) { - printf("Incorrect UUID type; was expecting " - "1 (time-based type)!\\n"); - failed++; - } - tv.tv_sec = 0; - tv.tv_usec = 0; - time_reg = uuid_time(buf, &tv); - printf("UUID time is: (%d, %d): %s\n", tv.tv_sec, tv.tv_usec, - ctime(&time_reg)); - uuid_parse(str, tst); - if (!uuid_compare(buf, tst)) - printf("UUID parse and compare succeeded.\n"); - else { - printf("UUID parse and compare failed!\n"); - failed++; - } - uuid_clear(tst); - if (uuid_is_null(tst)) - printf("UUID clear and is null succeeded.\n"); - else { - printf("UUID clear and is null failed!\n"); - failed++; - } - uuid_copy(buf, tst); - if (!uuid_compare(buf, tst)) - printf("UUID copy and compare succeeded.\n"); - else { - printf("UUID copy and compare failed!\n"); - failed++; - } - if (failed) { - printf("%d failures.\n", failed); - exit(1); - } - return 0; -} - - - diff --git a/capplets/file-types/libuuid/unpack.c b/capplets/file-types/libuuid/unpack.c deleted file mode 100644 index 8a80a9962..000000000 --- a/capplets/file-types/libuuid/unpack.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Internal routine for unpacking UUID - * - * Copyright (C) 1996, 1997 Theodore Ts'o. - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Public - * License. - * %End-Header% - */ - -#include <string.h> -#include "uuidP.h" - -void uuid_unpack(uuid_t in, struct uuid *uu) -{ - guint8 *ptr = in; - guint32 tmp; - - tmp = *ptr++; - tmp = (tmp << 8) | *ptr++; - tmp = (tmp << 8) | *ptr++; - tmp = (tmp << 8) | *ptr++; - uu->time_low = tmp; - - tmp = *ptr++; - tmp = (tmp << 8) | *ptr++; - uu->time_mid = tmp; - - tmp = *ptr++; - tmp = (tmp << 8) | *ptr++; - uu->time_hi_and_version = tmp; - - tmp = *ptr++; - tmp = (tmp << 8) | *ptr++; - uu->clock_seq = tmp; - - memcpy(uu->node, ptr, 6); -} - diff --git a/capplets/file-types/libuuid/unparse.c b/capplets/file-types/libuuid/unparse.c deleted file mode 100644 index ab904bc16..000000000 --- a/capplets/file-types/libuuid/unparse.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * unparse.c -- convert a UUID to string - * - * Copyright (C) 1996, 1997 Theodore Ts'o. - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Public - * License. - * %End-Header% - */ - -#include <stdio.h> - -#include "uuidP.h" - -void uuid_unparse(uuid_t uu, char *out) -{ - struct uuid uuid; - - uuid_unpack(uu, &uuid); - sprintf(out, - "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - uuid.time_low, uuid.time_mid, uuid.time_hi_and_version, - uuid.clock_seq >> 8, uuid.clock_seq & 0xFF, - uuid.node[0], uuid.node[1], uuid.node[2], - uuid.node[3], uuid.node[4], uuid.node[5]); -} - diff --git a/capplets/file-types/libuuid/uuid.h b/capplets/file-types/libuuid/uuid.h deleted file mode 100644 index 12afabffe..000000000 --- a/capplets/file-types/libuuid/uuid.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Public include file for the UUID library - * - * Copyright (C) 1996, 1997, 1998 Theodore Ts'o. - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Public - * License. - * %End-Header% - */ - -#include <sys/types.h> -#include <sys/time.h> -#include <time.h> - -typedef unsigned char uuid_t[16]; - -/* UUID Variant definitions */ -#define UUID_VARIANT_NCS 0 -#define UUID_VARIANT_DCE 1 -#define UUID_VARIANT_MICROSOFT 2 -#define UUID_VARIANT_OTHER 3 - -/* clear.c */ -void uuid_clear(uuid_t uu); - -/* compare.c */ -int uuid_compare(uuid_t uu1, uuid_t uu2); - -/* copy.c */ -void uuid_copy(uuid_t uu1, uuid_t uu2); - -/* gen_uuid.c */ -void uuid_generate(uuid_t out); -void uuid_generate_random(uuid_t out); -void uuid_generate_time(uuid_t out); - -/* isnull.c */ -int uuid_is_null(uuid_t uu); - -/* parse.c */ -int uuid_parse(char *in, uuid_t uu); - -/* unparse.c */ -void uuid_unparse(uuid_t uu, char *out); - -/* uuid_time.c */ -time_t uuid_time(uuid_t uu, struct timeval *ret_tv); -int uuid_type(uuid_t uu); -int uuid_variant(uuid_t uu); diff --git a/capplets/file-types/libuuid/uuidP.h b/capplets/file-types/libuuid/uuidP.h deleted file mode 100644 index 995db687c..000000000 --- a/capplets/file-types/libuuid/uuidP.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * uuid.h -- private header file for uuids - * - * Copyright (C) 1996, 1997 Theodore Ts'o. - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Public - * License. - * %End-Header% - */ - -#include <sys/types.h> -#include <glib.h> - -#include "uuid.h" - -/* - * Offset between 15-Oct-1582 and 1-Jan-70 - */ -#define TIME_OFFSET_HIGH 0x01B21DD2 -#define TIME_OFFSET_LOW 0x13814000 - -struct uuid { - guint32 time_low; - guint16 time_mid; - guint16 time_hi_and_version; - guint16 clock_seq; - guint8 node[6]; -}; - - -/* - * prototypes - */ -void uuid_pack(struct uuid *uu, uuid_t ptr); -void uuid_unpack(uuid_t in, struct uuid *uu); - - - - diff --git a/capplets/file-types/libuuid/uuid_time.c b/capplets/file-types/libuuid/uuid_time.c deleted file mode 100644 index 9a302202a..000000000 --- a/capplets/file-types/libuuid/uuid_time.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * uuid_time.c --- Interpret the time field from a uuid. This program - * violates the UUID abstraction barrier by reaching into the guts - * of a UUID and interpreting it. - * - * Copyright (C) 1998, 1999 Theodore Ts'o. - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Public - * License. - * %End-Header% - */ - -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <sys/types.h> -#include <sys/time.h> -#include <time.h> - -#include "uuidP.h" - -time_t uuid_time(uuid_t uu, struct timeval *ret_tv) -{ - struct uuid uuid; - guint32 high; - struct timeval tv; - unsigned long long clock_reg; - - uuid_unpack(uu, &uuid); - - high = uuid.time_mid | ((uuid.time_hi_and_version & 0xFFF) << 16); - clock_reg = uuid.time_low | ((unsigned long long) high << 32); - - clock_reg -= (((unsigned long long) 0x01B21DD2) << 32) + 0x13814000; - tv.tv_sec = clock_reg / 10000000; - tv.tv_usec = (clock_reg % 10000000) / 10; - - if (ret_tv) - *ret_tv = tv; - - return tv.tv_sec; -} - -int uuid_type(uuid_t uu) -{ - struct uuid uuid; - - uuid_unpack(uu, &uuid); - return ((uuid.time_hi_and_version >> 12) & 0xF); -} - -int uuid_variant(uuid_t uu) -{ - struct uuid uuid; - int var; - - uuid_unpack(uu, &uuid); - var = uuid.clock_seq; - - if ((var & 0x8000) == 0) - return UUID_VARIANT_NCS; - if ((var & 0x4000) == 0) - return UUID_VARIANT_DCE; - if ((var & 0x2000) == 0) - return UUID_VARIANT_MICROSOFT; - return UUID_VARIANT_OTHER; -} - -#ifdef DEBUG -static const char *variant_string(int variant) -{ - switch (variant) { - case UUID_VARIANT_NCS: - return "NCS"; - case UUID_VARIANT_DCE: - return "DCE"; - case UUID_VARIANT_MICROSOFT: - return "Microsoft"; - default: - return "Other"; - } -} - - -int -main(int argc, char **argv) -{ - uuid_t buf; - time_t time_reg; - struct timeval tv; - int type, variant; - - if (argc != 2) { - fprintf(stderr, "Usage: %s uuid\n", argv[0]); - exit(1); - } - if (uuid_parse(argv[1], buf)) { - fprintf(stderr, "Invalid UUID: %s\n", argv[1]); - exit(1); - } - variant = uuid_variant(buf); - type = uuid_type(buf); - time_reg = uuid_time(buf, &tv); - - printf("UUID variant is %d (%s)\n", variant, variant_string(variant)); - if (variant != UUID_VARIANT_DCE) { - printf("Warning: This program only knows how to interpret " - "DCE UUIDs.\n\tThe rest of the output is likely " - "to be incorrect!!\n"); - } - printf("UUID type is %d", type); - switch (type) { - case 1: - printf(" (time based)\n"); - break; - case 2: - printf(" (DCE)\n"); - break; - case 3: - printf(" (name-based)\n"); - break; - case 4: - printf(" (random)\n"); - break; - default: - printf("\n"); - } - if (type != 1) { - printf("Warning: not a time-based UUID, so UUID time " - "decoding will likely not work!\n"); - } - printf("UUID time is: (%u, %u): %s\n", (unsigned)tv.tv_sec, (unsigned)tv.tv_usec, - ctime(&time_reg)); - - return 0; -} -#endif diff --git a/capplets/mime-type/ChangeLog b/capplets/mime-type/ChangeLog deleted file mode 100644 index c285720ab..000000000 --- a/capplets/mime-type/ChangeLog +++ /dev/null @@ -1,12 +0,0 @@ -2001-07-27 Bradford Hovinen <hovinen@ximian.com> - - * RELEASE : 1.5.2 - -2001-07-24 Richard Hestilow <hestilow@ximian.com> - - * mime-data.c (get_mime_clist): Set clist to reasonable default size. - -2001-07-20 Chema Celorio <chema@celorio.com> - - * RELEASE : 1.5.0 - diff --git a/capplets/mime-type/Makefile.am b/capplets/mime-type/Makefile.am deleted file mode 100644 index 5e00036a9..000000000 --- a/capplets/mime-type/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -cappletname = mime-type -cappletgroup = "Advanced/" -bin_PROGRAMS = mime-type-capplet - -mime_type_capplet_LDADD = $(GNOMECC_CAPPLETS_LIBS) -mime_type_capplet_SOURCES = \ - mime-type-capplet.c\ - mime-data.h mime-data.c\ - edit-window.c edit-window.h\ - mime-info.c mime-info.h\ - new-mime-window.h new-mime-window.c - -pixmap_DATA = - -## -## You should not need to modify anything below this line -## -@XML_I18N_MERGE_DESKTOP_RULE@ -@GNOMECC_CAPPLETS_DESKTOP_IN_RULE@ - -INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS) -CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) -EXTRA_DIST = $(GNOMECC_CAPPLETS_EXTRA_DIST) -iconsdir = $(GNOMECC_ICONS_DIR) -Gladedir = $(GNOMECC_GLADE_DIR) -pixmapdir = $(GNOMECC_PIXMAPS_DIR) -Glade_DATA = $(cappletname)-properties.glade -icons_DATA = $(cappletname)-capplet.png -desktop = $(cappletname).desktop -all-local: $(desktop) diff --git a/capplets/mime-type/edit-window.c b/capplets/mime-type/edit-window.c deleted file mode 100644 index 98dd8bb51..000000000 --- a/capplets/mime-type/edit-window.c +++ /dev/null @@ -1,578 +0,0 @@ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include "edit-window.h" -#include "mime-data.h" -#include "mime-info.h" -#include "capplet-widget.h" - - -extern GtkWidget *capplet; -extern GHashTable *user_mime_types; - -typedef struct { - GtkWidget *window; - GtkWidget *icon_entry; - GtkWidget *mime_type; -/* GtkWidget *ext_tag_label; */ - GtkWidget *regexp1_tag_label; - GtkWidget *regexp2_tag_label; -/* GtkWidget *ext_label; */ - GtkWidget *regexp1_label; - GtkWidget *regexp2_label; - GtkWidget *open_entry; - GtkWidget *edit_entry; - GtkWidget *view_entry; - GtkWidget *ext_scroll; - GtkWidget *ext_clist; - GtkWidget *ext_entry; - GtkWidget *ext_add_button; - GtkWidget *ext_remove_button; - MimeInfo *mi; - MimeInfo *user_mi; - GList *tmp_ext[2]; -} edit_window; -static edit_window *main_win = NULL; -static gboolean changing = TRUE; -static void -destruction_handler (GtkWidget *widget, gpointer data) -{ - g_free (main_win); - main_win = NULL; -} -static void -entry_changed (GtkWidget *widget, gpointer data) -{ - if (changing == FALSE) - capplet_widget_state_changed (CAPPLET_WIDGET (capplet), - TRUE); -} -static void -ext_clist_selected (GtkWidget *clist, gint row, gint column, gpointer data) -{ - gboolean deletable; - - deletable = GPOINTER_TO_INT (gtk_clist_get_row_data (GTK_CLIST (clist), row)); - if (deletable) - gtk_widget_set_sensitive (main_win->ext_remove_button, TRUE); - else - gtk_widget_set_sensitive (main_win->ext_remove_button, FALSE); -} -static void -ext_clist_deselected (GtkWidget *clist, gint row, gint column, gpointer data) -{ - if (g_list_length (GTK_CLIST (clist)->selection) == 0) - gtk_widget_set_sensitive (main_win->ext_remove_button, FALSE); -} -static void -ext_entry_changed (GtkWidget *entry, gpointer data) -{ - gchar *text; - text = gtk_entry_get_text (GTK_ENTRY (entry)); - gtk_widget_set_sensitive (main_win->ext_add_button, (strlen (text) >0)); -} -static void -ext_add (GtkWidget *widget, gpointer data) -{ - gchar *row[1]; - gint rownumber; - - row[0] = g_strdup (gtk_entry_get_text (GTK_ENTRY (main_win->ext_entry))); - rownumber = gtk_clist_append (GTK_CLIST (main_win->ext_clist), row); - gtk_clist_set_row_data (GTK_CLIST (main_win->ext_clist), rownumber, - GINT_TO_POINTER (TRUE)); - gtk_entry_set_text (GTK_ENTRY (main_win->ext_entry), ""); - - main_win->tmp_ext[0] = g_list_prepend (main_win->tmp_ext[0], row[0]); - if (changing == FALSE) - capplet_widget_state_changed (CAPPLET_WIDGET (capplet), - TRUE); -} -static void -ext_remove (GtkWidget *widget, gpointer data) -{ - gint row; - gchar *text; - gchar *store; - GList *tmp; - - text = (gchar *)g_malloc (sizeof (gchar) * 1024); - gtk_clist_freeze (GTK_CLIST (main_win->ext_clist)); - row = GPOINTER_TO_INT (GTK_CLIST (main_win->ext_clist)->selection->data); - gtk_clist_get_text (GTK_CLIST (main_win->ext_clist), row, 0, &text); - store = g_strdup (text); - gtk_clist_remove (GTK_CLIST (main_win->ext_clist), row); - - gtk_clist_thaw (GTK_CLIST (main_win->ext_clist)); - - for (tmp = main_win->tmp_ext[0]; tmp; tmp = tmp->next) { - GList *found; - - if (strcmp (tmp->data, store) == 0) { - found = tmp; - - main_win->tmp_ext[0] = g_list_remove_link (main_win->tmp_ext[0], found); - g_list_free_1 (found); - break; - } - } - - if (changing == FALSE) - capplet_widget_state_changed (CAPPLET_WIDGET (capplet), - TRUE); -} -static void -apply_entry_change (GtkWidget *entry, gchar *key, MimeInfo *mi) -{ - const gchar *buf; - gchar *text; - /* buf is the value that existed before when we - * started the capplet */ - buf = local_mime_get_value (mi->mime_type, key); - if (buf == NULL) - buf = gnome_mime_get_value (mi->mime_type, key); - text = gtk_entry_get_text (GTK_ENTRY (entry)); - if (text && !*text) - text = NULL; - - /* First we see if they've added something. */ - if (buf == NULL && text) - set_mime_key_value (mi->mime_type, key, text); - else { - /* Has the value changed? */ - if (text && strcmp (text, buf)) - set_mime_key_value (mi->mime_type, key, text); - else - /* We _REALLY_ need a way to specify in - * user.keys not to use the system defaults. - * (ie. override the system default and - * query it). - * If we could then we'd set it here. */ - ; - } -} -static GList* -copy_mi_extensions (GList *orig) -{ - GList *tmp; - GList *list = NULL; - - for (tmp = orig; tmp; tmp = tmp->next) { - list = g_list_append (list, g_strdup (tmp->data)); - } - return list; -} -static void -make_readable (MimeInfo *mi) -{ - GList *list; - GString *extension; - - extension = g_string_new (""); - for (list = ((MimeInfo *) mi)->user_ext[0]; list; list = list->next) { - g_string_append (extension, (gchar *) list->data); - if (list->next != NULL) - g_string_append (extension, ", "); - } - mi->ext_readable[0] = extension->str; - g_string_free (extension, FALSE); - - extension = g_string_new (""); - for (list = ((MimeInfo *) mi)->user_ext[1]; list; list = list->next) { - g_string_append (extension, (gchar *) list->data); - if (list->next != NULL) - g_string_append (extension, ", "); - } - mi->ext_readable[1] = extension->str; - g_string_free (extension, FALSE); -} -static void -apply_changes (MimeInfo *mi) -{ - GList *tmp; - int i; - - apply_entry_change (gnome_icon_entry_gtk_entry (GNOME_ICON_ENTRY (main_win->icon_entry)), - "icon-filename", mi); - apply_entry_change (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (main_win->open_entry)), - "open", mi); - apply_entry_change (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (main_win->view_entry)), - "view", mi); - apply_entry_change (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (main_win->edit_entry)), - "edit", mi); - - if (!main_win->user_mi) { - add_to_key (mi->mime_type, "ext: tmp", user_mime_types, TRUE); - /* the tmp extension will be removed when we copy the tmp_ext - * stuff over the top of it. - */ - main_win->user_mi = g_hash_table_lookup (user_mime_types, - mi->mime_type); - } - - for (i = 0; i < 2; i++) { - if (main_win->tmp_ext[i]) { - main_win->user_mi->user_ext[i] = copy_mi_extensions (main_win->tmp_ext[i]); - mi->user_ext[i] = copy_mi_extensions (main_win->tmp_ext[i]); - } else { - main_win->user_mi->user_ext[i] = NULL; - mi->user_ext[i] = NULL; - } - } - - make_readable (main_win->user_mi); - - if (! (main_win->user_mi->ext[0] || main_win->user_mi->ext[1] || - main_win->user_mi->user_ext[0] || main_win->user_mi->ext[1])) - g_hash_table_remove (user_mime_types, mi->mime_type); - - /* Free the 2 tmp lists */ - for (i = 0; i < 2; i++) { - if (main_win->tmp_ext[i]) - for (tmp = main_win->tmp_ext[i]; tmp; tmp = tmp->next) - g_free (tmp->data); - } - if (changing == FALSE) - capplet_widget_state_changed (CAPPLET_WIDGET (capplet), - TRUE); -} -static void -browse_callback (GtkWidget *widget, gpointer data) -{ -} -static void -initialize_main_win () -{ - GtkWidget *align, *vbox, *hbox, *vbox2, *vbox3; - GtkWidget *frame, *table, *label; - GtkWidget *button; - GString *extension; - gchar *title[2] = {"Extensions"}; - - main_win = g_new (edit_window, 1); - main_win->window = gnome_dialog_new ("", - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, - NULL); - gtk_signal_connect (GTK_OBJECT (main_win->window), - "destroy", - destruction_handler, - NULL); - vbox = GNOME_DIALOG (main_win->window)->vbox; - - /* icon box */ - main_win->icon_entry = gnome_icon_entry_new ("mime_icon_entry", _("Select an icon...")); - align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); - gtk_container_add (GTK_CONTAINER (align), main_win->icon_entry); - gtk_signal_connect (GTK_OBJECT (gnome_icon_entry_gtk_entry (GNOME_ICON_ENTRY (main_win->icon_entry))), - "changed", - entry_changed, - NULL); - gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0); - - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("Mime Type: ")), FALSE, FALSE, 0); - main_win->mime_type = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (hbox), main_win->mime_type, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - /* extension/regexp */ - vbox2 = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0); - - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - main_win->ext_clist = gtk_clist_new_with_titles (1, title); - gtk_clist_column_titles_passive (GTK_CLIST (main_win->ext_clist)); - gtk_clist_set_auto_sort (GTK_CLIST (main_win->ext_clist), TRUE); - - gtk_signal_connect (GTK_OBJECT (main_win->ext_clist), - "select-row", - GTK_SIGNAL_FUNC (ext_clist_selected), - NULL); - gtk_signal_connect (GTK_OBJECT (main_win->ext_clist), - "unselect-row", - GTK_SIGNAL_FUNC (ext_clist_deselected), - NULL); - main_win->ext_scroll = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (main_win->ext_scroll), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (main_win->ext_scroll), - main_win->ext_clist); - - vbox3 = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - main_win->ext_add_button = gtk_button_new_with_label (_("Add")); - gtk_signal_connect (GTK_OBJECT (main_win->ext_add_button), - "clicked", - GTK_SIGNAL_FUNC (ext_add), - NULL); - gtk_box_pack_start (GTK_BOX (vbox3), main_win->ext_add_button, FALSE, FALSE, 0); - gtk_widget_set_sensitive (main_win->ext_add_button, FALSE); - - main_win->ext_remove_button = gtk_button_new_with_label (_("Remove")); - gtk_signal_connect (GTK_OBJECT (main_win->ext_remove_button), - "clicked", - GTK_SIGNAL_FUNC (ext_remove), - NULL); - gtk_widget_set_sensitive (main_win->ext_remove_button, FALSE); - gtk_box_pack_start (GTK_BOX (vbox3), main_win->ext_remove_button, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (hbox), main_win->ext_scroll, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (hbox), vbox3, FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, TRUE, 0); - - main_win->ext_entry = gtk_entry_new (); - gtk_signal_connect (GTK_OBJECT (main_win->ext_entry), - "changed", - ext_entry_changed, - NULL); - gtk_signal_connect (GTK_OBJECT (main_win->ext_entry), - "activate", - ext_add, - NULL); - gtk_box_pack_start (GTK_BOX (vbox2), main_win->ext_entry, TRUE, TRUE, 0); - - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - main_win->regexp1_label = gtk_label_new (""); - main_win->regexp1_tag_label = gtk_label_new (_("First Regular Expression: ")); - gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), main_win->regexp1_tag_label, - FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), main_win->regexp1_label, FALSE, FALSE, 0); - - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - main_win->regexp2_label = gtk_label_new (""); - main_win->regexp2_tag_label = gtk_label_new (_("Second Regular Expression: ")); - gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), main_win->regexp2_tag_label, - FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), main_win->regexp2_label, FALSE, FALSE, 0); - - /* Actions box */ - frame = gtk_frame_new (_("Mime Type Actions")); - vbox2 = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); - table = gtk_table_new (3, 2, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL); - gtk_container_set_border_width (GTK_CONTAINER (table), GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (frame), vbox2); - label = gtk_label_new (_("Example: emacs %f")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_misc_set_padding (GTK_MISC (label), 2, 0); - gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox2), table, FALSE, FALSE, 0); - label = gtk_label_new (_("Open")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_misc_set_padding (GTK_MISC (label), 2, 0); - gtk_table_attach_defaults (GTK_TABLE (table), - label, - 0, 1, 0, 1); - main_win->open_entry = gnome_file_entry_new ("MIME_CAPPLET_OPEN", _("Select a file...")); - gtk_signal_connect (GTK_OBJECT (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (main_win->open_entry))), - "changed", - entry_changed, - NULL); - - gtk_table_attach_defaults (GTK_TABLE (table), - main_win->open_entry, - 1, 2, 0, 1); - label = gtk_label_new (_("View")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_misc_set_padding (GTK_MISC (label), 2, 0); - gtk_table_attach_defaults (GTK_TABLE (table), - label, - 0, 1, 1, 2); - - main_win->view_entry = gnome_file_entry_new ("MIME_CAPPLET_VIEW", _("Select a file...")); - gtk_signal_connect (GTK_OBJECT (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (main_win->view_entry))), - "changed", - entry_changed, - NULL); - - gtk_table_attach_defaults (GTK_TABLE (table), - main_win->view_entry, - 1, 2, 1, 2); - label = gtk_label_new (_("Edit")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_misc_set_padding (GTK_MISC (label), 2, 0); - gtk_table_attach_defaults (GTK_TABLE (table), - label, - 0, 1, 2, 3); - main_win->edit_entry = gnome_file_entry_new ("MIME_CAPPLET_EDIT", _("Select a file...")); - gtk_signal_connect (GTK_OBJECT (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (main_win->edit_entry))), - "changed", - entry_changed, - NULL); - gtk_table_attach_defaults (GTK_TABLE (table), - main_win->edit_entry, - 1, 2, 2, 3); -} -static void -setup_entry (gchar *key, GtkWidget *g_entry, MimeInfo *mi) -{ - const gchar *buf; - GtkWidget *entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (g_entry)); - buf = local_mime_get_value (mi->mime_type, key); - if (buf == NULL) - buf = gnome_mime_get_value (mi->mime_type, key); - if (buf) - gtk_entry_set_text (GTK_ENTRY (entry), buf); - else - gtk_entry_set_text (GTK_ENTRY (entry), ""); -} -void -initialize_main_win_vals (void) -{ - MimeInfo *mi; - gchar *title; - gboolean showext = FALSE; - if (main_win == NULL) - return; - mi = main_win->mi; - if (mi == NULL) - return; - /* now we fill in the fields with the mi stuff. */ - - changing = TRUE; - gtk_label_set_text (GTK_LABEL (main_win->mime_type), mi->mime_type); - gnome_icon_entry_set_icon (GNOME_ICON_ENTRY (main_win->icon_entry), - gnome_mime_get_value (mi->mime_type, - "icon-filename")); - - gtk_widget_show_all (GNOME_DIALOG (main_win->window)->vbox); - /* we initialize everything */ - title = g_strdup_printf (_("Set actions for %s"), mi->mime_type); - gtk_window_set_title (GTK_WINDOW (main_win->window), title); - g_free (title); - - /* not sure why this is necessary */ - gtk_clist_clear (GTK_CLIST (main_win->ext_clist)); - if (mi->ext[0]) { - GList *tmp; - gchar *extension[1]; - gint row; - for (tmp = mi->ext[0]; tmp; tmp = tmp->next) { - extension[0] = g_strdup (tmp->data); - row = gtk_clist_append (GTK_CLIST (main_win->ext_clist), - extension); - gtk_clist_set_row_data (GTK_CLIST (main_win->ext_clist), - row, GINT_TO_POINTER (FALSE)); - } - showext = TRUE; - } - if (mi->ext[1]) { - GList *tmp; - gchar *extension[1]; - gint row; - for (tmp = mi->ext[1]; tmp; tmp = tmp->next) { - extension[0] = g_strdup (tmp->data); - row = gtk_clist_append (GTK_CLIST (main_win->ext_clist), - extension); - gtk_clist_set_row_data (GTK_CLIST (main_win->ext_clist), - row, GINT_TO_POINTER (FALSE)); - } - showext = TRUE; - } - if (main_win->tmp_ext[0]) { - GList *tmp; - gchar *extension[1]; - gint row; - for (tmp = main_win->tmp_ext[0]; tmp; tmp = tmp->next) { - extension[0] = g_strdup (tmp->data); - row = gtk_clist_append (GTK_CLIST (main_win->ext_clist), - extension); - gtk_clist_set_row_data (GTK_CLIST (main_win->ext_clist), - row, GINT_TO_POINTER (TRUE)); - } - showext = TRUE; - } - if (main_win->tmp_ext[1]) { - GList *tmp; - gchar *extension[1]; - gint row; - for (tmp = main_win->tmp_ext[0]; tmp; tmp = tmp->next) { - extension[0] = g_strdup (tmp->data); - row = gtk_clist_append (GTK_CLIST (main_win->ext_clist), - extension); - gtk_clist_set_row_data (GTK_CLIST (main_win->ext_clist), - row, GINT_TO_POINTER (TRUE)); - } - showext = TRUE; - } - if (!showext) { - gtk_widget_hide (main_win->ext_clist); - gtk_widget_hide (main_win->ext_entry); - gtk_widget_hide (main_win->ext_add_button); - gtk_widget_hide (main_win->ext_remove_button); - gtk_widget_hide (main_win->ext_scroll); - } - if (mi->regex_readable[0]) - gtk_label_set_text (GTK_LABEL (main_win->regexp1_label), - mi->regex_readable[0]); - else { - gtk_widget_hide (main_win->regexp1_label); - gtk_widget_hide (main_win->regexp1_tag_label); - } - if (mi->regex_readable[1]) - gtk_label_set_text (GTK_LABEL (main_win->regexp2_label), - mi->regex_readable[1]); - else { - gtk_widget_hide (main_win->regexp2_label); - gtk_widget_hide (main_win->regexp2_tag_label); - } - /* initialize the entries */ - setup_entry ("open", main_win->open_entry, mi); - setup_entry ("view", main_win->view_entry, mi); - setup_entry ("edit", main_win->edit_entry, mi); - changing = FALSE; - -} -void -launch_edit_window (MimeInfo *mi) -{ - gint size; - - if (main_win == NULL) - initialize_main_win (); - main_win->mi = mi; - main_win->user_mi = g_hash_table_lookup (user_mime_types, mi->mime_type); - main_win->tmp_ext[0] = NULL; - main_win->tmp_ext[1] = NULL; - if (main_win->user_mi) { - if (main_win->user_mi->user_ext[0]) - main_win->tmp_ext[0] = copy_mi_extensions (main_win->user_mi->user_ext[0]); - if (main_win->user_mi->user_ext[1]) - main_win->tmp_ext[1] = copy_mi_extensions (main_win->user_mi->user_ext[1]); - } - initialize_main_win_vals (); - - switch(gnome_dialog_run (GNOME_DIALOG (main_win->window))) { - case 0: - apply_changes (mi); - case 1: - main_win->mi = NULL; - gtk_widget_hide (main_win->window); - break; - } -} - -void -hide_edit_window (void) -{ - if (main_win && main_win->mi && main_win->window) - gtk_widget_hide (main_win->window); -} -void -show_edit_window (void) -{ - if (main_win && main_win->mi && main_win->window) - gtk_widget_show (main_win->window); -} - - - - diff --git a/capplets/mime-type/edit-window.h b/capplets/mime-type/edit-window.h deleted file mode 100644 index 626a7c6be..000000000 --- a/capplets/mime-type/edit-window.h +++ /dev/null @@ -1,15 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ -/* Copyright (C) 1998 Redhat Software Inc. - * Authors: Jonathan Blandford <jrb@redhat.com> - */ -#include "mime-data.h" -#ifndef _EDIT_WINDOW_H_ -#define _EDIT_WINDOW_H_ - - -void launch_edit_window (MimeInfo *mi); -void initialize_main_win_vals (void); -void hide_edit_window (void); -void show_edit_window (void); - -#endif diff --git a/capplets/mime-type/mime-data.c b/capplets/mime-type/mime-data.c deleted file mode 100644 index c9ffd2f25..000000000 --- a/capplets/mime-type/mime-data.c +++ /dev/null @@ -1,661 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ -/* Copyright (C) 1998 Redhat Software Inc. - * Authors: Jonathan Blandford <jrb@redhat.com> - */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include "capplet-widget.h" -#include "gnome.h" -#include <string.h> -#include <sys/types.h> -#include <dirent.h> -#include <regex.h> -#include <ctype.h> -#include "edit-window.h" -#include "mime-data.h" -#include "mime-info.h" -#include "new-mime-window.h" -#include <sys/stat.h> -#include <unistd.h> -#include <errno.h> - - -/* Prototypes */ -static void mime_fill_from_file (const char *filename, gboolean init_user); -static void mime_load_from_dir (const char *mime_info_dir, gboolean system_dir); -void add_to_key (char *mime_type, char *def, GHashTable *table, gboolean init_user); -static char *get_priority (char *def, int *priority); - - -/* Global variables */ -static char *current_lang; -static GHashTable *mime_types = NULL; -static GHashTable *initial_user_mime_types = NULL; -GHashTable *user_mime_types = NULL; -static GtkWidget *clist = NULL; -extern GtkWidget *delete_button; -extern GtkWidget *capplet; -/* Initialization functions */ -static void -run_error (gchar *message) -{ - GtkWidget *error_box; - - error_box = gnome_message_box_new ( - message, - GNOME_MESSAGE_BOX_ERROR, - GNOME_STOCK_BUTTON_OK, - NULL); - gnome_dialog_run_and_close (GNOME_DIALOG (error_box)); -} -static char * -get_priority (char *def, int *priority) -{ - *priority = 0; - - if (*def == ','){ - def++; - if (*def == '1'){ - *priority = 0; - def++; - } else if (*def == '2'){ - *priority = 1; - def++; - } - } - - while (*def && *def == ':') - def++; - - return def; -} -static void -free_mime_info (MimeInfo *mi) -{ - -} -void -add_to_key (char *mime_type, char *def, GHashTable *table, gboolean init_user) -{ - int priority = 1; - char *s, *p, *ext; - int used; - MimeInfo *info; - - info = g_hash_table_lookup (table, (const void *) mime_type); - if (info == NULL) { - info = g_malloc (sizeof (MimeInfo)); - info->mime_type = g_strdup (mime_type); - info->regex[0] = NULL; - info->regex[1] = NULL; - info->ext[0] = NULL; - info->ext[1] = NULL; - info->user_ext[0] = NULL; - info->user_ext[1] = NULL; - info->regex_readable[0] = NULL; - info->regex_readable[1] = NULL; - info->ext_readable[0] = NULL; - info->ext_readable[1] = NULL; - info->keys = gnome_mime_get_keys (mime_type); - g_hash_table_insert (table, info->mime_type, info); - } - if (strncmp (def, "ext", 3) == 0){ - char *tokp; - - def += 3; - def = get_priority (def, &priority); - s = p = g_strdup (def); - - used = 0; - - while ((ext = strtok_r (s, " \t\n\r,", &tokp)) != NULL){ - /* FIXME: We really need to check for duplicates before entering this. */ - if (!init_user) { - info->ext[priority] = g_list_prepend (info->ext[priority], ext); - } else { - info->user_ext[priority] = g_list_prepend (info->user_ext[priority], ext); - } - used = 1; - s = NULL; - } - if (!used) - g_free (p); - } - - if (strncmp (def, "regex", 5) == 0){ - regex_t *regex; - - regex = g_new (regex_t, 1); - def += 5; - def = get_priority (def, &priority); - - while (*def && isspace (*def)) - def++; - - if (!*def) - return; - if (regcomp (regex, def, REG_EXTENDED | REG_NOSUB)) - g_free (regex); - else { - info->regex[priority] = regex; - g_free (info->regex_readable[priority]); - info->regex_readable[priority] = g_strdup (def); - } - } -} -static void -mime_fill_from_file (const char *filename, gboolean init_user) -{ - FILE *f; - char buf [1024]; - char *current_key; - gboolean used; - - g_assert (filename != NULL); - - f = fopen (filename, "r"); - if (!f) - return; - - current_key = NULL; - used = FALSE; - while (fgets (buf, sizeof (buf), f)){ - char *p; - - if (buf [0] == '#') - continue; - - /* Trim trailing spaces */ - for (p = buf + strlen (buf) - 1; p >= buf; p--){ - if (isspace (*p) || *p == '\n') - *p = 0; - else - break; - } - - if (!buf [0]) - continue; - - if (buf [0] == '\t' || buf [0] == ' '){ - if (current_key){ - char *p = buf; - - while (*p && isspace (*p)) - p++; - - if (*p == 0) - continue; - add_to_key (current_key, p, mime_types, init_user); - if (init_user) { - add_to_key (current_key, p, - initial_user_mime_types, - TRUE); - add_to_key (current_key, p, - user_mime_types, TRUE); - } - used = TRUE; - } - } else { - if (!used && current_key) - g_free (current_key); - current_key = g_strdup (buf); - if (current_key [strlen (current_key)-1] == ':') - current_key [strlen (current_key)-1] = 0; - - used = FALSE; - } - } - fclose (f); -} - -static void -mime_load_from_dir (const char *mime_info_dir, gboolean system_dir) -{ - DIR *dir; - struct dirent *dent; - const int extlen = sizeof (".mime") - 1; - char *filename; - - dir = opendir (mime_info_dir); - if (!dir) - return; - if (system_dir) { - filename = g_concat_dir_and_file (mime_info_dir, "gnome.mime"); - mime_fill_from_file (filename, FALSE); - g_free (filename); - } - while ((dent = readdir (dir)) != NULL){ - - int len = strlen (dent->d_name); - - if (len <= extlen) - continue; - - if (strcmp (dent->d_name + len - extlen, ".mime")) - continue; - if (system_dir && !strcmp (dent->d_name, "gnome.mime")) - continue; - if (!system_dir && !strcmp (dent->d_name, "user.mime")) - continue; - - filename = g_concat_dir_and_file (mime_info_dir, dent->d_name); - mime_fill_from_file (filename, FALSE); - g_free (filename); - } - if (!system_dir) { - filename = g_concat_dir_and_file (mime_info_dir, "user.mime"); - mime_fill_from_file (filename, TRUE); - g_free (filename); - } - closedir (dir); -} -static int -add_mime_vals_to_clist (gchar *mime_type, gpointer mi, gpointer cl) -{ - /* we also finalize the MimeInfo structure here, now that we're done - * loading it */ - static gchar *text[2]; - GList *list; - GString *extension; - gint row; - - extension = g_string_new (""); - for (list = ((MimeInfo *) mi)->ext[0];list; list=list->next) { - g_string_append (extension, (gchar *) list->data); - if (list->next != NULL) - g_string_append (extension, ", "); - } - if (strcmp (extension->str, "") != 0 && ((MimeInfo *)mi)->user_ext[0]) - g_string_append (extension, ", "); - for (list = ((MimeInfo *) mi)->user_ext[0]; list; list=list->next) { - g_string_append (extension, (gchar *) list->data); - if (list->next != NULL) - g_string_append (extension, ", "); - } - ((MimeInfo *) mi)->ext_readable[0] = extension->str; - g_string_free (extension, FALSE); - - extension = g_string_new (""); - for (list = ((MimeInfo *) mi)->ext[1];list; list=list->next) { - g_string_append (extension, (gchar *) list->data); - if (list->next) - g_string_append (extension, ", "); - } - if (strcmp (extension->str, "") != 0 && ((MimeInfo *)mi)->user_ext[1]) - g_string_append (extension, ", "); - for (list = ((MimeInfo *) mi)->user_ext[1]; list; list=list->next) { - g_string_append (extension, (gchar *) list->data); - if (list->next != NULL) - g_string_append (extension, ", "); - } - ((MimeInfo *) mi)->ext_readable[1] = extension->str; - g_string_free (extension, FALSE); - - if (((MimeInfo *) mi)->ext[0] || ((MimeInfo *) mi)->user_ext[0]) { - extension = g_string_new ((((MimeInfo *) mi)->ext_readable[0])); - if (((MimeInfo *) mi)->ext[1] || ((MimeInfo *) mi)->user_ext[1]) { - g_string_append (extension, ", "); - g_string_append (extension, (((MimeInfo *) mi)->ext_readable[1])); - } - } else if (((MimeInfo *) mi)->ext[1] || ((MimeInfo *) mi)->user_ext[1]) - extension = g_string_new ((((MimeInfo *) mi)->ext_readable[1])); - else - extension = g_string_new (""); - - text[0] = ((MimeInfo *) mi)->mime_type; - text[1] = extension->str; - - row = gtk_clist_insert (GTK_CLIST (cl), 1, text); - gtk_clist_set_row_data (GTK_CLIST (cl), row, mi); - g_string_free (extension, TRUE); - return row; -} -static void -selected_row_callback (GtkWidget *widget, gint row, gint column, GdkEvent *event, gpointer data) -{ - MimeInfo *mi; - if (column < 0) - return; - - mi = (MimeInfo *) gtk_clist_get_row_data (GTK_CLIST (widget),row); - - if (event && event->type == GDK_2BUTTON_PRESS) - launch_edit_window (mi); - - if (g_hash_table_lookup (user_mime_types, mi->mime_type)) { - gtk_widget_set_sensitive (delete_button, TRUE); - } else - gtk_widget_set_sensitive (delete_button, FALSE); -} - -/* public functions */ -void -delete_clicked (GtkWidget *widget, gpointer data) -{ - MimeInfo *mi; - gint row = 0; - - if (GTK_CLIST (clist)->selection) - row = GPOINTER_TO_INT ((GTK_CLIST (clist)->selection)->data); - else - return; - mi = (MimeInfo *) gtk_clist_get_row_data (GTK_CLIST (clist), row); - - gtk_clist_remove (GTK_CLIST (clist), row); - g_hash_table_remove (user_mime_types, mi->mime_type); - remove_mime_info (mi->mime_type); - free_mime_info (mi); - capplet_widget_state_changed (CAPPLET_WIDGET (capplet), - TRUE); -} - -void -edit_clicked (GtkWidget *widget, gpointer data) -{ - MimeInfo *mi; - gint row = 0; - - if (GTK_CLIST (clist)->selection) - row = GPOINTER_TO_INT ((GTK_CLIST (clist)->selection)->data); - else - return; - mi = (MimeInfo *) gtk_clist_get_row_data (GTK_CLIST (clist), row); - if (mi) - launch_edit_window (mi); - gtk_clist_remove (GTK_CLIST (clist), row); - row = add_mime_vals_to_clist (mi->mime_type, mi, clist); - gtk_clist_select_row (GTK_CLIST (clist), row, 0); -} -void -add_clicked (GtkWidget *widget, gpointer data) -{ - launch_new_mime_window (); -} - -GtkWidget * -get_mime_clist (void) -{ - GtkWidget *retval; - gchar *titles[2]; - - titles[0] = _("Mime Type"); - titles[1] = _("Extension"); - retval = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (retval), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - clist = gtk_clist_new_with_titles (2, titles); - gtk_widget_set_usize (clist, 400, 300); - gtk_signal_connect (GTK_OBJECT (clist), - "select_row", - GTK_SIGNAL_FUNC (selected_row_callback), - NULL); - gtk_clist_set_selection_mode (GTK_CLIST (clist), GTK_SELECTION_BROWSE); - gtk_clist_set_auto_sort (GTK_CLIST (clist), TRUE); - if (clist) - g_hash_table_foreach (mime_types, (GHFunc) add_mime_vals_to_clist, clist); - gtk_clist_columns_autosize (GTK_CLIST (clist)); - gtk_clist_select_row (GTK_CLIST (clist), 0, 0); - gtk_container_add (GTK_CONTAINER (retval), clist); - return retval; -} - -static void -finalize_mime_type_foreach (gpointer mime_type, gpointer info, gpointer data) -{ - MimeInfo *mi = (MimeInfo *)info; - GList *list; - GString *extension; - - extension = g_string_new (""); - for (list = ((MimeInfo *) mi)->ext[0];list; list=list->next) { - g_string_append (extension, (gchar *) list->data); - if (list->next != NULL) - g_string_append (extension, ", "); - } - if (strcmp (extension->str, "") != 0 && mi->user_ext[0]) - g_string_append (extension, ", "); - for (list = ((MimeInfo *) mi)->user_ext[0]; list; list=list->next) { - g_string_append (extension, (gchar *) list->data); - if (list->next != NULL) - g_string_append (extension, ", "); - } - ((MimeInfo *) mi)->ext_readable[0] = extension->str; - g_string_free (extension, FALSE); - - extension = g_string_new (""); - for (list = ((MimeInfo *) mi)->ext[1];list; list=list->next) { - g_string_append (extension, (gchar *) list->data); - if (list->next) - g_string_append (extension, ", "); - } - if (strcmp (extension->str, "") != 0 && mi->user_ext[1]) - g_string_append (extension, ", "); - for (list = ((MimeInfo *) mi)->user_ext[1]; list; list=list->next) { - g_string_append (extension, (gchar *) list->data); - if (list->next != NULL) - g_string_append (extension, ", "); - } - ((MimeInfo *) mi)->ext_readable[1] = extension->str; - g_string_free (extension, FALSE); - - if (((MimeInfo *) mi)->ext[0] || ((MimeInfo *) mi)->user_ext[0]) { - extension = g_string_new ((((MimeInfo *) mi)->ext_readable[0])); - if (((MimeInfo *) mi)->ext[1] || ((MimeInfo *) mi)->user_ext[1]) { - g_string_append (extension, ", "); - g_string_append (extension, (((MimeInfo *) mi)->ext_readable[1])); - } - } else if (((MimeInfo *) mi)->ext[1] || ((MimeInfo *) mi)->user_ext[1]) - extension = g_string_new ((((MimeInfo *) mi)->ext_readable[1])); - else - extension = g_string_new (""); - g_string_free (extension, TRUE); -} -static void -finalize_user_mime () -{ - g_hash_table_foreach (user_mime_types, finalize_mime_type_foreach, NULL); - g_hash_table_foreach (initial_user_mime_types, finalize_mime_type_foreach, NULL); -} -void -init_mime_type (void) -{ - char *mime_info_dir; - - mime_types = g_hash_table_new (g_str_hash, g_str_equal); - initial_user_mime_types = g_hash_table_new (g_str_hash, g_str_equal); - user_mime_types = g_hash_table_new (g_str_hash, g_str_equal); - - mime_info_dir = gnome_unconditional_datadir_file ("mime-info"); - mime_load_from_dir (mime_info_dir, TRUE); - g_free (mime_info_dir); - - mime_info_dir = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/mime-info"); - mime_load_from_dir (mime_info_dir, FALSE); - g_free (mime_info_dir); - finalize_user_mime (); - init_mime_info (); -} -void -add_new_mime_type (gchar *mime_type, gchar *raw_ext, gchar *regexp1, gchar *regexp2) -{ - gchar *temp; - MimeInfo *mi = NULL; - gint row; - gchar *ext = NULL; - gchar *ptr, *ptr2; - - /* first we make sure that the information is good */ - if (mime_type == NULL || *mime_type == '\000') { - run_error (_("You must enter a mime-type")); - return; - } else if ((raw_ext == NULL || *raw_ext == '\000') && - (regexp1 == NULL || *regexp1 == '\000') && - (regexp2 == NULL || *regexp2 == '\000')){ - run_error (_("You must add either a regular-expression or\na file-name extension")); - return; - } - if (strchr (mime_type, '/') == NULL) { - run_error (_("Please put your mime-type in the format:\nCATEGORY/TYPE\n\nFor Example:\nimage/png")); - return; - } - if (g_hash_table_lookup (user_mime_types, mime_type) || - g_hash_table_lookup (mime_types, mime_type)) { - run_error (_("This mime-type already exists")); - return; - } - if (raw_ext || *raw_ext) { - ptr2 = ext = g_malloc (sizeof (raw_ext)); - for (ptr = raw_ext;*ptr; ptr++) { - if (*ptr != '.' && *ptr != ',') { - *ptr2 = *ptr; - ptr2 += 1; - } - } - *ptr2 = '\000'; - } - /* passed check, now we add it. */ - if (ext) { - temp = g_strconcat ("ext: ", ext, NULL); - add_to_key (mime_type, temp, user_mime_types, TRUE); - mi = (MimeInfo *) g_hash_table_lookup (user_mime_types, mime_type); - g_free (temp); - } - if (regexp1) { - temp = g_strconcat ("regex: ", regexp1, NULL); - add_to_key (mime_type, temp, user_mime_types, TRUE); - g_free (temp); - } - if (regexp2) { - temp = g_strconcat ("regex,2: ", regexp2, NULL); - add_to_key (mime_type, temp, user_mime_types, TRUE); - g_free (temp); - } - /* Finally add it to the clist */ - if (mi) { - row = add_mime_vals_to_clist (mime_type, mi, clist); - gtk_clist_select_row (GTK_CLIST (clist), row, 0); - gtk_clist_moveto (GTK_CLIST (clist), row, 0, 0.5, 0.0); - } - g_free (ext); -} -static void -write_mime_foreach (gpointer mime_type, gpointer info, gpointer data) -{ - gchar *buf; - MimeInfo *mi = (MimeInfo *) info; - fwrite ((char *) mi->mime_type, 1, strlen ((char *) mi->mime_type), (FILE *) data); - fwrite ("\n", 1, 1, (FILE *) data); - if (mi->ext_readable[0]) { - fwrite ("\text: ", 1, strlen ("\text: "), (FILE *) data); - fwrite (mi->ext_readable[0], 1, - strlen (mi->ext_readable[0]), - (FILE *) data); - fwrite ("\n", 1, 1, (FILE *) data); - } - if (mi->regex_readable[0]) { - fwrite ("\tregex: ", 1, strlen ("\tregex: "), (FILE *) data); - fwrite (mi->regex_readable[0], 1, - strlen (mi->regex_readable[0]), - (FILE *) data); - fwrite ("\n", 1, 1, (FILE *) data); - } - if (mi->regex_readable[1]) { - fwrite ("\tregex,2: ", 1, strlen ("\tregex,2: "), (FILE *) data); - fwrite (mi->regex_readable[1], 1, - strlen (mi->regex_readable[1]), - (FILE *) data); - fwrite ("\n", 1, 1, (FILE *) data); - } - fwrite ("\n", 1, 1, (FILE *) data); -} - -static void -write_mime (GHashTable *hash) -{ - struct stat s; - gchar *dirname, *filename; - FILE *file; - GtkWidget *error_box; - - dirname = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/mime-info"); - if ((stat (dirname, &s) < 0) || !(S_ISDIR (s.st_mode))){ - if (errno == ENOENT) { - if (mkdir (dirname, S_IRWXU) < 0) { - run_error (_("We are unable to create the directory\n" - "~/.gnome/mime-info\n\n" - "We will not be able to save the state.")); - return; - } - } else { - run_error (_("We are unable to access the directory\n" - "~/.gnome/mime-info\n\n" - "We will not be able to save the state.")); - return; - } - } - filename = g_concat_dir_and_file (dirname, "user.mime"); - - remove (filename); - file = fopen (filename, "w"); - if (file == NULL) { - run_error (_("Cannot create the file\n~/.gnome/mime-info/user.mime\n\n" - "We will not be able to save the state")); - return; - } - g_hash_table_foreach (hash, write_mime_foreach, file); - fclose (file); -} - -void -write_user_mime (void) -{ - write_mime (user_mime_types); -} - -void -write_initial_mime (void) -{ - write_mime (initial_user_mime_types); -} - -void -reread_list () -{ - gtk_clist_freeze (GTK_CLIST (clist)); - gtk_clist_clear (GTK_CLIST (clist)); - g_hash_table_foreach (mime_types, (GHFunc) add_mime_vals_to_clist, clist); - gtk_clist_thaw (GTK_CLIST (clist)); -} -static void -clean_mime_type (gpointer mime_type, gpointer mime_info, gpointer data) -{ - /* we should write this )-: */ -} -void -discard_mime_info () -{ - gchar *filename; - g_hash_table_foreach (user_mime_types, clean_mime_type, NULL); - g_hash_table_destroy (user_mime_types); - g_hash_table_foreach (initial_user_mime_types, clean_mime_type, NULL); - g_hash_table_destroy (initial_user_mime_types); - user_mime_types = g_hash_table_new (g_str_hash, g_str_equal); - initial_user_mime_types = g_hash_table_new (g_str_hash, g_str_equal); - - filename = g_concat_dir_and_file (gnome_util_user_home (), "/.gnome/mime-info/user.keys"); - mime_fill_from_file (filename, TRUE); - finalize_user_mime (); - reread_list (); - g_free (filename); -} - - - - - - - diff --git a/capplets/mime-type/mime-data.h b/capplets/mime-type/mime-data.h deleted file mode 100644 index f5c8bedea..000000000 --- a/capplets/mime-type/mime-data.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ -/* Copyright (C) 1998 Redhat Software Inc. - * Authors: Jonathan Blandford <jrb@redhat.com> - */ -#ifndef _MIME_DATA_H_ -#define _MIME_DATA_H_ -#include "gnome.h" -#include <regex.h> -/* Typedefs */ -typedef struct { - char *mime_type; - regex_t *regex[2]; - GList *ext[2]; - GList *user_ext[2]; - char *ext_readable[2]; - char *regex_readable[2]; - char *file_name; - GList *keys; -} MimeInfo; - -extern GHashTable *user_mime_types; -extern void add_to_key (char *mime_type, char *def, GHashTable *table, gboolean init_user); - -GtkWidget *get_mime_clist (void); -void init_mime_type (void); -void delete_clicked (GtkWidget *widget, gpointer data); -void add_clicked (GtkWidget *widget, gpointer data); -void edit_clicked (GtkWidget *widget, gpointer data); -void add_new_mime_type (gchar *mime_type, gchar *ext, gchar *regexp1, gchar *regexp2); -void write_user_mime (void); -void write_initial_mime (void); -void reread_list (void); -void discard_mime_info (void); -#endif diff --git a/capplets/mime-type/mime-info.c b/capplets/mime-type/mime-info.c deleted file mode 100644 index cc36252f0..000000000 --- a/capplets/mime-type/mime-info.c +++ /dev/null @@ -1,492 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ -/* Copyright (C) 1998 Redhat Software Inc. - * Authors: Jonathan Blandford <jrb@redhat.com> - */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include "capplet-widget.h" -#include "gnome.h" -#include <string.h> -#include <sys/types.h> -#include <dirent.h> -#include <regex.h> -#include <ctype.h> -#include "mime-info.h" -#include "mime-data.h" -#include <errno.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <fcntl.h> -#include <unistd.h> - -#if !defined getc_unlocked && !defined HAVE_GETC_UNLOCKED -# define getc_unlocked(fp) getc (fp) -#endif - -typedef struct { - char *mime_type; - GHashTable *keys; -} GnomeMimeContext; - -typedef enum { - STATE_NONE, - STATE_LANG, - STATE_LOOKING_FOR_KEY, - STATE_ON_MIME_TYPE, - STATE_ON_KEY, - STATE_ON_VALUE -} ParserState; - -static char *current_lang = NULL; - -/* - * A hash table containing all of the Mime records for specific - * mime types (full description, like image/png) - */ -static GHashTable *specific_types; -static GHashTable *initial_specific_types; - -/* - * A hash table containing all of the Mime records for non-specific - * mime types (like image/\*) - */ -static GHashTable *generic_types; -static GHashTable *initial_generic_types; - -#define SWITCH_TO_MIME_TYPE() { -static GnomeMimeContext * -context_new (GString *str, gboolean is_default_context) -{ - GnomeMimeContext *context; - GHashTable *table; - char *mime_type, *p; - - mime_type = g_strdup (str->str); - - if (is_default_context) { - if ((p = strstr (mime_type, "/*")) == NULL){ - table = initial_specific_types; - } else { - *(p+1) = 0; - table = initial_generic_types; - } - } else { - if ((p = strstr (mime_type, "/*")) == NULL){ - table = specific_types; - } else { - *(p+1) = 0; - table = generic_types; - } - } - context = g_hash_table_lookup (table, mime_type); - - if (context) - return context; - - context = g_new (GnomeMimeContext, 1); - context->mime_type = mime_type; - context->keys = g_hash_table_new (g_str_hash, g_str_equal); - - g_hash_table_insert (table, context->mime_type, context); - return context; -} - -static gboolean -release_key_and_value (gpointer key, gpointer value, gpointer user_data) -{ - g_free (key); - g_free (value); - - return TRUE; -} - - -static gboolean -remove_this_key (gpointer key, gpointer value, gpointer user_data) -{ - if (strcmp ((gchar *)key, (gchar *)user_data) == 0){ - g_free (key); - g_free (value); - return TRUE; - } - - return FALSE; -} -static void -context_add_key (GnomeMimeContext *context, char *key, char *value) -{ - char *v; - - v = g_hash_table_lookup (context->keys, key); - if (v) - g_hash_table_foreach_remove (context->keys, remove_this_key, key); - - g_hash_table_insert (context->keys, g_strdup (key), g_strdup (value)); -} -static void -context_destroy (GnomeMimeContext *context) -{ - /* - * Remove the context from our hash tables, we dont know - * where it is: so just remove it from both (it can - * only be in one). - */ - if (context->mime_type) { - g_hash_table_remove (specific_types, context->mime_type); - g_hash_table_remove (generic_types, context->mime_type); - } - /* - * Destroy it - */ - if (context->keys) { - g_hash_table_foreach_remove (context->keys, release_key_and_value, NULL); - g_hash_table_destroy (context->keys); - } - g_free (context->mime_type); - g_free (context); -} - -static void -load_mime_type_info_from (char *filename) -{ - FILE *mime_file; - gboolean in_comment, context_used; - GString *line; - int column, c; - ParserState state; - GnomeMimeContext *context, *default_context; - char *key; - - mime_file = fopen (filename, "r"); - if (mime_file == NULL) - return; - - in_comment = FALSE; - context_used = FALSE; - column = 0; - context = NULL; - default_context = NULL; - key = NULL; - line = g_string_sized_new (120); - state = STATE_NONE; - - while ((c = getc_unlocked (mime_file)) != EOF){ - column++; - if (c == '\r') - continue; - - if (c == '#' && column == 0){ - in_comment = TRUE; - continue; - } - - if (c == '\n'){ - in_comment = FALSE; - column = 0; - if (state == STATE_ON_MIME_TYPE){ - context = context_new (line, FALSE); - default_context = context_new (line, TRUE); - context_used = FALSE; - g_string_assign (line, ""); - state = STATE_LOOKING_FOR_KEY; - continue; - } - if (state == STATE_ON_VALUE){ - context_used = TRUE; - context_add_key (context, key, line->str); - context_add_key (default_context, key, line->str); - g_string_assign (line, ""); - g_free (key); - key = NULL; - state = STATE_LOOKING_FOR_KEY; - continue; - } - continue; - } - - if (in_comment) - continue; - - switch (state){ - case STATE_NONE: - if (c != ' ' && c != '\t') - state = STATE_ON_MIME_TYPE; - else - break; - /* fall down */ - - case STATE_ON_MIME_TYPE: - if (c == ':'){ - in_comment = TRUE; - break; - } - g_string_append_c (line, c); - break; - - case STATE_LOOKING_FOR_KEY: - if (c == '\t' || c == ' ') - break; - - if (c == '['){ - state = STATE_LANG; - break; - } - - if (column == 1){ - state = STATE_ON_MIME_TYPE; - g_string_append_c (line, c); - break; - } - state = STATE_ON_KEY; - /* falldown */ - - case STATE_ON_KEY: - if (c == '\\'){ - c = getc (mime_file); - if (c == EOF) - break; - } - if (c == '='){ - key = g_strdup (line->str); - g_string_assign (line, ""); - state = STATE_ON_VALUE; - break; - } - g_string_append_c (line, c); - break; - - case STATE_ON_VALUE: - g_string_append_c (line, c); - break; - - case STATE_LANG: - if (c == ']'){ - state = STATE_ON_KEY; - if (current_lang && line->str [0]){ - if (strcmp (current_lang, line->str) != 0){ - in_comment = TRUE; - state = STATE_LOOKING_FOR_KEY; - } - } else { - in_comment = TRUE; - state = STATE_LOOKING_FOR_KEY; - } - g_string_assign (line, ""); - break; - } - g_string_append_c (line, c); - break; - } - } - - if (context){ - if (key && line->str [0]) { - context_add_key (context, key, line->str); - context_add_key (default_context, key, line->str); - } else - if (!context_used) { - context_destroy (context); - context_destroy (default_context); - } - - } - - g_string_free (line, TRUE); - if (key) - g_free (key); - - fclose (mime_file); -} -void -set_mime_key_value (gchar *mime_type, gchar *key, gchar *value) -{ - GnomeMimeContext *context; - - /* Assume no generic context's for now. */ - context = g_hash_table_lookup (specific_types, mime_type); - if (context == NULL) { - GString *str = g_string_new (mime_type); - context = context_new (str, FALSE); - g_string_free (str, TRUE); - } - context_add_key (context, key, value); -} -void -init_mime_info (void) -{ - gchar *filename; - - current_lang = getenv ("LANG"); - specific_types = g_hash_table_new (g_str_hash, g_str_equal); - generic_types = g_hash_table_new (g_str_hash, g_str_equal); - initial_specific_types = g_hash_table_new (g_str_hash, g_str_equal); - initial_generic_types = g_hash_table_new (g_str_hash, g_str_equal); - - filename = g_concat_dir_and_file (gnome_util_user_home (), "/.gnome/mime-info/user.keys"); - load_mime_type_info_from (filename); - g_free (filename); -} - -const char * -local_mime_get_value (const char *mime_type, char *key) -{ - char *value, *generic_type, *p; - GnomeMimeContext *context; - - g_return_val_if_fail (mime_type != NULL, NULL); - g_return_val_if_fail (key != NULL, NULL); - context = g_hash_table_lookup (specific_types, mime_type); - if (context){ - value = g_hash_table_lookup (context->keys, key); - - if (value) - return value; - } - - generic_type = g_strdup (mime_type); - p = strchr (generic_type, '/'); - if (p) - *(p+1) = 0; - - context = g_hash_table_lookup (generic_types, generic_type); - g_free (generic_type); - - if (context){ - value = g_hash_table_lookup (context->keys, key); - if (value) - return value; - } - return NULL; -} -static void -clean_mime_foreach (gpointer mime_type, gpointer gmc, gpointer data) -{ - context_destroy ((GnomeMimeContext *) gmc); -} -static void -write_mime_keys_foreach (gpointer key_name, gpointer value, gpointer data) -{ - gchar *buf; - if (current_lang && strcmp (current_lang, "C")) - buf = g_strconcat ("\t[", - current_lang, - "]", - (gchar *) key_name, - "=", - (gchar *) value, - "\n", NULL); - else - buf = g_strconcat ("\t", - (gchar *) key_name, - "=", - (gchar *) value, - "\n", NULL); - fwrite (buf, 1, strlen (buf), (FILE *) data); - g_free (buf); -} -static void -write_mime_foreach (gpointer mime_type, gpointer gmc, gpointer data) -{ - gchar *buf; - GnomeMimeContext *context = (GnomeMimeContext *) gmc; - - buf = g_strconcat ((gchar *) mime_type, ":\n", NULL); - fwrite (buf, 1, strlen (buf), (FILE *) data); - g_free (buf); - g_hash_table_foreach (context->keys, write_mime_keys_foreach, data); - fwrite ("\n", 1, strlen ("\n"), (FILE *) data); -} - -static void -run_error (gchar *message) -{ - GtkWidget *error_box; - - error_box = gnome_message_box_new ( - message, - GNOME_MESSAGE_BOX_ERROR, - GNOME_STOCK_BUTTON_OK, - NULL); - gnome_dialog_run_and_close (GNOME_DIALOG (error_box)); -} -static void -write_keys (GHashTable *spec_hash, GHashTable *generic_hash) -{ - struct stat s; - gchar *dirname, *filename; - FILE *file; - GtkWidget *error_box; - - dirname = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/mime-info"); - if ((stat (dirname, &s) < 0) || !(S_ISDIR (s.st_mode))){ - if (errno == ENOENT) { - if (mkdir (dirname, S_IRWXU) < 0) { - run_error (_("We are unable to create the directory\n" - "~/.gnome/mime-info\n\n" - "We will not be able to save the state.")); - return; - } - } else { - run_error (_("We are unable to access the directory\n" - "~/.gnome/mime-info\n\n" - "We will not be able to save the state.")); - return; - } - } - filename = g_concat_dir_and_file (dirname, "user.keys"); - - remove (filename); - file = fopen (filename, "w"); - if (file == NULL) { - run_error (_("Cannot create the file\n~/.gnome/mime-info/user.keys.\n\n" - "We will not be able to save the state")); - return; - } - g_hash_table_foreach (spec_hash, write_mime_foreach, file); - g_hash_table_foreach (generic_hash, write_mime_foreach, file); - fclose (file); -} -void -write_initial_keys (void) -{ - write_keys (initial_generic_types, initial_specific_types); -} -void -write_user_keys (void) -{ - write_keys (generic_types, specific_types); -} -static void -print_mime_foreach (gpointer mime_info, gpointer mi, gpointer data) -{ - g_print ("mime_info:%s:\n", (char *)mime_info); - g_print ("\t:%s:\n", ((MimeInfo *)mi)->mime_type); -} -void -discard_key_info (void) -{ - gchar *filename; - - current_lang = getenv ("LANG"); - g_hash_table_foreach (generic_types, clean_mime_foreach, NULL); -/* g_hash_table_foreach (specific_types, print_mime_foreach, NULL); */ - g_hash_table_foreach (specific_types, clean_mime_foreach, NULL); - g_hash_table_destroy (generic_types); - g_hash_table_destroy (specific_types); - specific_types = g_hash_table_new (g_str_hash, g_str_equal); - generic_types = g_hash_table_new (g_str_hash, g_str_equal); - - filename = g_concat_dir_and_file (gnome_util_user_home (), "/.gnome/mime-info/user.keys"); - load_mime_type_info_from (filename); - reread_list (); - g_free (filename); -} -void -remove_mime_info (gchar *mime_type) -{ - g_hash_table_remove (generic_types, mime_type); - g_hash_table_remove (specific_types, mime_type); -} diff --git a/capplets/mime-type/mime-info.h b/capplets/mime-type/mime-info.h deleted file mode 100644 index 18db2326f..000000000 --- a/capplets/mime-type/mime-info.h +++ /dev/null @@ -1,17 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ -/* Copyright (C) 1998 Redhat Software Inc. - * Authors: Jonathan Blandford <jrb@redhat.com> - */ -#ifndef _MIME_INFO_H_ -#define _MIME_INFO_H_ -#include "gnome.h" -#include <regex.h> -/* Typedefs */ -void init_mime_info (void); -void discard_key_info (void); -void set_mime_key_value (gchar *mime_type, gchar *key, gchar *value); -const char * local_mime_get_value (const char *mime_type, char *key); -void write_user_keys (void); -void write_initial_keys (void); -void remove_mime_info (gchar *mime_type); -#endif diff --git a/capplets/mime-type/mime-type-capplet.c b/capplets/mime-type/mime-type-capplet.c deleted file mode 100644 index 8d75d2cf5..000000000 --- a/capplets/mime-type/mime-type-capplet.c +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ -/* Copyright (C) 1998 Redhat Software Inc. - * Authors: Jonathan Blandford <jrb@redhat.com> - */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include "capplet-widget.h" -#include "gnome.h" -#include <string.h> -#include <sys/types.h> -#include <dirent.h> -#include <regex.h> -#include <ctype.h> -#include "mime-data.h" -#include "mime-info.h" -#include "edit-window.h" -/* Prototypes */ -static void try_callback (); -static void revert_callback (); -static void ok_callback (); -static void cancel_callback (); -static void help_callback (); -GtkWidget *capplet = NULL; -GtkWidget *delete_button = NULL; - -static GtkWidget * -left_aligned_button (gchar *label) -{ - GtkWidget *button = gtk_button_new_with_label (label); - gtk_misc_set_alignment (GTK_MISC (GTK_BIN (button)->child), - 0.0, 0.5); - gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), - GNOME_PAD_SMALL, 0); - - return button; -} - -static void -try_callback () -{ - write_user_keys (); - write_user_mime (); -} -static void -revert_callback () -{ - write_initial_keys (); - write_initial_mime (); - discard_key_info (); - discard_mime_info (); - initialize_main_win_vals (); -} -static void -ok_callback () -{ - write_user_keys (); - write_user_mime (); -} -static void -cancel_callback () -{ - write_initial_keys (); - write_initial_mime (); -} - -static void -help_callback () -{ - /* Sigh... empty as always */ -} - -static void -init_mime_capplet () -{ - GtkWidget *vbox; - GtkWidget *hbox; - GtkWidget *button; - - capplet = capplet_widget_new (); - delete_button = left_aligned_button (_("Delete")); - gtk_signal_connect (GTK_OBJECT (delete_button), "clicked", - delete_clicked, NULL); - - hbox = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (capplet), hbox); - gtk_box_pack_start (GTK_BOX (hbox), get_mime_clist (), TRUE, TRUE, 0); - vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); - button = left_aligned_button (_("Add...")); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - add_clicked, NULL); - button = left_aligned_button (_("Edit...")); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - edit_clicked, NULL); - gtk_box_pack_start (GTK_BOX (vbox), delete_button, FALSE, FALSE, 0); - gtk_widget_show_all (capplet); - gtk_signal_connect(GTK_OBJECT(capplet), "try", - GTK_SIGNAL_FUNC(try_callback), NULL); - gtk_signal_connect(GTK_OBJECT(capplet), "revert", - GTK_SIGNAL_FUNC(revert_callback), NULL); - gtk_signal_connect(GTK_OBJECT(capplet), "ok", - GTK_SIGNAL_FUNC(ok_callback), NULL); - gtk_signal_connect(GTK_OBJECT(capplet), "cancel", - GTK_SIGNAL_FUNC(cancel_callback), NULL); - gtk_signal_connect(GTK_OBJECT(capplet), "page_hidden", - GTK_SIGNAL_FUNC(hide_edit_window), NULL); - gtk_signal_connect(GTK_OBJECT(capplet), "page_shown", - GTK_SIGNAL_FUNC(show_edit_window), NULL); -#if 0 - gtk_signal_connect(GTK_OBJECT(capplet), "help", - GTK_SIGNAL_FUNC(help_callback), NULL); -#endif -} - -int -main (int argc, char **argv) -{ - int init_results; - - bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE); - - init_results = gnome_capplet_init("mime-type", VERSION, - argc, argv, NULL, 0, NULL); - - if (init_results < 0) { - exit (0); - } - - if (init_results == 0) { - init_mime_type (); - init_mime_capplet (); - capplet_gtk_main (); - } - return 0; -} diff --git a/capplets/mime-type/mime-type-capplet.png b/capplets/mime-type/mime-type-capplet.png Binary files differdeleted file mode 100644 index b253d29fe..000000000 --- a/capplets/mime-type/mime-type-capplet.png +++ /dev/null diff --git a/capplets/mime-type/mime-type-properties.glade b/capplets/mime-type/mime-type-properties.glade deleted file mode 100644 index e69de29bb..000000000 --- a/capplets/mime-type/mime-type-properties.glade +++ /dev/null diff --git a/capplets/mime-type/mime-type.desktop.in.in b/capplets/mime-type/mime-type.desktop.in.in deleted file mode 100644 index 3ca034881..000000000 --- a/capplets/mime-type/mime-type.desktop.in.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=Mime Types -_Comment=Configure how files are associated and started -Icon=mime-type-capplet.png -Exec=mime-type-capplet -Terminal=0 -Type=Application diff --git a/capplets/mime-type/new-mime-window.c b/capplets/mime-type/new-mime-window.c deleted file mode 100644 index bc21109b7..000000000 --- a/capplets/mime-type/new-mime-window.c +++ /dev/null @@ -1,120 +0,0 @@ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include "new-mime-window.h" -#include "capplet-widget.h" -static GtkWidget *add_dialog = NULL; -extern GtkWidget *capplet; - -/*Public functions */ -void -launch_new_mime_window (void) -{ - GtkWidget *mime_entry; - GtkWidget *label; - GtkWidget *frame; - GtkWidget *ext_entry; - GtkWidget *regex1_entry; - GtkWidget *regex2_entry; - GtkWidget *hbox; - GtkWidget *vbox; - GtkWidget *table; - - add_dialog = gnome_dialog_new (_("Add Mime Type"), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); - label = gtk_label_new (_("Add a new Mime Type\nFor example: image/tiff; text/x-scheme")); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (add_dialog)->vbox), hbox, FALSE, FALSE, 0); - label = gtk_label_new (_("Mime Type: ")); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - mime_entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (hbox), mime_entry, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (add_dialog)->vbox), hbox, FALSE, FALSE, 0); - - frame = gtk_frame_new (_("Extensions")); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (add_dialog)->vbox), frame, FALSE, FALSE, 0); - vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL); - label = gtk_label_new (_("Type in the extensions for this mime-type.\nFor example: .html, .htm")); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame), vbox); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("Extension:")), FALSE, FALSE, 0); - ext_entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (hbox), ext_entry, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - frame = gtk_frame_new (_("Regular Expressions")); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (add_dialog)->vbox), frame, FALSE, FALSE, 0); - vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL); - label = gtk_label_new (_("You can set up two regular expressions here to identify the Mime Type\nby. These fields are optional.")); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame), vbox); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0); - table = gtk_table_new (2, 2, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL); -/* gtk_container_set_border_width (GTK_CONTAINER (table), GNOME_PAD_SMALL);*/ - label = gtk_label_new (_("First Regular Expression: ")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - gtk_table_attach (GTK_TABLE (table), - label, - 0, 1, 0, 1, - GTK_FILL, GTK_FILL, 0, 0); - regex1_entry = gtk_entry_new (); - gtk_table_attach_defaults (GTK_TABLE (table), - regex1_entry, - 1, 2, 0, 1); - label = gtk_label_new (_("Second Regular Expression: ")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - gtk_table_attach (GTK_TABLE (table), - label, - 0, 1, 1, 2, - GTK_FILL, GTK_FILL, 0, 0); - regex2_entry = gtk_entry_new (); - gtk_table_attach_defaults (GTK_TABLE (table), - regex2_entry, - 1, 2, 1, 2); - gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); - - - gtk_widget_show_all (GNOME_DIALOG (add_dialog)->vbox); - switch (gnome_dialog_run (GNOME_DIALOG (add_dialog))) { - case 0: - capplet_widget_state_changed (CAPPLET_WIDGET (capplet), - TRUE); - add_new_mime_type (gtk_entry_get_text (GTK_ENTRY (mime_entry)), - gtk_entry_get_text (GTK_ENTRY (ext_entry)), - gtk_entry_get_text (GTK_ENTRY (regex1_entry)), - gtk_entry_get_text (GTK_ENTRY (regex2_entry))); - case 1: - gtk_widget_destroy (add_dialog); - default:; - } - add_dialog = NULL; -} -void -hide_new_mime_window (void) -{ - if (add_dialog != NULL) - gtk_widget_hide (add_dialog); -} -void -show_new_mime_window (void) -{ - if (add_dialog != NULL) - gtk_widget_show (add_dialog); -} diff --git a/capplets/mime-type/new-mime-window.h b/capplets/mime-type/new-mime-window.h deleted file mode 100644 index 3071ab3fd..000000000 --- a/capplets/mime-type/new-mime-window.h +++ /dev/null @@ -1,14 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ -/* Copyright (C) 1998 Redhat Software Inc. - * Authors: Jonathan Blandford <jrb@redhat.com> - */ -#include "mime-data.h" -#ifndef _NEW_MIME_WINDOW_H_ -#define _NEW_MIME_WINDOW_H_ - -void launch_new_mime_window (void); -void hide_new_mime_window (void); -void show_new_mime_window (void); - -#endif - diff --git a/capplets/theme-switcher/.cvsignore b/capplets/theme-switcher/.cvsignore deleted file mode 100644 index 6f363cf6c..000000000 --- a/capplets/theme-switcher/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -Makefile.in -Makefile -.deps -.libs -gtk-theme-selector-capplet -gtk-theme-selector.desktop -gtk-theme-selector.desktop.in diff --git a/capplets/theme-switcher/ChangeLog b/capplets/theme-switcher/ChangeLog deleted file mode 100644 index 1a18b63fd..000000000 --- a/capplets/theme-switcher/ChangeLog +++ /dev/null @@ -1,40 +0,0 @@ -2001-09-29 Richard Hestilow <hestilow@ximian.com> - - * gui.c (sort_alpha): Use g_strcasecmp, not strcmp. - Fixes bug #13539. - -2001-09-29 Richard Hestilow <hestilow@ximian.com> - - * lister.c: (list_themes, list_system_themes, list_user_themes): - Return a GList of ThemeEntry*, and remove extraneous number argument. - Also, use g_strdup_printf instead of g_snprintf. - - * da.h (ThemeEntry): Add a "row" data member. - * gui.c: Change variables current_theme, current_global_theme, - initial_theme, and last_theme to ThemeEntry*. - (make_main): Change GtkList to a GtkCList to avoid scrolling bug. - (click_entry): Changed to "select_row" callback prototype. - (delete_entry): Removed. - (item_destroy_notify): Added in lieu of delete_entry. - (sort_alpha): Accept ThemeEntry* and not GtkBin*. - (add_theme_list): Added. - (update_theme_entries): Use clist functions. - -2001-07-27 Bradford Hovinen <hovinen@ximian.com> - - * RELEASE : 1.5.2 - -2001-07-27 Bradford Hovinen <hovinen@ximian.com> - - * Makefile.am: Remove empty SUBDIRS line - -2001-07-20 Chema Celorio <chema@celorio.com> - - * RELEASE : 1.5.0 - -2001-07-19 Richard Hestilow <hestilow@ximian.com> - - * Started. - - * main.c (main): Don't waitpid. I have no idea why it didn't work, - but this is at least better than waiting forever. diff --git a/capplets/theme-switcher/Makefile.am b/capplets/theme-switcher/Makefile.am deleted file mode 100644 index c9324240f..000000000 --- a/capplets/theme-switcher/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -cappletname = gtk-theme-selector -cappletgroup = "Advanced/" -bin_PROGRAMS = gtk-theme-selector-capplet - -gtk_theme_selector_capplet_LDADD = $(GNOMECC_CAPPLETS_LIBS) -gtk_theme_selector_capplet_SOURCES = \ - da.h \ - file.c \ - globals.c \ - lister.c \ - main.c \ - signals.c \ - demo.c \ - gui.c \ - install.c - -pixmap_DATA = - -## -## You should not need to modify anything below this line -## -@XML_I18N_MERGE_DESKTOP_RULE@ -@GNOMECC_CAPPLETS_DESKTOP_IN_RULE@ - -INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS) -CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) -EXTRA_DIST = $(GNOMECC_CAPPLETS_EXTRA_DIST) -iconsdir = $(GNOMECC_ICONS_DIR) -Gladedir = $(GNOMECC_GLADE_DIR) -pixmapdir = $(GNOMECC_PIXMAPS_DIR) -Glade_DATA = $(cappletname)-properties.glade -icons_DATA = $(cappletname)-capplet.png -desktop = $(cappletname).desktop -all-local: $(desktop) diff --git a/capplets/theme-switcher/da.h b/capplets/theme-switcher/da.h deleted file mode 100644 index 9620fc915..000000000 --- a/capplets/theme-switcher/da.h +++ /dev/null @@ -1,86 +0,0 @@ -#include <gnome.h> -#include <gtk-xmhtml/gtk-xmhtml.h> -#include <gtk/gtk.h> -#include <gdk/gdkx.h> -#include <sys/types.h> -#include <string.h> -#include <dirent.h> -#include <unistd.h> -#include <limits.h> -#include <fcntl.h> - -typedef struct _theme_entry -{ - gchar *name; - gchar *rc; - gchar *dir; - gchar *readme; - gchar *icon; - int row; -} ThemeEntry; - -void md(char *s); -int exists(char *s); -int isfile(char *s); -int isdir(char *s); -char **ls(char *dir, int *num); -void freestrlist(char **l, int num); -void rm(char *s); -void mv(char *s, char *ss); -void cp(char *s, char *ss); -unsigned long moddate(char *s); -int filesize(char *s); -void cd(char *s); -char *cwd(void); -int permissions(char *s); -int owner(char *s); -int group(char *s); -char *username(int uid); -char *homedir(int uid); -char *usershell(int uid); -char *atword(char *s, int num); -char *atchar(char *s, char c); -void word(char *s, int num, char *wd); -int canread(char *s); -int canwrite(char *s); -int canexec(char *s); -char *fileof(char *s); -char *fullfileof(char *s); -char *noext(char *s); -void mkdirs(char *s); - -void -free_theme_list(ThemeEntry *list, gint number); -GList* -list_themes(gchar *dir); -GList* -list_system_themes(void); -GList* -list_user_themes(void); -GtkWidget * -make_main(void); -void -update_theme_entries(GtkWidget *disp_list); -void -signal_apply_theme(GtkWidget *widget); -void -edit_file_to_use(gchar *file, gchar *theme, gchar *font); -void -set_tmp_rc(void); -void -use_theme(gchar *theme, gchar *font); -void -test_theme(gchar *theme, gchar *font); -gchar * -install_theme(gchar *file); -gint -do_demo(int argc, char **argv); -void -send_socket(void); -void -send_reread(void); - - -extern GtkWidget *preview_socket; -extern gint prog_fd; -extern gchar gtkrc_tmp[1024]; diff --git a/capplets/theme-switcher/da.h-67648 b/capplets/theme-switcher/da.h-67648 deleted file mode 100644 index 9620fc915..000000000 --- a/capplets/theme-switcher/da.h-67648 +++ /dev/null @@ -1,86 +0,0 @@ -#include <gnome.h> -#include <gtk-xmhtml/gtk-xmhtml.h> -#include <gtk/gtk.h> -#include <gdk/gdkx.h> -#include <sys/types.h> -#include <string.h> -#include <dirent.h> -#include <unistd.h> -#include <limits.h> -#include <fcntl.h> - -typedef struct _theme_entry -{ - gchar *name; - gchar *rc; - gchar *dir; - gchar *readme; - gchar *icon; - int row; -} ThemeEntry; - -void md(char *s); -int exists(char *s); -int isfile(char *s); -int isdir(char *s); -char **ls(char *dir, int *num); -void freestrlist(char **l, int num); -void rm(char *s); -void mv(char *s, char *ss); -void cp(char *s, char *ss); -unsigned long moddate(char *s); -int filesize(char *s); -void cd(char *s); -char *cwd(void); -int permissions(char *s); -int owner(char *s); -int group(char *s); -char *username(int uid); -char *homedir(int uid); -char *usershell(int uid); -char *atword(char *s, int num); -char *atchar(char *s, char c); -void word(char *s, int num, char *wd); -int canread(char *s); -int canwrite(char *s); -int canexec(char *s); -char *fileof(char *s); -char *fullfileof(char *s); -char *noext(char *s); -void mkdirs(char *s); - -void -free_theme_list(ThemeEntry *list, gint number); -GList* -list_themes(gchar *dir); -GList* -list_system_themes(void); -GList* -list_user_themes(void); -GtkWidget * -make_main(void); -void -update_theme_entries(GtkWidget *disp_list); -void -signal_apply_theme(GtkWidget *widget); -void -edit_file_to_use(gchar *file, gchar *theme, gchar *font); -void -set_tmp_rc(void); -void -use_theme(gchar *theme, gchar *font); -void -test_theme(gchar *theme, gchar *font); -gchar * -install_theme(gchar *file); -gint -do_demo(int argc, char **argv); -void -send_socket(void); -void -send_reread(void); - - -extern GtkWidget *preview_socket; -extern gint prog_fd; -extern gchar gtkrc_tmp[1024]; diff --git a/capplets/theme-switcher/demo.c b/capplets/theme-switcher/demo.c deleted file mode 100644 index 0f8a6ce39..000000000 --- a/capplets/theme-switcher/demo.c +++ /dev/null @@ -1,219 +0,0 @@ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include "da.h" -#include <errno.h> - -GtkWidget *plug; - -void -send_socket() -{ - gchar buffer[256]; - - g_snprintf(buffer, sizeof(buffer), "%11lx ", - (gulong)GDK_WINDOW_XWINDOW (preview_socket->window)); - write(prog_fd, buffer, strlen(buffer)); -} - -void -send_reread() -{ - gchar buffer[256]; - - g_snprintf(buffer, sizeof(buffer), "R "); - write(prog_fd, buffer, strlen(buffer)); -} - -static void -demo_data_in(gpointer data, gint source, GdkInputCondition condition) -{ - gchar buf[256]; - - if (condition & GDK_INPUT_EXCEPTION || - read(source, buf, 2) == 0) - gtk_main_quit(); /* Parent exited */ - else { - if (gtk_rc_reparse_all ()) - gtk_widget_reset_rc_styles(plug); - } -} - -#define NUM 50 - -static void -demo_main(int argc, char **argv, gint in_fd) -{ - gchar buf[256]; - Window window; - GtkWidget *widget, *table, *hbox; - GtkWidget *scrolled_window, *menubar, *menu; - GSList *group; - gchar *titles[2] = {N_("One"),N_("Two")}; - /* just 8 short names that will serve as samples for titles in demo */ - gchar *row1[2] = {N_("Eenie"), N_("Meenie")}; - gchar *row2[2] = {N_("Mynie"), N_("Moe")}; - gchar *row3[2] = {N_("Catcha"), N_("Tiger")}; - gchar *row4[2] = {N_("By Its"), N_("Toe")}; - gchar **rc_files; - gchar **new_rc_files; - gint rc_file_count; - gint new_count; - gchar *home_dir; - gint i; - -#ifdef ENABLE_NLS - for (i=0;i<2;i++) { - titles[i]=_(titles[i]); - row1[i]=_(row1[i]); - row2[i]=_(row2[i]); - row3[i]=_(row3[i]); - row4[i]=_(row4[i]); - } -#endif - - if (read(in_fd, buf, 12) <= 0) - /* Assume this means that our parent exited or was killed */ - exit(0); - - buf[12] = 0; - window = strtol (buf, NULL, 16); - - fcntl(0, F_SETFL, O_NONBLOCK); - - /* Strip out ~/.gtkrc from the set of initial default files. - * to suppress reading of the previous rc file. - */ - - rc_files = gtk_rc_get_default_files(); - for (rc_file_count = 0; rc_files[rc_file_count]; rc_file_count++) - /* Nothing */; - - new_rc_files = g_new (gchar *, rc_file_count + 2); - - home_dir = g_get_home_dir(); - new_count = 0; - - for (i = 0; i<rc_file_count; i++) - { - if (strncmp (rc_files[i], home_dir, strlen (home_dir)) != 0) - new_rc_files[new_count++] = g_strdup (rc_files[i]); - } - new_rc_files[new_count++] = g_strdup (gtkrc_tmp); - new_rc_files[new_count] = NULL; - - gtk_rc_set_default_files (new_rc_files); - g_strfreev (new_rc_files); - - gtk_set_locale(); - gtk_init (&argc, &argv); - - plug = gtk_plug_new(window); - - table = gtk_table_new (5, 3, FALSE); - gtk_container_add(GTK_CONTAINER(plug), table); - - widget = gtk_label_new (_("Selected themes from above will be tested by previewing here.")); - gtk_label_set_justify (GTK_LABEL (widget), GTK_JUSTIFY_LEFT); - gtk_table_attach (GTK_TABLE (table), widget, 0, 3, 0, 1, 0, 0, GNOME_PAD_SMALL, GNOME_PAD_SMALL); - - /* column one */ - widget = gtk_button_new_with_label (_("Sample Button")); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); - gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, 0, GNOME_PAD_SMALL, GNOME_PAD_SMALL); - widget = gtk_check_button_new_with_label (_("Sample Check Button")); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); - gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, 0, GNOME_PAD_SMALL, 0); - widget = gtk_entry_new_with_max_length (50); - gtk_entry_set_text (GTK_ENTRY (widget), _("Sample Text Entry Field")); - gtk_widget_set_usize (widget, 70, -1); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); - gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 4, 5, GTK_EXPAND | GTK_FILL, 0, GNOME_PAD_SMALL, GNOME_PAD_SMALL); - - /* column two */ - - menubar = gtk_menu_bar_new(); - gtk_table_attach (GTK_TABLE (table), menubar, 1, 2, 2, 3, 0, 0, GNOME_PAD_SMALL, GNOME_PAD_SMALL); - - widget = gtk_menu_item_new_with_label(_("Submenu")); - gtk_widget_show(widget); - gtk_menu_bar_append(GTK_MENU_BAR(menubar), widget); - gtk_widget_show(menubar); - - menu = gtk_menu_new(); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(widget), menu); - widget = gtk_menu_item_new_with_label(_("Item 1")); - gtk_widget_show(widget); - gtk_menu_append(GTK_MENU(menu), widget); - widget = gtk_menu_item_new_with_label(_("Another item")); - gtk_widget_show(widget); - gtk_menu_append(GTK_MENU(menu), widget); - - - widget = gtk_radio_button_new_with_label (NULL, _("Radio Button 1")); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (widget)); - gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0, 0, 0); - - widget = gtk_radio_button_new_with_label (group, _("Radio Button 2")); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (widget)); - gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, 0, 0, 0); - - /* column three */ - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); - - gtk_table_attach (GTK_TABLE (table), scrolled_window, 2, 3, 2, 5, GTK_EXPAND | GTK_FILL, 0, GNOME_PAD_SMALL, 0); - - widget = gtk_clist_new_with_titles (2, titles); - gtk_clist_set_column_width (GTK_CLIST(widget), 0, 45); - gtk_clist_set_column_width (GTK_CLIST(widget), 1, 45); - gtk_clist_append (GTK_CLIST(widget), row1); - gtk_clist_append (GTK_CLIST(widget), row2); - gtk_clist_append (GTK_CLIST(widget), row3); - gtk_clist_append (GTK_CLIST(widget), row4); - gtk_widget_set_usize (widget, 160, -1); - - gtk_container_add (GTK_CONTAINER (scrolled_window), widget); - - gdk_input_add_full(in_fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, demo_data_in, NULL, NULL); - gtk_widget_show_all (plug); - - gtk_main (); -} - -gint -do_demo(int argc, char **argv) -{ - gint toProg[2]; - gint pid; - - pipe(toProg); - - if (!(pid = fork())) - { - close(toProg[1]); - demo_main(argc, argv, toProg[0]); - exit(0); - } - else if (pid > 0) - { - close(toProg[0]); - prog_fd = toProg[1]; - return pid; - } - else - { - /* baaaaaaaah eeeeek */ - return -1; - } -} diff --git a/capplets/theme-switcher/demo.c-45827 b/capplets/theme-switcher/demo.c-45827 deleted file mode 100644 index 0f8a6ce39..000000000 --- a/capplets/theme-switcher/demo.c-45827 +++ /dev/null @@ -1,219 +0,0 @@ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include "da.h" -#include <errno.h> - -GtkWidget *plug; - -void -send_socket() -{ - gchar buffer[256]; - - g_snprintf(buffer, sizeof(buffer), "%11lx ", - (gulong)GDK_WINDOW_XWINDOW (preview_socket->window)); - write(prog_fd, buffer, strlen(buffer)); -} - -void -send_reread() -{ - gchar buffer[256]; - - g_snprintf(buffer, sizeof(buffer), "R "); - write(prog_fd, buffer, strlen(buffer)); -} - -static void -demo_data_in(gpointer data, gint source, GdkInputCondition condition) -{ - gchar buf[256]; - - if (condition & GDK_INPUT_EXCEPTION || - read(source, buf, 2) == 0) - gtk_main_quit(); /* Parent exited */ - else { - if (gtk_rc_reparse_all ()) - gtk_widget_reset_rc_styles(plug); - } -} - -#define NUM 50 - -static void -demo_main(int argc, char **argv, gint in_fd) -{ - gchar buf[256]; - Window window; - GtkWidget *widget, *table, *hbox; - GtkWidget *scrolled_window, *menubar, *menu; - GSList *group; - gchar *titles[2] = {N_("One"),N_("Two")}; - /* just 8 short names that will serve as samples for titles in demo */ - gchar *row1[2] = {N_("Eenie"), N_("Meenie")}; - gchar *row2[2] = {N_("Mynie"), N_("Moe")}; - gchar *row3[2] = {N_("Catcha"), N_("Tiger")}; - gchar *row4[2] = {N_("By Its"), N_("Toe")}; - gchar **rc_files; - gchar **new_rc_files; - gint rc_file_count; - gint new_count; - gchar *home_dir; - gint i; - -#ifdef ENABLE_NLS - for (i=0;i<2;i++) { - titles[i]=_(titles[i]); - row1[i]=_(row1[i]); - row2[i]=_(row2[i]); - row3[i]=_(row3[i]); - row4[i]=_(row4[i]); - } -#endif - - if (read(in_fd, buf, 12) <= 0) - /* Assume this means that our parent exited or was killed */ - exit(0); - - buf[12] = 0; - window = strtol (buf, NULL, 16); - - fcntl(0, F_SETFL, O_NONBLOCK); - - /* Strip out ~/.gtkrc from the set of initial default files. - * to suppress reading of the previous rc file. - */ - - rc_files = gtk_rc_get_default_files(); - for (rc_file_count = 0; rc_files[rc_file_count]; rc_file_count++) - /* Nothing */; - - new_rc_files = g_new (gchar *, rc_file_count + 2); - - home_dir = g_get_home_dir(); - new_count = 0; - - for (i = 0; i<rc_file_count; i++) - { - if (strncmp (rc_files[i], home_dir, strlen (home_dir)) != 0) - new_rc_files[new_count++] = g_strdup (rc_files[i]); - } - new_rc_files[new_count++] = g_strdup (gtkrc_tmp); - new_rc_files[new_count] = NULL; - - gtk_rc_set_default_files (new_rc_files); - g_strfreev (new_rc_files); - - gtk_set_locale(); - gtk_init (&argc, &argv); - - plug = gtk_plug_new(window); - - table = gtk_table_new (5, 3, FALSE); - gtk_container_add(GTK_CONTAINER(plug), table); - - widget = gtk_label_new (_("Selected themes from above will be tested by previewing here.")); - gtk_label_set_justify (GTK_LABEL (widget), GTK_JUSTIFY_LEFT); - gtk_table_attach (GTK_TABLE (table), widget, 0, 3, 0, 1, 0, 0, GNOME_PAD_SMALL, GNOME_PAD_SMALL); - - /* column one */ - widget = gtk_button_new_with_label (_("Sample Button")); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); - gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, 0, GNOME_PAD_SMALL, GNOME_PAD_SMALL); - widget = gtk_check_button_new_with_label (_("Sample Check Button")); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); - gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, 0, GNOME_PAD_SMALL, 0); - widget = gtk_entry_new_with_max_length (50); - gtk_entry_set_text (GTK_ENTRY (widget), _("Sample Text Entry Field")); - gtk_widget_set_usize (widget, 70, -1); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); - gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 4, 5, GTK_EXPAND | GTK_FILL, 0, GNOME_PAD_SMALL, GNOME_PAD_SMALL); - - /* column two */ - - menubar = gtk_menu_bar_new(); - gtk_table_attach (GTK_TABLE (table), menubar, 1, 2, 2, 3, 0, 0, GNOME_PAD_SMALL, GNOME_PAD_SMALL); - - widget = gtk_menu_item_new_with_label(_("Submenu")); - gtk_widget_show(widget); - gtk_menu_bar_append(GTK_MENU_BAR(menubar), widget); - gtk_widget_show(menubar); - - menu = gtk_menu_new(); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(widget), menu); - widget = gtk_menu_item_new_with_label(_("Item 1")); - gtk_widget_show(widget); - gtk_menu_append(GTK_MENU(menu), widget); - widget = gtk_menu_item_new_with_label(_("Another item")); - gtk_widget_show(widget); - gtk_menu_append(GTK_MENU(menu), widget); - - - widget = gtk_radio_button_new_with_label (NULL, _("Radio Button 1")); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (widget)); - gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0, 0, 0); - - widget = gtk_radio_button_new_with_label (group, _("Radio Button 2")); - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (widget)); - gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, 0, 0, 0); - - /* column three */ - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); - - gtk_table_attach (GTK_TABLE (table), scrolled_window, 2, 3, 2, 5, GTK_EXPAND | GTK_FILL, 0, GNOME_PAD_SMALL, 0); - - widget = gtk_clist_new_with_titles (2, titles); - gtk_clist_set_column_width (GTK_CLIST(widget), 0, 45); - gtk_clist_set_column_width (GTK_CLIST(widget), 1, 45); - gtk_clist_append (GTK_CLIST(widget), row1); - gtk_clist_append (GTK_CLIST(widget), row2); - gtk_clist_append (GTK_CLIST(widget), row3); - gtk_clist_append (GTK_CLIST(widget), row4); - gtk_widget_set_usize (widget, 160, -1); - - gtk_container_add (GTK_CONTAINER (scrolled_window), widget); - - gdk_input_add_full(in_fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, demo_data_in, NULL, NULL); - gtk_widget_show_all (plug); - - gtk_main (); -} - -gint -do_demo(int argc, char **argv) -{ - gint toProg[2]; - gint pid; - - pipe(toProg); - - if (!(pid = fork())) - { - close(toProg[1]); - demo_main(argc, argv, toProg[0]); - exit(0); - } - else if (pid > 0) - { - close(toProg[0]); - prog_fd = toProg[1]; - return pid; - } - else - { - /* baaaaaaaah eeeeek */ - return -1; - } -} diff --git a/capplets/theme-switcher/file.c b/capplets/theme-switcher/file.c deleted file mode 100644 index 3baae387f..000000000 --- a/capplets/theme-switcher/file.c +++ /dev/null @@ -1,535 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <stdarg.h> -#include <string.h> -#include <fcntl.h> -#include <dirent.h> -#include <signal.h> -#include <time.h> -#include <math.h> -#include <pwd.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/stat.h> -#include "da.h" - -void -md(char *s) -{ - if ((!s) || (!*s)) - return; - mkdir(s, S_IRWXU); -} - -int -exists(char *s) -{ - struct stat st; - - if ((!s) || (!*s)) - return 0; - if (stat(s, &st) < 0) - return 0; - return 1; -} - -int -isfile(char *s) -{ - struct stat st; - - if ((!s) || (!*s)) - return 0; - if (stat(s, &st) < 0) - return 0; - if (st.st_blocks == 0) - return 0; - if (S_ISREG(st.st_mode)) - return 1; - return 0; -} - -int -isdir(char *s) -{ - struct stat st; - - if ((!s) || (!*s)) - return 0; - if (stat(s, &st) < 0) - return 0; - if (S_ISDIR(st.st_mode)) - return 1; - return 0; -} - -int -ls_compare_func(const void *a, const void *b) -{ - return strcmp(*(char **)a, *(char **)b); -} - -char ** -ls(char *dir, int *num) -{ - int i, dirlen; - DIR *dirp; - char **names; - struct dirent *dp; - - if ((!dir) || (!*dir)) - return 0; - dirp = opendir(dir); - if (!dirp) - { - *num = 0; - return NULL; - } - - /* count # of entries in dir (worst case) */ - for (dirlen = 0; (dp = readdir(dirp)) != NULL; dirlen++); - if (!dirlen) - { - closedir(dirp); - *num = dirlen; - return NULL; - } - - /* load up the entries, now that we know how many to make */ - names = (char **)malloc(dirlen * sizeof(char *)); - - if (!names) - return NULL; - - rewinddir(dirp); - for (i = 0; i < dirlen;) - { - dp = readdir(dirp); - if (!dp) - break; - names[i] = (char *)malloc(strlen(dp->d_name) + 1); - if (!names) - return NULL; - strcpy(names[i], dp->d_name); - i++; - } - - if (i < dirlen) - dirlen = i; /* dir got shorter... */ - closedir(dirp); - *num = dirlen; - qsort(names, dirlen, sizeof(char *), ls_compare_func); - - return names; -} - -void -freestrlist(char **l, int num) -{ - if (!l) - return; - while (num--) - if (l[num]) - free(l[num]); - free(l); -} - -void -rm(char *s) -{ - if ((!s) || (!*s)) - return; - unlink(s); -} - -void -mv(char *s, char *ss) -{ - if ((!s) || (!ss) || (!*s) || (!*ss)) - return; - rename(s, ss); -} - -void -cp(char *s, char *ss) -{ - int i; - FILE *f, *ff; - unsigned char buf[1]; - - if ((!s) || (!ss) || (!*s) || (!*ss)) - return; - if (!exists(s)) - return; - i = filesize(s); - f = fopen(s, "r"); - if (!f) - return; - ff = fopen(ss, "w"); - if (!ff) - { - fclose(f); - return; - } - while (fread(buf, 1, 1, f)) - fwrite(buf, 1, 1, ff); - fclose(f); - fclose(ff); -} - -unsigned long -moddate(char *s) -{ - struct stat st; - - if ((!s) || (!*s)) - return 0; - if (!stat(s, &st) < 0) - return 0; - if (st.st_mtime > st.st_ctime) - return st.st_mtime; - else - return st.st_ctime; -} - -int -filesize(char *s) -{ - struct stat st; - - if ((!s) || (!*s)) - return 0; - if (stat(s, &st) < 0) - return 0; - return (int)st.st_size; -} - -void -cd(char *s) -{ - if ((!s) || (!*s)) - return; - chdir(s); -} - -char * -cwd(void) -{ - char s[4096]; - - getcwd(s, sizeof(s)); - return strdup(s); -} - -int -permissions(char *s) -{ - struct stat st; - - if ((!s) || (!*s)) - return 0; - if (!stat(s, &st) < 0) - return 0; - return st.st_mode; -} - -int -owner(char *s) -{ - struct stat st; - - if ((!s) || (!*s)) - return 0; - if (!stat(s, &st) < 0) - return 0; - return st.st_uid; -} - -int -group(char *s) -{ - struct stat st; - - if ((!s) || (!*s)) - return 0; - if (!stat(s, &st) < 0) - return 0; - return st.st_gid; -} - -char * -username(int uid) -{ - struct passwd *pass; - char *result; - - pass = getpwuid(uid); - if (pass && pass->pw_name) - result = strdup(pass->pw_name); - else - result = NULL; - endpwent(); - return result; -} - -char * -homedir(int uid) -{ - struct passwd *pass; - char *result; - - result = getenv("HOME"); - if (result) - return strdup(result); - - pass = getpwuid(uid); - if (pass && pass->pw_dir) - result = strdup(pass->pw_dir); - else - result = NULL; - endpwent(); - return result; -} - -char * -usershell(int uid) -{ - struct passwd *pass; - char *result; - - pass = getpwuid(uid); - if (pass && pass->pw_shell) - result = strdup(pass->pw_shell); - else - result = NULL; - endpwent(); - return result; -} - -char * -atword(char *s, int num) -{ - int cnt, i; - - if (!s) - return NULL; - cnt = 0; - i = 0; - - while (s[i]) - { - if ((s[i] != ' ') && (s[i] != '\t')) - { - if (i == 0) - cnt++; - else if ((s[i - 1] == ' ') || (s[i - 1] == '\t')) - cnt++; - if (cnt == num) - return &s[i]; - } - i++; - } - return NULL; -} - -char * -atchar(char *s, char c) -{ - int i; - - if (!s) - return NULL; - i = 0; - while (s[i] != 0) - { - if (s[i] == c) - return &s[i]; - i++; - } - return NULL; -} - -void -word(char *s, int num, char *wd) -{ - int cnt, i; - char *start, *finish, *ss, *w; - - if (!s) - return; - if (!wd) - return; - if (num <= 0) - { - *wd = 0; - return; - } - cnt = 0; - i = 0; - start = NULL; - finish = NULL; - ss = NULL; - w = wd; - - while (s[i]) - { - if ((cnt == num) && ((s[i] == ' ') || (s[i] == '\t'))) - { - finish = &s[i]; - break; - } - if ((s[i] != ' ') && (s[i] != '\t')) - { - if (i == 0) - { - cnt++; - if (cnt == num) - start = &s[i]; - } - else if ((s[i - 1] == ' ') || (s[i - 1] == '\t')) - { - cnt++; - if (cnt == num) - start = &s[i]; - } - } - i++; - } - if (cnt == num) - { - if ((start) && (finish)) - { - for (ss = start; ss < finish; ss++) - *wd++ = *ss; - } - else if (start) - { - for (ss = start; *ss != 0; ss++) - *wd++ = *ss; - } - *wd = 0; - } - return; -} - -int -canread(char *s) -{ - if ((!s) || (!*s)) - return 0; - return access(s, R_OK); -} - -int -canwrite(char *s) -{ - if ((!s) || (!*s)) - return 0; - return access(s, W_OK); -} - -int -canexec(char *s) -{ - if ((!s) || (!*s)) - return 0; - return access(s, X_OK); -} - -char * -fileof(char *s) -{ - char ss[1024]; - int i, p1, p2; - - i = 0; - p1 = -1; - p2 = -1; - for (i = strlen(s) - 1; i >= 0; i--) - { - if ((s[i] == '.') && (p2 < 0) && (p1 < 0)) - p2 = i; - if ((s[i] == '/') && (p1 < 0)) - p1 = i; - } - if (p2 < 0) - p2 = strlen(s); - if (p1 < 0) - p1 = 0; - for (i = 0; i < (p2 - p1 - 1); i++) - ss[i] = s[p1 + 1 + i]; - ss[i] = 0; - return strdup(ss); -} - -char * -fullfileof(char *s) -{ - char ss[1024]; - int i, p1, p2; - - i = 0; - p1 = -1; - for (i = strlen(s) - 1; i >= 0; i--) - { - if ((s[i] == '/') && (p1 < 0)) - p1 = i; - } - p2 = strlen(s); - for (i = 0; i < (p2 - p1 - 1); i++) - ss[i] = s[p1 + 1 + i]; - ss[i] = 0; - return strdup(ss); -} - -char * -noext(char *s) -{ - char ss[1024]; - int i, p1, p2; - - i = 0; - p1 = -1; - for (i = strlen(s) - 1; i >= 0; i--) - { - if ((s[i] == '/') && (p1 < 0)) - break; - else if (s[i] == '.') - { - p1 = i; - break; - } - } - if (p1 < 0) - return strdup(s); - p2 = strlen(s); - for (i = 0; i < p1; i++) - ss[i] = s[i]; - ss[i] = 0; - return strdup(ss); -} - -void -mkdirs(char *s) -{ - char ss[1024]; - int i, ii; - - i = 0; - ii = 0; - while (s[i]) - { - ss[ii++] = s[i]; - ss[ii] = 0; - if (s[i] == '/') - { - if (!exists(ss)) - md(ss); - else if (!isdir(ss)) - return; - } - i++; - } -} diff --git a/capplets/theme-switcher/file.c-98078 b/capplets/theme-switcher/file.c-98078 deleted file mode 100644 index 3baae387f..000000000 --- a/capplets/theme-switcher/file.c-98078 +++ /dev/null @@ -1,535 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <stdarg.h> -#include <string.h> -#include <fcntl.h> -#include <dirent.h> -#include <signal.h> -#include <time.h> -#include <math.h> -#include <pwd.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/stat.h> -#include "da.h" - -void -md(char *s) -{ - if ((!s) || (!*s)) - return; - mkdir(s, S_IRWXU); -} - -int -exists(char *s) -{ - struct stat st; - - if ((!s) || (!*s)) - return 0; - if (stat(s, &st) < 0) - return 0; - return 1; -} - -int -isfile(char *s) -{ - struct stat st; - - if ((!s) || (!*s)) - return 0; - if (stat(s, &st) < 0) - return 0; - if (st.st_blocks == 0) - return 0; - if (S_ISREG(st.st_mode)) - return 1; - return 0; -} - -int -isdir(char *s) -{ - struct stat st; - - if ((!s) || (!*s)) - return 0; - if (stat(s, &st) < 0) - return 0; - if (S_ISDIR(st.st_mode)) - return 1; - return 0; -} - -int -ls_compare_func(const void *a, const void *b) -{ - return strcmp(*(char **)a, *(char **)b); -} - -char ** -ls(char *dir, int *num) -{ - int i, dirlen; - DIR *dirp; - char **names; - struct dirent *dp; - - if ((!dir) || (!*dir)) - return 0; - dirp = opendir(dir); - if (!dirp) - { - *num = 0; - return NULL; - } - - /* count # of entries in dir (worst case) */ - for (dirlen = 0; (dp = readdir(dirp)) != NULL; dirlen++); - if (!dirlen) - { - closedir(dirp); - *num = dirlen; - return NULL; - } - - /* load up the entries, now that we know how many to make */ - names = (char **)malloc(dirlen * sizeof(char *)); - - if (!names) - return NULL; - - rewinddir(dirp); - for (i = 0; i < dirlen;) - { - dp = readdir(dirp); - if (!dp) - break; - names[i] = (char *)malloc(strlen(dp->d_name) + 1); - if (!names) - return NULL; - strcpy(names[i], dp->d_name); - i++; - } - - if (i < dirlen) - dirlen = i; /* dir got shorter... */ - closedir(dirp); - *num = dirlen; - qsort(names, dirlen, sizeof(char *), ls_compare_func); - - return names; -} - -void -freestrlist(char **l, int num) -{ - if (!l) - return; - while (num--) - if (l[num]) - free(l[num]); - free(l); -} - -void -rm(char *s) -{ - if ((!s) || (!*s)) - return; - unlink(s); -} - -void -mv(char *s, char *ss) -{ - if ((!s) || (!ss) || (!*s) || (!*ss)) - return; - rename(s, ss); -} - -void -cp(char *s, char *ss) -{ - int i; - FILE *f, *ff; - unsigned char buf[1]; - - if ((!s) || (!ss) || (!*s) || (!*ss)) - return; - if (!exists(s)) - return; - i = filesize(s); - f = fopen(s, "r"); - if (!f) - return; - ff = fopen(ss, "w"); - if (!ff) - { - fclose(f); - return; - } - while (fread(buf, 1, 1, f)) - fwrite(buf, 1, 1, ff); - fclose(f); - fclose(ff); -} - -unsigned long -moddate(char *s) -{ - struct stat st; - - if ((!s) || (!*s)) - return 0; - if (!stat(s, &st) < 0) - return 0; - if (st.st_mtime > st.st_ctime) - return st.st_mtime; - else - return st.st_ctime; -} - -int -filesize(char *s) -{ - struct stat st; - - if ((!s) || (!*s)) - return 0; - if (stat(s, &st) < 0) - return 0; - return (int)st.st_size; -} - -void -cd(char *s) -{ - if ((!s) || (!*s)) - return; - chdir(s); -} - -char * -cwd(void) -{ - char s[4096]; - - getcwd(s, sizeof(s)); - return strdup(s); -} - -int -permissions(char *s) -{ - struct stat st; - - if ((!s) || (!*s)) - return 0; - if (!stat(s, &st) < 0) - return 0; - return st.st_mode; -} - -int -owner(char *s) -{ - struct stat st; - - if ((!s) || (!*s)) - return 0; - if (!stat(s, &st) < 0) - return 0; - return st.st_uid; -} - -int -group(char *s) -{ - struct stat st; - - if ((!s) || (!*s)) - return 0; - if (!stat(s, &st) < 0) - return 0; - return st.st_gid; -} - -char * -username(int uid) -{ - struct passwd *pass; - char *result; - - pass = getpwuid(uid); - if (pass && pass->pw_name) - result = strdup(pass->pw_name); - else - result = NULL; - endpwent(); - return result; -} - -char * -homedir(int uid) -{ - struct passwd *pass; - char *result; - - result = getenv("HOME"); - if (result) - return strdup(result); - - pass = getpwuid(uid); - if (pass && pass->pw_dir) - result = strdup(pass->pw_dir); - else - result = NULL; - endpwent(); - return result; -} - -char * -usershell(int uid) -{ - struct passwd *pass; - char *result; - - pass = getpwuid(uid); - if (pass && pass->pw_shell) - result = strdup(pass->pw_shell); - else - result = NULL; - endpwent(); - return result; -} - -char * -atword(char *s, int num) -{ - int cnt, i; - - if (!s) - return NULL; - cnt = 0; - i = 0; - - while (s[i]) - { - if ((s[i] != ' ') && (s[i] != '\t')) - { - if (i == 0) - cnt++; - else if ((s[i - 1] == ' ') || (s[i - 1] == '\t')) - cnt++; - if (cnt == num) - return &s[i]; - } - i++; - } - return NULL; -} - -char * -atchar(char *s, char c) -{ - int i; - - if (!s) - return NULL; - i = 0; - while (s[i] != 0) - { - if (s[i] == c) - return &s[i]; - i++; - } - return NULL; -} - -void -word(char *s, int num, char *wd) -{ - int cnt, i; - char *start, *finish, *ss, *w; - - if (!s) - return; - if (!wd) - return; - if (num <= 0) - { - *wd = 0; - return; - } - cnt = 0; - i = 0; - start = NULL; - finish = NULL; - ss = NULL; - w = wd; - - while (s[i]) - { - if ((cnt == num) && ((s[i] == ' ') || (s[i] == '\t'))) - { - finish = &s[i]; - break; - } - if ((s[i] != ' ') && (s[i] != '\t')) - { - if (i == 0) - { - cnt++; - if (cnt == num) - start = &s[i]; - } - else if ((s[i - 1] == ' ') || (s[i - 1] == '\t')) - { - cnt++; - if (cnt == num) - start = &s[i]; - } - } - i++; - } - if (cnt == num) - { - if ((start) && (finish)) - { - for (ss = start; ss < finish; ss++) - *wd++ = *ss; - } - else if (start) - { - for (ss = start; *ss != 0; ss++) - *wd++ = *ss; - } - *wd = 0; - } - return; -} - -int -canread(char *s) -{ - if ((!s) || (!*s)) - return 0; - return access(s, R_OK); -} - -int -canwrite(char *s) -{ - if ((!s) || (!*s)) - return 0; - return access(s, W_OK); -} - -int -canexec(char *s) -{ - if ((!s) || (!*s)) - return 0; - return access(s, X_OK); -} - -char * -fileof(char *s) -{ - char ss[1024]; - int i, p1, p2; - - i = 0; - p1 = -1; - p2 = -1; - for (i = strlen(s) - 1; i >= 0; i--) - { - if ((s[i] == '.') && (p2 < 0) && (p1 < 0)) - p2 = i; - if ((s[i] == '/') && (p1 < 0)) - p1 = i; - } - if (p2 < 0) - p2 = strlen(s); - if (p1 < 0) - p1 = 0; - for (i = 0; i < (p2 - p1 - 1); i++) - ss[i] = s[p1 + 1 + i]; - ss[i] = 0; - return strdup(ss); -} - -char * -fullfileof(char *s) -{ - char ss[1024]; - int i, p1, p2; - - i = 0; - p1 = -1; - for (i = strlen(s) - 1; i >= 0; i--) - { - if ((s[i] == '/') && (p1 < 0)) - p1 = i; - } - p2 = strlen(s); - for (i = 0; i < (p2 - p1 - 1); i++) - ss[i] = s[p1 + 1 + i]; - ss[i] = 0; - return strdup(ss); -} - -char * -noext(char *s) -{ - char ss[1024]; - int i, p1, p2; - - i = 0; - p1 = -1; - for (i = strlen(s) - 1; i >= 0; i--) - { - if ((s[i] == '/') && (p1 < 0)) - break; - else if (s[i] == '.') - { - p1 = i; - break; - } - } - if (p1 < 0) - return strdup(s); - p2 = strlen(s); - for (i = 0; i < p1; i++) - ss[i] = s[i]; - ss[i] = 0; - return strdup(ss); -} - -void -mkdirs(char *s) -{ - char ss[1024]; - int i, ii; - - i = 0; - ii = 0; - while (s[i]) - { - ss[ii++] = s[i]; - ss[ii] = 0; - if (s[i] == '/') - { - if (!exists(ss)) - md(ss); - else if (!isdir(ss)) - return; - } - i++; - } -} diff --git a/capplets/theme-switcher/globals.c b/capplets/theme-switcher/globals.c deleted file mode 100644 index 4ba604be7..000000000 --- a/capplets/theme-switcher/globals.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "da.h" - -gint prog_fd; -gchar gtkrc_tmp[1024]; -GtkWidget *preview_socket; diff --git a/capplets/theme-switcher/globals.c-53032 b/capplets/theme-switcher/globals.c-53032 deleted file mode 100644 index 4ba604be7..000000000 --- a/capplets/theme-switcher/globals.c-53032 +++ /dev/null @@ -1,5 +0,0 @@ -#include "da.h" - -gint prog_fd; -gchar gtkrc_tmp[1024]; -GtkWidget *preview_socket; diff --git a/capplets/theme-switcher/gtk-theme-selector-capplet.png b/capplets/theme-switcher/gtk-theme-selector-capplet.png Binary files differdeleted file mode 100644 index 4ceb86de6..000000000 --- a/capplets/theme-switcher/gtk-theme-selector-capplet.png +++ /dev/null diff --git a/capplets/theme-switcher/gtk-theme-selector-properties.glade b/capplets/theme-switcher/gtk-theme-selector-properties.glade deleted file mode 100644 index e69de29bb..000000000 --- a/capplets/theme-switcher/gtk-theme-selector-properties.glade +++ /dev/null diff --git a/capplets/theme-switcher/gtk-theme-selector-properties.glade-56055 b/capplets/theme-switcher/gtk-theme-selector-properties.glade-56055 deleted file mode 100644 index e69de29bb..000000000 --- a/capplets/theme-switcher/gtk-theme-selector-properties.glade-56055 +++ /dev/null diff --git a/capplets/theme-switcher/gtk-theme-selector.desktop.in.in b/capplets/theme-switcher/gtk-theme-selector.desktop.in.in deleted file mode 100644 index b6d961af8..000000000 --- a/capplets/theme-switcher/gtk-theme-selector.desktop.in.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=Gtk+ Theme Selector -_Comment=Select which gtk+ theme to use -Exec=gtk-theme-selector-capplet -Icon=gnome-ccthemes.png -Terminal=0 -Type=Application diff --git a/capplets/theme-switcher/gui.c b/capplets/theme-switcher/gui.c deleted file mode 100644 index 8287c2882..000000000 --- a/capplets/theme-switcher/gui.c +++ /dev/null @@ -1,629 +0,0 @@ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include "da.h" -#include "capplet-widget.h" -#include <signal.h> - -static gboolean ignore_change = FALSE; - -static GtkWidget *install_theme_file_sel; - -static GtkWidget *capplet_widget; -static GtkWidget *theme_list; -static GtkWidget *auto_preview; - -static ThemeEntry *current_theme = NULL; -static ThemeEntry *current_global_theme = NULL; -static ThemeEntry *initial_theme = NULL; -static ThemeEntry *last_theme = NULL; -static GtkWidget *font_sel; -static GtkWidget *font_cbox; -static gboolean initial_preview; -/* If this is TRUE, then we use the custom font */ -static gboolean initial_font_cbox; -static gchar *initial_font; -static void -click_preview(GtkWidget *widget, gpointer data); -static void -click_try(GtkWidget *widget, gpointer data); -static void -click_help(GtkWidget *widget, gpointer data); -static void -click_ok(GtkWidget *widget, gpointer data); -static void -click_revert(GtkWidget *widget, gpointer data); -static void -click_entry(GtkWidget *clist, gint row, gint col, GdkEvent *event, - gpointer data); - -static void -auto_callback (GtkWidget *widget, gpointer data) -{ - if (ignore_change == FALSE) { - if (GTK_TOGGLE_BUTTON (auto_preview)->active) - click_preview (widget,NULL); - capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), TRUE); - } - -} -static void -font_callback (GtkWidget *widget, gchar *font, gpointer data) -{ - if (ignore_change == FALSE) { - capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), TRUE); - if (GTK_TOGGLE_BUTTON (auto_preview)->active) - click_preview (widget,NULL); - } -} -static void -use_theme_font_callback (GtkWidget *widget, gpointer data) -{ - if (ignore_change == FALSE) { - capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), TRUE); - if (GTK_TOGGLE_BUTTON (auto_preview)->active) - click_preview (widget,NULL); - if (!GTK_TOGGLE_BUTTON (font_cbox)->active) - gtk_widget_set_sensitive (font_sel, FALSE); - else - gtk_widget_set_sensitive (font_sel, TRUE); - } -} -static void -browse_dialog_ok (GtkWidget *widget, gpointer data) -{ - GtkWidget *filesel = gtk_widget_get_toplevel (widget); - gchar *filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel)); - gchar *error; - - error = install_theme (filename); - - if (!error) - update_theme_entries (theme_list); - else - { - char *msg = g_strdup_printf (_("Error installing theme:\n'%s'\n%s"), - filename, error); - GtkWidget *msgbox = gnome_message_box_new (msg, - GNOME_MESSAGE_BOX_ERROR, - GNOME_STOCK_BUTTON_OK, - NULL); - gnome_dialog_run (GNOME_DIALOG (msgbox)); - g_free (msg); - g_free (error); - } - gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE); - gtk_widget_destroy (filesel); -} -static void -browse_dialog_close (GtkWidget *widget, gpointer data) -{ - gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE); - gtk_widget_destroy (gtk_widget_get_toplevel (widget)); -} -static void -browse_dialog_kill (GtkWidget *widget, gpointer data) -{ - gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE); -} - -static void -install_theme_callback (GtkWidget *widget, gpointer data) -{ - GtkWidget *parent; - gtk_widget_set_sensitive (widget, FALSE); - - install_theme_file_sel = gtk_file_selection_new (_("Select a theme to install")); - gtk_file_selection_hide_fileop_buttons (GTK_FILE_SELECTION (install_theme_file_sel)); - /* BEGIN UGLINESS. This code is stolen from gnome_dialog_set_parent. - * We want its functionality, but it takes a GnomeDialog as its argument. - * So we copy it )-: */ - - parent = gtk_widget_get_toplevel (GTK_WIDGET (widget)); - - /* We'd like to set a transient_for hint here, but it isn't - * worth the bother, since our parent window isn't in this process - */ - if ( gnome_preferences_get_dialog_centered() ) { - /* User wants us to center over parent */ - - gint x, y, w, h, dialog_x, dialog_y; - - if (GTK_WIDGET_VISIBLE(parent)) { - /* Throw out other positioning */ - gtk_window_set_position(GTK_WINDOW(install_theme_file_sel), - GTK_WIN_POS_NONE); - - gdk_window_get_origin (GTK_WIDGET(parent)->window, &x, &y); - gdk_window_get_size (GTK_WIDGET(parent)->window, &w, &h); - - /* The problem here is we don't know how big the dialog is. - So "centered" isn't really true. We'll go with - "kind of more or less on top" */ - dialog_x = x + w/4; - dialog_y = y + h/4; - - gtk_widget_set_uposition(GTK_WIDGET(install_theme_file_sel), - dialog_x, dialog_y); - } - } - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (install_theme_file_sel) - ->ok_button), "clicked", - (GtkSignalFunc) browse_dialog_ok, - widget); - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (install_theme_file_sel)->cancel_button), - "clicked", - GTK_SIGNAL_FUNC(browse_dialog_close), - widget); - gtk_signal_connect (GTK_OBJECT (install_theme_file_sel), "destroy", - GTK_SIGNAL_FUNC(browse_dialog_kill), - widget); - - if (gtk_grab_get_current ()) - gtk_grab_add (install_theme_file_sel); - - gtk_widget_show (install_theme_file_sel); - -} - -static gint -delete_capplet (GtkWidget *widget, GdkEvent *event, gpointer data) -{ - /* We don't want the toplevel window destroyed until - * our child exits. - */ - close(prog_fd); - return FALSE; -} - -GtkWidget * -make_main(void) -{ - void *sw, *label; - GtkWidget *box, *hbox, *hbox2, *vbox; - GtkWidget *frame, *button; - GtkWidget *button_vbox; - gboolean default_used; - - capplet_widget = capplet_widget_new(); - gtk_container_set_border_width(GTK_CONTAINER(capplet_widget), 5); - - box = gtk_vbox_new(FALSE, GNOME_PAD); - hbox = gtk_hbox_new(TRUE, GNOME_PAD); - frame = gtk_frame_new (_("Available Themes")); - hbox2 = gtk_hbox_new(FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (hbox2), GNOME_PAD_SMALL); - gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(box), hbox, TRUE, TRUE, 0); - gtk_container_add (GTK_CONTAINER (frame), hbox2); - - /* List of available themes - */ - theme_list = gtk_clist_new (1); - gtk_signal_connect (GTK_OBJECT (theme_list), "select_row", click_entry, - NULL); - gtk_clist_set_selection_mode(GTK_CLIST(theme_list), GTK_SELECTION_BROWSE); - sw = gtk_scrolled_window_new(NULL, NULL); - gtk_container_add (GTK_CONTAINER(sw), theme_list); - /* Mysterious allocation bug keeps shrinking hscrollbar during browse */ - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); - gtk_widget_set_usize (sw, 120, -1); - - gtk_box_pack_start(GTK_BOX(hbox2), sw, TRUE, TRUE, 0); - - /* Buttons to preview, and install themes - */ - button_vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_container_set_border_width (GTK_CONTAINER (button_vbox), GNOME_PAD_SMALL); - gtk_box_pack_start(GTK_BOX(hbox2), button_vbox, FALSE, FALSE, 0); - - label = gtk_label_new (_("Auto\nPreview")); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - auto_preview = gtk_check_button_new (); - initial_preview = gnome_config_get_bool ("/theme-switcher-capplet/settings/auto=TRUE"); - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (auto_preview), - initial_preview); - gtk_signal_connect (GTK_OBJECT (auto_preview), "toggled", GTK_SIGNAL_FUNC (auto_callback), NULL); - gtk_container_add (GTK_CONTAINER (auto_preview), label); - gtk_box_pack_start (GTK_BOX (button_vbox), auto_preview, FALSE, FALSE, 0); - button = gtk_button_new_with_label (_("Preview")); - gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (click_preview), NULL); - gtk_box_pack_start (GTK_BOX (button_vbox), button, FALSE, FALSE, 0); - button = gtk_button_new_with_label (_("Install new\ntheme...")); - gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (install_theme_callback), NULL); - gtk_box_pack_start (GTK_BOX (button_vbox), button, FALSE, FALSE, 0); - - /* Font selector. - */ - frame = gtk_frame_new (_("User Font")); - gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0); - font_sel = gnome_font_picker_new (); - gnome_font_picker_set_mode (GNOME_FONT_PICKER (font_sel), - GNOME_FONT_PICKER_MODE_FONT_INFO); - initial_font = gnome_config_get_string_with_default ("/theme-switcher-capplet/settings/font",&default_used); - - - if (initial_font == NULL) { - - GtkStyle *style; - - gtk_widget_ensure_style (frame); - style = gtk_widget_get_style (frame); - - if (style->rc_style == NULL) { - /* FIXME - should really get this from X somehow */ - /* for now we just assume default gtk font */ - initial_font = g_strdup(_("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*")); - } else { - initial_font = style->rc_style->font_name; - } - } - - gnome_font_picker_set_font_name (GNOME_FONT_PICKER (font_sel), initial_font); - - gnome_font_picker_fi_set_use_font_in_label (GNOME_FONT_PICKER (font_sel), - TRUE, - 12); - gnome_font_picker_fi_set_show_size (GNOME_FONT_PICKER (font_sel), FALSE); - gtk_signal_connect (GTK_OBJECT (font_sel), - "font_set", - font_callback, - NULL); - vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (frame), vbox); - font_cbox = gtk_check_button_new_with_label (_("Use custom font.")); - initial_font_cbox = gnome_config_get_bool ("/theme-switcher-capplet/settings/use_theme_font=FALSE"); - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (font_cbox), - initial_font_cbox); - gtk_signal_connect (GTK_OBJECT (font_cbox), - "toggled", - GTK_SIGNAL_FUNC (use_theme_font_callback), - NULL); - gtk_box_pack_start (GTK_BOX (vbox), font_cbox, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), font_sel, FALSE, FALSE, 0); - if (!GTK_TOGGLE_BUTTON (font_cbox)->active) - gtk_widget_set_sensitive (font_sel, FALSE); - else - gtk_widget_set_sensitive (font_sel, TRUE); - - gtk_widget_show_all (vbox); - - -#if 0 - readme_display = gtk_xmhtml_new(); - gtk_container_add(GTK_CONTAINER(frame2), readme_display) ; -#endif - /* Preview of theme - */ - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL); - frame = gtk_frame_new (_("Preview")); - gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 0); - gtk_container_add (GTK_CONTAINER (frame), hbox); - - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); - gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0); - preview_socket = gtk_socket_new(); - gtk_container_add(GTK_CONTAINER(frame), preview_socket); - update_theme_entries(theme_list); - - gtk_signal_connect (GTK_OBJECT (capplet_widget), "help", - GTK_SIGNAL_FUNC (click_help), NULL); - gtk_signal_connect (GTK_OBJECT (capplet_widget), "try", - GTK_SIGNAL_FUNC (click_try), NULL); - gtk_signal_connect (GTK_OBJECT (capplet_widget), "ok", - GTK_SIGNAL_FUNC (click_ok), NULL); - gtk_signal_connect (GTK_OBJECT (capplet_widget), "revert", - GTK_SIGNAL_FUNC (click_revert), NULL); - gtk_signal_connect (GTK_OBJECT (capplet_widget), "cancel", - GTK_SIGNAL_FUNC (click_revert), NULL); - gtk_signal_connect (GTK_OBJECT (capplet_widget), "delete_event", - GTK_SIGNAL_FUNC (delete_capplet), NULL); - gtk_container_add (GTK_CONTAINER (capplet_widget), box); - - last_theme = NULL; - - return capplet_widget; -} - -static void -click_preview(GtkWidget *widget, gpointer data) -{ - gchar *rc; - -/* if (current_theme == last_theme) - return;*/ - last_theme = current_theme; - if (!current_theme) { - return; - } - rc = current_theme->rc; - if (GTK_TOGGLE_BUTTON (font_cbox)->active) - test_theme(rc, - gnome_font_picker_get_font_name (GNOME_FONT_PICKER (font_sel))); - else - { - test_theme(rc, NULL); - } - - send_reread(); -} -static void -click_help(GtkWidget *widget, gpointer data) -{ - gchar *tmp; - - tmp = gnome_help_file_find_file ("users-guide", "gccdesktop.html#GCCTHEME"); - if (tmp) { - gnome_help_goto(0, tmp); - g_free(tmp); - } else { - GtkWidget *mbox; - - mbox = gnome_message_box_new(_("No help is available/installed for these settings. Please make sure you\nhave the GNOME User's Guide installed on your system."), - GNOME_MESSAGE_BOX_ERROR, - _("Close"), NULL); - - gtk_widget_show(mbox); - } - -} -static void -click_try(GtkWidget *widget, gpointer data) -{ - gchar *rc; - gchar *dir; - -/* if (current_theme == current_global_theme) - return;*/ - if (!current_theme) - return; - - current_global_theme = current_theme; - rc = current_theme->rc; - dir = current_theme->dir; - - /* hack for enlightenment only!!!! */ - /* FIXME: restart what ever windowmanager you have! */ - /*g_snprintf(cmd, sizeof(cmd), "eesh -e \"restart %s/e\"", dir);*/ - /* printf("%s\n", cmd); */ - send_reread(); - if (GTK_TOGGLE_BUTTON (font_cbox)->active) - { - use_theme(rc, - gnome_font_picker_get_font_name (GNOME_FONT_PICKER (font_sel))); - } - else - { - use_theme(rc, NULL); - } - gdk_error_warnings = 0; - signal_apply_theme(widget); - gdk_flush(); - /* system(cmd); */ - gdk_error_warnings = 1; -} -static void -click_ok(GtkWidget *widget, gpointer data) -{ - click_try (widget, data); - gnome_config_set_bool ("/theme-switcher-capplet/settings/auto",GTK_TOGGLE_BUTTON (auto_preview)->active); - gnome_config_set_string ("/theme-switcher-capplet/settings/theme", current_theme->name); - gnome_config_set_bool ("/theme-switcher-capplet/settings/use_theme_font", - GTK_TOGGLE_BUTTON (font_cbox)->active); - gnome_config_set_string ("/theme-switcher-capplet/settings/font", - gnome_font_picker_get_font_name (GNOME_FONT_PICKER (font_sel))); - gnome_config_sync (); -} -static void -click_revert(GtkWidget *widget, gpointer data) -{ - gchar *rc; - - if (!initial_theme) - /* we hope this doesn't happen, but it could if things - * are mis-installed -jrb */ - /* Damn, I hate this code... )-: */ - return; - - rc = initial_theme->rc; - - if ((current_global_theme != initial_theme) || - (initial_font_cbox != GTK_TOGGLE_BUTTON (font_cbox)->active) || - (GTK_TOGGLE_BUTTON (font_cbox)->active && strcmp (initial_font, - gnome_font_picker_get_font_name (GNOME_FONT_PICKER (font_sel))))) - { - - /* This if statement is magic to determine if we want to reset the system theme. - * It can almost certainly be cleaned up if needed. Basicly, it sees if anything has - * or if the theme has been set.. */ - send_reread(); - use_theme(rc, initial_font); - gdk_error_warnings = 0; - signal_apply_theme(widget); - gdk_flush(); - gdk_error_warnings = 1; - } - current_global_theme = initial_theme; - ignore_change = TRUE; - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (auto_preview), - initial_preview); - - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (font_cbox), - initial_font_cbox); - if (initial_font) - gnome_font_picker_set_font_name (GNOME_FONT_PICKER (font_sel), - initial_font); - gtk_clist_select_row (GTK_CLIST (theme_list), initial_theme->row, -1); - test_theme(rc, initial_font); - send_reread(); - if (!GTK_TOGGLE_BUTTON (font_cbox)->active) - gtk_widget_set_sensitive (font_sel, FALSE); - else - gtk_widget_set_sensitive (font_sel, TRUE); - ignore_change = FALSE; - current_theme = initial_theme; -} - -static void -click_entry(GtkWidget *clist, gint row, gint col, GdkEvent *event, - gpointer data) -{ - /* Load in the README file */ -#if 0 - if (readme_current) - { - g_free(readme_current); - readme_current = NULL; - } - f = fopen(readme, "r"); - if (f) - { - GString *new_readme = g_string_new (NULL); - - while (fgets(buf, 1024, f)) - g_string_append (new_readme, buf); - - fclose(f); - - gtk_xmhtml_source(GTK_XMHTML(readme_display), new_readme->str); - g_string_free (new_readme, TRUE); - } - else - gtk_xmhtml_source(GTK_XMHTML(readme_display), ""); -#endif - if (!ignore_change) - { - current_theme = gtk_clist_get_row_data (GTK_CLIST (clist), row); - - if (initial_theme) - capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), TRUE); - else - capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), FALSE); - - if (GTK_TOGGLE_BUTTON (auto_preview)->active) - click_preview (NULL,NULL); - } -} - -static void -item_destroy_notify (gpointer data) -{ - ThemeEntry *item = data; - - g_free(item->name); - g_free(item->rc); - g_free(item->dir); - g_free(item->icon); - - if (current_theme == item) - current_theme = NULL; - - g_free (item); -} -static gint sort_alpha(const void *a, const void *b) -{ - const ThemeEntry *A, *B; - - A = a; - B = b; - - return g_strcasecmp(A->name, B->name); -} - -static void -add_theme_list (GtkWidget *disp_list, GList *themes, gchar *d_theme, gchar *current_name) -{ - ThemeEntry *item; - GList *l; - - for (l = themes; l != NULL; l = l->next) - { - gchar *text[1] = { NULL }; - - item = l->data; - text[0] = item->name; - item->row = gtk_clist_append (GTK_CLIST(disp_list), text); - - gtk_clist_set_row_data_full (GTK_CLIST(disp_list), item->row, item, - item_destroy_notify); - - if (strcmp (d_theme, item->name) == 0) - { - current_global_theme = item; - initial_theme = item; - } - if (current_name && (strcmp (current_name, item->name) == 0)) - { - current_theme = item; - } - } -} - -void -update_theme_entries(GtkWidget *disp_list) -{ - GList *themes; - gchar *d_theme = gnome_config_get_string ("/theme-switcher-capplet/settings/theme=Default"); - gchar *current_name = NULL; - - if (current_theme) - current_name = g_strdup (current_theme->name); - else - current_name = d_theme; - - current_theme = NULL; - initial_theme = NULL; - - /* Suppress an update here, because the BROWSE mode will - * cause a false initial selection - */ - ignore_change = TRUE; - - gtk_clist_clear (GTK_CLIST(disp_list)); - - themes = list_system_themes(); - themes = g_list_sort (themes, sort_alpha); - add_theme_list (disp_list, themes, d_theme, current_name); - - themes = list_user_themes(); - themes = g_list_sort (themes, sort_alpha); - add_theme_list (disp_list, themes, d_theme, current_name); - - ignore_change = FALSE; - - if (!current_theme) - current_theme = initial_theme; - - /* Suppress an update only if the current theme didn't change or - * this was the first time around - */ - if (current_theme) - { - if (current_name && - strcmp (current_theme->name, - current_name) != 0) - { - gtk_clist_select_row (GTK_CLIST (disp_list), current_theme->row, 0); - } - else - { - ignore_change = TRUE; - gtk_clist_select_row (GTK_CLIST (disp_list), current_theme->row, 0); - ignore_change = FALSE; - } - } - - if (current_name != d_theme) { - g_free (current_name); - g_free (d_theme); - } else - g_free (d_theme); - if (current_theme == NULL) - ; -} diff --git a/capplets/theme-switcher/gui.c-6060 b/capplets/theme-switcher/gui.c-6060 deleted file mode 100644 index 8287c2882..000000000 --- a/capplets/theme-switcher/gui.c-6060 +++ /dev/null @@ -1,629 +0,0 @@ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include "da.h" -#include "capplet-widget.h" -#include <signal.h> - -static gboolean ignore_change = FALSE; - -static GtkWidget *install_theme_file_sel; - -static GtkWidget *capplet_widget; -static GtkWidget *theme_list; -static GtkWidget *auto_preview; - -static ThemeEntry *current_theme = NULL; -static ThemeEntry *current_global_theme = NULL; -static ThemeEntry *initial_theme = NULL; -static ThemeEntry *last_theme = NULL; -static GtkWidget *font_sel; -static GtkWidget *font_cbox; -static gboolean initial_preview; -/* If this is TRUE, then we use the custom font */ -static gboolean initial_font_cbox; -static gchar *initial_font; -static void -click_preview(GtkWidget *widget, gpointer data); -static void -click_try(GtkWidget *widget, gpointer data); -static void -click_help(GtkWidget *widget, gpointer data); -static void -click_ok(GtkWidget *widget, gpointer data); -static void -click_revert(GtkWidget *widget, gpointer data); -static void -click_entry(GtkWidget *clist, gint row, gint col, GdkEvent *event, - gpointer data); - -static void -auto_callback (GtkWidget *widget, gpointer data) -{ - if (ignore_change == FALSE) { - if (GTK_TOGGLE_BUTTON (auto_preview)->active) - click_preview (widget,NULL); - capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), TRUE); - } - -} -static void -font_callback (GtkWidget *widget, gchar *font, gpointer data) -{ - if (ignore_change == FALSE) { - capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), TRUE); - if (GTK_TOGGLE_BUTTON (auto_preview)->active) - click_preview (widget,NULL); - } -} -static void -use_theme_font_callback (GtkWidget *widget, gpointer data) -{ - if (ignore_change == FALSE) { - capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), TRUE); - if (GTK_TOGGLE_BUTTON (auto_preview)->active) - click_preview (widget,NULL); - if (!GTK_TOGGLE_BUTTON (font_cbox)->active) - gtk_widget_set_sensitive (font_sel, FALSE); - else - gtk_widget_set_sensitive (font_sel, TRUE); - } -} -static void -browse_dialog_ok (GtkWidget *widget, gpointer data) -{ - GtkWidget *filesel = gtk_widget_get_toplevel (widget); - gchar *filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel)); - gchar *error; - - error = install_theme (filename); - - if (!error) - update_theme_entries (theme_list); - else - { - char *msg = g_strdup_printf (_("Error installing theme:\n'%s'\n%s"), - filename, error); - GtkWidget *msgbox = gnome_message_box_new (msg, - GNOME_MESSAGE_BOX_ERROR, - GNOME_STOCK_BUTTON_OK, - NULL); - gnome_dialog_run (GNOME_DIALOG (msgbox)); - g_free (msg); - g_free (error); - } - gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE); - gtk_widget_destroy (filesel); -} -static void -browse_dialog_close (GtkWidget *widget, gpointer data) -{ - gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE); - gtk_widget_destroy (gtk_widget_get_toplevel (widget)); -} -static void -browse_dialog_kill (GtkWidget *widget, gpointer data) -{ - gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE); -} - -static void -install_theme_callback (GtkWidget *widget, gpointer data) -{ - GtkWidget *parent; - gtk_widget_set_sensitive (widget, FALSE); - - install_theme_file_sel = gtk_file_selection_new (_("Select a theme to install")); - gtk_file_selection_hide_fileop_buttons (GTK_FILE_SELECTION (install_theme_file_sel)); - /* BEGIN UGLINESS. This code is stolen from gnome_dialog_set_parent. - * We want its functionality, but it takes a GnomeDialog as its argument. - * So we copy it )-: */ - - parent = gtk_widget_get_toplevel (GTK_WIDGET (widget)); - - /* We'd like to set a transient_for hint here, but it isn't - * worth the bother, since our parent window isn't in this process - */ - if ( gnome_preferences_get_dialog_centered() ) { - /* User wants us to center over parent */ - - gint x, y, w, h, dialog_x, dialog_y; - - if (GTK_WIDGET_VISIBLE(parent)) { - /* Throw out other positioning */ - gtk_window_set_position(GTK_WINDOW(install_theme_file_sel), - GTK_WIN_POS_NONE); - - gdk_window_get_origin (GTK_WIDGET(parent)->window, &x, &y); - gdk_window_get_size (GTK_WIDGET(parent)->window, &w, &h); - - /* The problem here is we don't know how big the dialog is. - So "centered" isn't really true. We'll go with - "kind of more or less on top" */ - dialog_x = x + w/4; - dialog_y = y + h/4; - - gtk_widget_set_uposition(GTK_WIDGET(install_theme_file_sel), - dialog_x, dialog_y); - } - } - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (install_theme_file_sel) - ->ok_button), "clicked", - (GtkSignalFunc) browse_dialog_ok, - widget); - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (install_theme_file_sel)->cancel_button), - "clicked", - GTK_SIGNAL_FUNC(browse_dialog_close), - widget); - gtk_signal_connect (GTK_OBJECT (install_theme_file_sel), "destroy", - GTK_SIGNAL_FUNC(browse_dialog_kill), - widget); - - if (gtk_grab_get_current ()) - gtk_grab_add (install_theme_file_sel); - - gtk_widget_show (install_theme_file_sel); - -} - -static gint -delete_capplet (GtkWidget *widget, GdkEvent *event, gpointer data) -{ - /* We don't want the toplevel window destroyed until - * our child exits. - */ - close(prog_fd); - return FALSE; -} - -GtkWidget * -make_main(void) -{ - void *sw, *label; - GtkWidget *box, *hbox, *hbox2, *vbox; - GtkWidget *frame, *button; - GtkWidget *button_vbox; - gboolean default_used; - - capplet_widget = capplet_widget_new(); - gtk_container_set_border_width(GTK_CONTAINER(capplet_widget), 5); - - box = gtk_vbox_new(FALSE, GNOME_PAD); - hbox = gtk_hbox_new(TRUE, GNOME_PAD); - frame = gtk_frame_new (_("Available Themes")); - hbox2 = gtk_hbox_new(FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (hbox2), GNOME_PAD_SMALL); - gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(box), hbox, TRUE, TRUE, 0); - gtk_container_add (GTK_CONTAINER (frame), hbox2); - - /* List of available themes - */ - theme_list = gtk_clist_new (1); - gtk_signal_connect (GTK_OBJECT (theme_list), "select_row", click_entry, - NULL); - gtk_clist_set_selection_mode(GTK_CLIST(theme_list), GTK_SELECTION_BROWSE); - sw = gtk_scrolled_window_new(NULL, NULL); - gtk_container_add (GTK_CONTAINER(sw), theme_list); - /* Mysterious allocation bug keeps shrinking hscrollbar during browse */ - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); - gtk_widget_set_usize (sw, 120, -1); - - gtk_box_pack_start(GTK_BOX(hbox2), sw, TRUE, TRUE, 0); - - /* Buttons to preview, and install themes - */ - button_vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_container_set_border_width (GTK_CONTAINER (button_vbox), GNOME_PAD_SMALL); - gtk_box_pack_start(GTK_BOX(hbox2), button_vbox, FALSE, FALSE, 0); - - label = gtk_label_new (_("Auto\nPreview")); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - auto_preview = gtk_check_button_new (); - initial_preview = gnome_config_get_bool ("/theme-switcher-capplet/settings/auto=TRUE"); - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (auto_preview), - initial_preview); - gtk_signal_connect (GTK_OBJECT (auto_preview), "toggled", GTK_SIGNAL_FUNC (auto_callback), NULL); - gtk_container_add (GTK_CONTAINER (auto_preview), label); - gtk_box_pack_start (GTK_BOX (button_vbox), auto_preview, FALSE, FALSE, 0); - button = gtk_button_new_with_label (_("Preview")); - gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (click_preview), NULL); - gtk_box_pack_start (GTK_BOX (button_vbox), button, FALSE, FALSE, 0); - button = gtk_button_new_with_label (_("Install new\ntheme...")); - gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (install_theme_callback), NULL); - gtk_box_pack_start (GTK_BOX (button_vbox), button, FALSE, FALSE, 0); - - /* Font selector. - */ - frame = gtk_frame_new (_("User Font")); - gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0); - font_sel = gnome_font_picker_new (); - gnome_font_picker_set_mode (GNOME_FONT_PICKER (font_sel), - GNOME_FONT_PICKER_MODE_FONT_INFO); - initial_font = gnome_config_get_string_with_default ("/theme-switcher-capplet/settings/font",&default_used); - - - if (initial_font == NULL) { - - GtkStyle *style; - - gtk_widget_ensure_style (frame); - style = gtk_widget_get_style (frame); - - if (style->rc_style == NULL) { - /* FIXME - should really get this from X somehow */ - /* for now we just assume default gtk font */ - initial_font = g_strdup(_("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*")); - } else { - initial_font = style->rc_style->font_name; - } - } - - gnome_font_picker_set_font_name (GNOME_FONT_PICKER (font_sel), initial_font); - - gnome_font_picker_fi_set_use_font_in_label (GNOME_FONT_PICKER (font_sel), - TRUE, - 12); - gnome_font_picker_fi_set_show_size (GNOME_FONT_PICKER (font_sel), FALSE); - gtk_signal_connect (GTK_OBJECT (font_sel), - "font_set", - font_callback, - NULL); - vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (frame), vbox); - font_cbox = gtk_check_button_new_with_label (_("Use custom font.")); - initial_font_cbox = gnome_config_get_bool ("/theme-switcher-capplet/settings/use_theme_font=FALSE"); - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (font_cbox), - initial_font_cbox); - gtk_signal_connect (GTK_OBJECT (font_cbox), - "toggled", - GTK_SIGNAL_FUNC (use_theme_font_callback), - NULL); - gtk_box_pack_start (GTK_BOX (vbox), font_cbox, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), font_sel, FALSE, FALSE, 0); - if (!GTK_TOGGLE_BUTTON (font_cbox)->active) - gtk_widget_set_sensitive (font_sel, FALSE); - else - gtk_widget_set_sensitive (font_sel, TRUE); - - gtk_widget_show_all (vbox); - - -#if 0 - readme_display = gtk_xmhtml_new(); - gtk_container_add(GTK_CONTAINER(frame2), readme_display) ; -#endif - /* Preview of theme - */ - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL); - frame = gtk_frame_new (_("Preview")); - gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 0); - gtk_container_add (GTK_CONTAINER (frame), hbox); - - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); - gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0); - preview_socket = gtk_socket_new(); - gtk_container_add(GTK_CONTAINER(frame), preview_socket); - update_theme_entries(theme_list); - - gtk_signal_connect (GTK_OBJECT (capplet_widget), "help", - GTK_SIGNAL_FUNC (click_help), NULL); - gtk_signal_connect (GTK_OBJECT (capplet_widget), "try", - GTK_SIGNAL_FUNC (click_try), NULL); - gtk_signal_connect (GTK_OBJECT (capplet_widget), "ok", - GTK_SIGNAL_FUNC (click_ok), NULL); - gtk_signal_connect (GTK_OBJECT (capplet_widget), "revert", - GTK_SIGNAL_FUNC (click_revert), NULL); - gtk_signal_connect (GTK_OBJECT (capplet_widget), "cancel", - GTK_SIGNAL_FUNC (click_revert), NULL); - gtk_signal_connect (GTK_OBJECT (capplet_widget), "delete_event", - GTK_SIGNAL_FUNC (delete_capplet), NULL); - gtk_container_add (GTK_CONTAINER (capplet_widget), box); - - last_theme = NULL; - - return capplet_widget; -} - -static void -click_preview(GtkWidget *widget, gpointer data) -{ - gchar *rc; - -/* if (current_theme == last_theme) - return;*/ - last_theme = current_theme; - if (!current_theme) { - return; - } - rc = current_theme->rc; - if (GTK_TOGGLE_BUTTON (font_cbox)->active) - test_theme(rc, - gnome_font_picker_get_font_name (GNOME_FONT_PICKER (font_sel))); - else - { - test_theme(rc, NULL); - } - - send_reread(); -} -static void -click_help(GtkWidget *widget, gpointer data) -{ - gchar *tmp; - - tmp = gnome_help_file_find_file ("users-guide", "gccdesktop.html#GCCTHEME"); - if (tmp) { - gnome_help_goto(0, tmp); - g_free(tmp); - } else { - GtkWidget *mbox; - - mbox = gnome_message_box_new(_("No help is available/installed for these settings. Please make sure you\nhave the GNOME User's Guide installed on your system."), - GNOME_MESSAGE_BOX_ERROR, - _("Close"), NULL); - - gtk_widget_show(mbox); - } - -} -static void -click_try(GtkWidget *widget, gpointer data) -{ - gchar *rc; - gchar *dir; - -/* if (current_theme == current_global_theme) - return;*/ - if (!current_theme) - return; - - current_global_theme = current_theme; - rc = current_theme->rc; - dir = current_theme->dir; - - /* hack for enlightenment only!!!! */ - /* FIXME: restart what ever windowmanager you have! */ - /*g_snprintf(cmd, sizeof(cmd), "eesh -e \"restart %s/e\"", dir);*/ - /* printf("%s\n", cmd); */ - send_reread(); - if (GTK_TOGGLE_BUTTON (font_cbox)->active) - { - use_theme(rc, - gnome_font_picker_get_font_name (GNOME_FONT_PICKER (font_sel))); - } - else - { - use_theme(rc, NULL); - } - gdk_error_warnings = 0; - signal_apply_theme(widget); - gdk_flush(); - /* system(cmd); */ - gdk_error_warnings = 1; -} -static void -click_ok(GtkWidget *widget, gpointer data) -{ - click_try (widget, data); - gnome_config_set_bool ("/theme-switcher-capplet/settings/auto",GTK_TOGGLE_BUTTON (auto_preview)->active); - gnome_config_set_string ("/theme-switcher-capplet/settings/theme", current_theme->name); - gnome_config_set_bool ("/theme-switcher-capplet/settings/use_theme_font", - GTK_TOGGLE_BUTTON (font_cbox)->active); - gnome_config_set_string ("/theme-switcher-capplet/settings/font", - gnome_font_picker_get_font_name (GNOME_FONT_PICKER (font_sel))); - gnome_config_sync (); -} -static void -click_revert(GtkWidget *widget, gpointer data) -{ - gchar *rc; - - if (!initial_theme) - /* we hope this doesn't happen, but it could if things - * are mis-installed -jrb */ - /* Damn, I hate this code... )-: */ - return; - - rc = initial_theme->rc; - - if ((current_global_theme != initial_theme) || - (initial_font_cbox != GTK_TOGGLE_BUTTON (font_cbox)->active) || - (GTK_TOGGLE_BUTTON (font_cbox)->active && strcmp (initial_font, - gnome_font_picker_get_font_name (GNOME_FONT_PICKER (font_sel))))) - { - - /* This if statement is magic to determine if we want to reset the system theme. - * It can almost certainly be cleaned up if needed. Basicly, it sees if anything has - * or if the theme has been set.. */ - send_reread(); - use_theme(rc, initial_font); - gdk_error_warnings = 0; - signal_apply_theme(widget); - gdk_flush(); - gdk_error_warnings = 1; - } - current_global_theme = initial_theme; - ignore_change = TRUE; - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (auto_preview), - initial_preview); - - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (font_cbox), - initial_font_cbox); - if (initial_font) - gnome_font_picker_set_font_name (GNOME_FONT_PICKER (font_sel), - initial_font); - gtk_clist_select_row (GTK_CLIST (theme_list), initial_theme->row, -1); - test_theme(rc, initial_font); - send_reread(); - if (!GTK_TOGGLE_BUTTON (font_cbox)->active) - gtk_widget_set_sensitive (font_sel, FALSE); - else - gtk_widget_set_sensitive (font_sel, TRUE); - ignore_change = FALSE; - current_theme = initial_theme; -} - -static void -click_entry(GtkWidget *clist, gint row, gint col, GdkEvent *event, - gpointer data) -{ - /* Load in the README file */ -#if 0 - if (readme_current) - { - g_free(readme_current); - readme_current = NULL; - } - f = fopen(readme, "r"); - if (f) - { - GString *new_readme = g_string_new (NULL); - - while (fgets(buf, 1024, f)) - g_string_append (new_readme, buf); - - fclose(f); - - gtk_xmhtml_source(GTK_XMHTML(readme_display), new_readme->str); - g_string_free (new_readme, TRUE); - } - else - gtk_xmhtml_source(GTK_XMHTML(readme_display), ""); -#endif - if (!ignore_change) - { - current_theme = gtk_clist_get_row_data (GTK_CLIST (clist), row); - - if (initial_theme) - capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), TRUE); - else - capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), FALSE); - - if (GTK_TOGGLE_BUTTON (auto_preview)->active) - click_preview (NULL,NULL); - } -} - -static void -item_destroy_notify (gpointer data) -{ - ThemeEntry *item = data; - - g_free(item->name); - g_free(item->rc); - g_free(item->dir); - g_free(item->icon); - - if (current_theme == item) - current_theme = NULL; - - g_free (item); -} -static gint sort_alpha(const void *a, const void *b) -{ - const ThemeEntry *A, *B; - - A = a; - B = b; - - return g_strcasecmp(A->name, B->name); -} - -static void -add_theme_list (GtkWidget *disp_list, GList *themes, gchar *d_theme, gchar *current_name) -{ - ThemeEntry *item; - GList *l; - - for (l = themes; l != NULL; l = l->next) - { - gchar *text[1] = { NULL }; - - item = l->data; - text[0] = item->name; - item->row = gtk_clist_append (GTK_CLIST(disp_list), text); - - gtk_clist_set_row_data_full (GTK_CLIST(disp_list), item->row, item, - item_destroy_notify); - - if (strcmp (d_theme, item->name) == 0) - { - current_global_theme = item; - initial_theme = item; - } - if (current_name && (strcmp (current_name, item->name) == 0)) - { - current_theme = item; - } - } -} - -void -update_theme_entries(GtkWidget *disp_list) -{ - GList *themes; - gchar *d_theme = gnome_config_get_string ("/theme-switcher-capplet/settings/theme=Default"); - gchar *current_name = NULL; - - if (current_theme) - current_name = g_strdup (current_theme->name); - else - current_name = d_theme; - - current_theme = NULL; - initial_theme = NULL; - - /* Suppress an update here, because the BROWSE mode will - * cause a false initial selection - */ - ignore_change = TRUE; - - gtk_clist_clear (GTK_CLIST(disp_list)); - - themes = list_system_themes(); - themes = g_list_sort (themes, sort_alpha); - add_theme_list (disp_list, themes, d_theme, current_name); - - themes = list_user_themes(); - themes = g_list_sort (themes, sort_alpha); - add_theme_list (disp_list, themes, d_theme, current_name); - - ignore_change = FALSE; - - if (!current_theme) - current_theme = initial_theme; - - /* Suppress an update only if the current theme didn't change or - * this was the first time around - */ - if (current_theme) - { - if (current_name && - strcmp (current_theme->name, - current_name) != 0) - { - gtk_clist_select_row (GTK_CLIST (disp_list), current_theme->row, 0); - } - else - { - ignore_change = TRUE; - gtk_clist_select_row (GTK_CLIST (disp_list), current_theme->row, 0); - ignore_change = FALSE; - } - } - - if (current_name != d_theme) { - g_free (current_name); - g_free (d_theme); - } else - g_free (d_theme); - if (current_theme == NULL) - ; -} diff --git a/capplets/theme-switcher/install.c b/capplets/theme-switcher/install.c deleted file mode 100644 index fd586114b..000000000 --- a/capplets/theme-switcher/install.c +++ /dev/null @@ -1,82 +0,0 @@ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include "da.h" -#include <errno.h> - -gchar * -install_theme(gchar *file) -{ - gchar s[4096]; - gchar th[4096]; - FILE *f; - guchar buf[1024]; - gchar *theme_dir; - gchar *home; - - if (isdir(file)) - return FALSE; - - theme_dir = gtk_rc_get_theme_dir(); - if (geteuid() == 0) - g_snprintf(th, sizeof(th), "%s/", theme_dir); - else - { - home = g_get_home_dir(); - if (!home) - { - g_free(theme_dir); - return g_strdup(_("Home directory doesn't exist!\n")); - } - g_snprintf(th, sizeof(th), "%s/.themes/", home); - } - g_free(theme_dir); - - if (!isdir(th)) - md(th); - - if (!isfile(file)) - return g_strdup(_("Theme does not exist")); - - f = fopen(file, "r"); - if (f) - { - fread(buf, 1, 1000, f); - fclose(f); - if ((buf[0] == 31) && (buf[1] == 139)) - { - /*gzipped tarball */ - /*sprintf(s,"gzip -d -c < %s | tar -xf - -C %s",Theme_Tar_Ball,Theme_Path); */ - g_snprintf(s, sizeof(s), - "gzip -d -c < %s | (cd %s ; tar -xf -)", - file, th); - } - else if ((buf[257] == 'u') && (buf[258] == 's') && (buf[259] == 't') && - (buf[260] == 'a') && (buf[261] == 'r')) - { - /*vanilla tarball */ - /*sprintf(s,"tar -xf - -C %s < %s",Theme_Path,Theme_Tar_Ball); */ - g_snprintf(s, sizeof(s), - "(cd %s && tar -xf %s", - th, file); - } else - s[0] = '\0'; - - if (*s) - { - gint status = system(s); - if (status < 0) - return g_strdup(g_strerror (errno)); - else if (status != 0) - return g_strdup_printf(_("Command '%s' failed"), s); - else - return NULL; - } - else - return g_strdup(_("Unknown file format")); - } - - return FALSE; -} diff --git a/capplets/theme-switcher/install.c-64828 b/capplets/theme-switcher/install.c-64828 deleted file mode 100644 index fd586114b..000000000 --- a/capplets/theme-switcher/install.c-64828 +++ /dev/null @@ -1,82 +0,0 @@ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include "da.h" -#include <errno.h> - -gchar * -install_theme(gchar *file) -{ - gchar s[4096]; - gchar th[4096]; - FILE *f; - guchar buf[1024]; - gchar *theme_dir; - gchar *home; - - if (isdir(file)) - return FALSE; - - theme_dir = gtk_rc_get_theme_dir(); - if (geteuid() == 0) - g_snprintf(th, sizeof(th), "%s/", theme_dir); - else - { - home = g_get_home_dir(); - if (!home) - { - g_free(theme_dir); - return g_strdup(_("Home directory doesn't exist!\n")); - } - g_snprintf(th, sizeof(th), "%s/.themes/", home); - } - g_free(theme_dir); - - if (!isdir(th)) - md(th); - - if (!isfile(file)) - return g_strdup(_("Theme does not exist")); - - f = fopen(file, "r"); - if (f) - { - fread(buf, 1, 1000, f); - fclose(f); - if ((buf[0] == 31) && (buf[1] == 139)) - { - /*gzipped tarball */ - /*sprintf(s,"gzip -d -c < %s | tar -xf - -C %s",Theme_Tar_Ball,Theme_Path); */ - g_snprintf(s, sizeof(s), - "gzip -d -c < %s | (cd %s ; tar -xf -)", - file, th); - } - else if ((buf[257] == 'u') && (buf[258] == 's') && (buf[259] == 't') && - (buf[260] == 'a') && (buf[261] == 'r')) - { - /*vanilla tarball */ - /*sprintf(s,"tar -xf - -C %s < %s",Theme_Path,Theme_Tar_Ball); */ - g_snprintf(s, sizeof(s), - "(cd %s && tar -xf %s", - th, file); - } else - s[0] = '\0'; - - if (*s) - { - gint status = system(s); - if (status < 0) - return g_strdup(g_strerror (errno)); - else if (status != 0) - return g_strdup_printf(_("Command '%s' failed"), s); - else - return NULL; - } - else - return g_strdup(_("Unknown file format")); - } - - return FALSE; -} diff --git a/capplets/theme-switcher/lister.c b/capplets/theme-switcher/lister.c deleted file mode 100644 index 1e624e003..000000000 --- a/capplets/theme-switcher/lister.c +++ /dev/null @@ -1,215 +0,0 @@ -#include "da.h" -#include <sys/types.h> -#include <utime.h> -#define MARK_STRING "# -- THEME AUTO-WRITTEN DO NOT EDIT\n" -static void -print_standard_stuff(FILE *fout, gchar *theme, gchar *font) -{ - gchar *homedir; - - homedir = g_strconcat ("include \"", - gnome_util_user_home(), - "/.gtkrc.mine\"\n\n", NULL); - fprintf(fout, MARK_STRING); - fprintf(fout, "include \"%s\"\n\n", theme); - if (font) - fprintf(fout, "style \"user-font\"\n{\n font=\"%s\"\n}\nwidget_class \"*\" style \"user-font\"\n\n", font); - fprintf(fout, homedir); - g_free (homedir); - fprintf(fout, MARK_STRING); -} -void -edit_file_to_use(gchar *file, gchar *theme, gchar *font) -{ - FILE *fin, *fout; - gchar tmp[4096], buf[4096]; - gchar nextline = 0, hastheme = 0; - - srand(time(NULL)); - g_snprintf(tmp, sizeof(tmp), "/tmp/gtkrc_%i", rand()); - fout = fopen(tmp, "w"); - if (!fout) - return; - fin = fopen(file, "r"); - if (!fin) - { - print_standard_stuff (fout, theme, font); - fclose(fout); - cp(tmp, file); - return; - } - while (fgets(buf, sizeof(buf), fin)) - { - if (!strcmp(MARK_STRING, buf)) - hastheme += 1; - } - rewind(fin); - if (!hastheme) - { - print_standard_stuff (fout, theme, font); - while (fgets(buf, sizeof(buf), fin)) - fprintf(fout, "%s", buf); - } - else if (hastheme == 1) - /* we keep this in for backwards compatability. */ - { - nextline = 0; - while (fgets(buf, sizeof(buf), fin)) - { - if (nextline == 1) - nextline = 0; - else if (!strcmp(MARK_STRING, buf)) - { - print_standard_stuff (fout, theme, font); - nextline = 1; - } - else if (nextline == 0) - fprintf(fout, "%s", buf); - } - } - else - { - nextline = 0; - while (fgets(buf, sizeof(buf), fin)) - { - if (!strcmp(MARK_STRING, buf)) - { - if (nextline == 0) - { - nextline = 1; - print_standard_stuff (fout, theme, font); - } - else - { - nextline = 0; - } - } else if (nextline == 0) - fprintf(fout, "%s", buf); - } - } - fclose(fin); - fclose(fout); - cp(tmp, file); - rm(tmp); -} - -void -set_tmp_rc(void) -{ - gchar s[4096], *home; - - home = g_get_home_dir (); - if (!home) - return; - g_snprintf(s, sizeof(s), "%s/.gtkrc", home); - srand(time(NULL)); - g_snprintf(gtkrc_tmp, sizeof(gtkrc_tmp), "/tmp/%i-gtkrc-%i", time(NULL), rand()); - cp(s, gtkrc_tmp); -} - -void -use_theme(gchar *theme, gchar *font) -{ - gchar s[4096], *home; - - home = g_get_home_dir (); - if (!home) - return; - g_snprintf(s, sizeof(s), "%s/.gtkrc", home); - edit_file_to_use(s, theme, font); -} - -void -test_theme(gchar *theme, gchar *font) -{ - static time_t last_written_time = 0; - time_t current_time = time (NULL); - struct utimbuf buf; - - edit_file_to_use(gtkrc_tmp, theme, font); - - if (last_written_time >= current_time) - { - current_time = last_written_time + 1; - buf.actime = current_time; - buf.modtime = current_time; - utime (gtkrc_tmp, &buf); - } - - last_written_time = current_time; -} - -void -free_theme_list(ThemeEntry *list, gint number) -{ - gint i; - - for(i = 0; i < number; i++) - { - g_free(list[i].name); - g_free(list[i].rc); - g_free(list[i].readme); - g_free(list[i].icon); - } - g_free(list); -} - -GList * -list_themes(gchar *dir) -{ - gchar **dir_listing = NULL, *tmp; - GList *list = NULL; - gint i = 0, num = 0; - - dir_listing = ls(dir, &num); - for(i = 0; i < num; i++) - { - tmp = g_strdup_printf ("%s/%s/gtk/gtkrc", dir, dir_listing[i]); - if (isfile(tmp)) - { - ThemeEntry *item = g_new0 (ThemeEntry, 1); - item->name = g_strdup(dir_listing[i]); - item->rc = g_strdup (tmp); - item->dir = g_strdup_printf ("%s/%s", dir, dir_listing[i]); - item->readme = g_strdup_printf ("%s/%s/README.html", dir, dir_listing[i]); - item->icon = g_strdup_printf ("%s/%s/ICON.png", dir, dir_listing[i]); - list = g_list_prepend (list, item); - } - g_free (tmp); - } - freestrlist(dir_listing, num); - return g_list_reverse (list); -} - -GList * -list_system_themes(void) -{ - gchar *theme_dir = NULL; - GList *list = NULL; - - theme_dir = gtk_rc_get_theme_dir(); - list = list_themes(theme_dir); - g_free(theme_dir); - return list; -} - -GList * -list_user_themes() -{ - gchar *home = NULL; - gchar *theme_dir = NULL; - GList *list = NULL; - - home = g_get_home_dir (); - if (!home) - return NULL; - - if (!isdir(home)) - return NULL; - - theme_dir = g_malloc(strlen(home) + strlen("/.themes") + 1); - sprintf(theme_dir, "%s%s", home, "/.themes"); - list = list_themes(theme_dir); - g_free(theme_dir); - return list; -} diff --git a/capplets/theme-switcher/lister.c-42011 b/capplets/theme-switcher/lister.c-42011 deleted file mode 100644 index 1e624e003..000000000 --- a/capplets/theme-switcher/lister.c-42011 +++ /dev/null @@ -1,215 +0,0 @@ -#include "da.h" -#include <sys/types.h> -#include <utime.h> -#define MARK_STRING "# -- THEME AUTO-WRITTEN DO NOT EDIT\n" -static void -print_standard_stuff(FILE *fout, gchar *theme, gchar *font) -{ - gchar *homedir; - - homedir = g_strconcat ("include \"", - gnome_util_user_home(), - "/.gtkrc.mine\"\n\n", NULL); - fprintf(fout, MARK_STRING); - fprintf(fout, "include \"%s\"\n\n", theme); - if (font) - fprintf(fout, "style \"user-font\"\n{\n font=\"%s\"\n}\nwidget_class \"*\" style \"user-font\"\n\n", font); - fprintf(fout, homedir); - g_free (homedir); - fprintf(fout, MARK_STRING); -} -void -edit_file_to_use(gchar *file, gchar *theme, gchar *font) -{ - FILE *fin, *fout; - gchar tmp[4096], buf[4096]; - gchar nextline = 0, hastheme = 0; - - srand(time(NULL)); - g_snprintf(tmp, sizeof(tmp), "/tmp/gtkrc_%i", rand()); - fout = fopen(tmp, "w"); - if (!fout) - return; - fin = fopen(file, "r"); - if (!fin) - { - print_standard_stuff (fout, theme, font); - fclose(fout); - cp(tmp, file); - return; - } - while (fgets(buf, sizeof(buf), fin)) - { - if (!strcmp(MARK_STRING, buf)) - hastheme += 1; - } - rewind(fin); - if (!hastheme) - { - print_standard_stuff (fout, theme, font); - while (fgets(buf, sizeof(buf), fin)) - fprintf(fout, "%s", buf); - } - else if (hastheme == 1) - /* we keep this in for backwards compatability. */ - { - nextline = 0; - while (fgets(buf, sizeof(buf), fin)) - { - if (nextline == 1) - nextline = 0; - else if (!strcmp(MARK_STRING, buf)) - { - print_standard_stuff (fout, theme, font); - nextline = 1; - } - else if (nextline == 0) - fprintf(fout, "%s", buf); - } - } - else - { - nextline = 0; - while (fgets(buf, sizeof(buf), fin)) - { - if (!strcmp(MARK_STRING, buf)) - { - if (nextline == 0) - { - nextline = 1; - print_standard_stuff (fout, theme, font); - } - else - { - nextline = 0; - } - } else if (nextline == 0) - fprintf(fout, "%s", buf); - } - } - fclose(fin); - fclose(fout); - cp(tmp, file); - rm(tmp); -} - -void -set_tmp_rc(void) -{ - gchar s[4096], *home; - - home = g_get_home_dir (); - if (!home) - return; - g_snprintf(s, sizeof(s), "%s/.gtkrc", home); - srand(time(NULL)); - g_snprintf(gtkrc_tmp, sizeof(gtkrc_tmp), "/tmp/%i-gtkrc-%i", time(NULL), rand()); - cp(s, gtkrc_tmp); -} - -void -use_theme(gchar *theme, gchar *font) -{ - gchar s[4096], *home; - - home = g_get_home_dir (); - if (!home) - return; - g_snprintf(s, sizeof(s), "%s/.gtkrc", home); - edit_file_to_use(s, theme, font); -} - -void -test_theme(gchar *theme, gchar *font) -{ - static time_t last_written_time = 0; - time_t current_time = time (NULL); - struct utimbuf buf; - - edit_file_to_use(gtkrc_tmp, theme, font); - - if (last_written_time >= current_time) - { - current_time = last_written_time + 1; - buf.actime = current_time; - buf.modtime = current_time; - utime (gtkrc_tmp, &buf); - } - - last_written_time = current_time; -} - -void -free_theme_list(ThemeEntry *list, gint number) -{ - gint i; - - for(i = 0; i < number; i++) - { - g_free(list[i].name); - g_free(list[i].rc); - g_free(list[i].readme); - g_free(list[i].icon); - } - g_free(list); -} - -GList * -list_themes(gchar *dir) -{ - gchar **dir_listing = NULL, *tmp; - GList *list = NULL; - gint i = 0, num = 0; - - dir_listing = ls(dir, &num); - for(i = 0; i < num; i++) - { - tmp = g_strdup_printf ("%s/%s/gtk/gtkrc", dir, dir_listing[i]); - if (isfile(tmp)) - { - ThemeEntry *item = g_new0 (ThemeEntry, 1); - item->name = g_strdup(dir_listing[i]); - item->rc = g_strdup (tmp); - item->dir = g_strdup_printf ("%s/%s", dir, dir_listing[i]); - item->readme = g_strdup_printf ("%s/%s/README.html", dir, dir_listing[i]); - item->icon = g_strdup_printf ("%s/%s/ICON.png", dir, dir_listing[i]); - list = g_list_prepend (list, item); - } - g_free (tmp); - } - freestrlist(dir_listing, num); - return g_list_reverse (list); -} - -GList * -list_system_themes(void) -{ - gchar *theme_dir = NULL; - GList *list = NULL; - - theme_dir = gtk_rc_get_theme_dir(); - list = list_themes(theme_dir); - g_free(theme_dir); - return list; -} - -GList * -list_user_themes() -{ - gchar *home = NULL; - gchar *theme_dir = NULL; - GList *list = NULL; - - home = g_get_home_dir (); - if (!home) - return NULL; - - if (!isdir(home)) - return NULL; - - theme_dir = g_malloc(strlen(home) + strlen("/.themes") + 1); - sprintf(theme_dir, "%s%s", home, "/.themes"); - list = list_themes(theme_dir); - g_free(theme_dir); - return list; -} diff --git a/capplets/theme-switcher/main.c b/capplets/theme-switcher/main.c deleted file mode 100644 index 3913c8725..000000000 --- a/capplets/theme-switcher/main.c +++ /dev/null @@ -1,44 +0,0 @@ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include "capplet-widget.h" -#include "da.h" - -#define THEME_SWITCHER_VERSION "0.1" - -int -main(int argc, char **argv) -{ - GtkWidget *w; - gint child_pid; - - bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE); - - set_tmp_rc(); - child_pid = do_demo(argc, argv); - switch (gnome_capplet_init ("gtk-theme-selector", - THEME_SWITCHER_VERSION, argc, argv, NULL, 0, NULL)) { - case -1: - exit (1); - case 1: - return 0; - } - w = make_main(); - gtk_widget_show_all(w); - send_socket(); - - gtk_main(); - /* This doesn't work any more -- why? */ -#if 0 - /* Pause here until our child exits and the socket can be safely - * destroyed - */ - if (child_pid > 0) - waitpid(child_pid, NULL, 0); -#endif - - return 0; -} diff --git a/capplets/theme-switcher/signals.c b/capplets/theme-switcher/signals.c deleted file mode 100644 index feecad58c..000000000 --- a/capplets/theme-switcher/signals.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "da.h" - -void -signal_apply_theme(GtkWidget *widget) -{ - GdkEventClient rcevent; - - rcevent.type = GDK_CLIENT_EVENT; - rcevent.window = widget->window; - rcevent.send_event = TRUE; - rcevent.message_type = gdk_atom_intern("_GTK_READ_RCFILES", FALSE); - rcevent.data_format = 8; - gdk_event_send_clientmessage_toall((GdkEvent *)&rcevent); -} diff --git a/capplets/theme-switcher/signals.c-20981 b/capplets/theme-switcher/signals.c-20981 deleted file mode 100644 index feecad58c..000000000 --- a/capplets/theme-switcher/signals.c-20981 +++ /dev/null @@ -1,14 +0,0 @@ -#include "da.h" - -void -signal_apply_theme(GtkWidget *widget) -{ - GdkEventClient rcevent; - - rcevent.type = GDK_CLIENT_EVENT; - rcevent.window = widget->window; - rcevent.send_event = TRUE; - rcevent.message_type = gdk_atom_intern("_GTK_READ_RCFILES", FALSE); - rcevent.data_format = 8; - gdk_event_send_clientmessage_toall((GdkEvent *)&rcevent); -} diff --git a/capplets/theme-switcher/theme-switcher-capplet.png b/capplets/theme-switcher/theme-switcher-capplet.png Binary files differdeleted file mode 100644 index 4ceb86de6..000000000 --- a/capplets/theme-switcher/theme-switcher-capplet.png +++ /dev/null diff --git a/capplets/ui-properties/.cvsignore b/capplets/ui-properties/.cvsignore deleted file mode 100644 index 51a0e37ec..000000000 --- a/capplets/ui-properties/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -Makefile -Makefile.in -.deps -.libs -*.lo -*.la -*.o -ui-properties -*.desktop -*.desktop.in
\ No newline at end of file diff --git a/capplets/ui-properties/ChangeLog b/capplets/ui-properties/ChangeLog deleted file mode 100644 index 7a5fdd1f3..000000000 --- a/capplets/ui-properties/ChangeLog +++ /dev/null @@ -1,20 +0,0 @@ -2001-09-29 Richard Hestilow <hestilow@ximian.com> - - * prefs-widget.c (prefs_widget_set_arg): Register - callbacks after loading the preferences; otherwise they will - get triggered unnecessarily. - (selected_cb): Only trigger a change if there really was one. - Fixes bug #9161. - -2001-07-27 Bradford Hovinen <hovinen@ximian.com> - - * RELEASE : 1.5.2 - -2001-07-20 Chema Celorio <chema@celorio.com> - - * RELEASE : 1.5.0 - -2001-07-19 Chema Celorio <chema@celorio.com> - - * Makefile.am (cappletname): distcheck fixes - diff --git a/capplets/ui-properties/Makefile.am b/capplets/ui-properties/Makefile.am deleted file mode 100644 index 057028aa6..000000000 --- a/capplets/ui-properties/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -cappletname = behavior -cappletgroup = "Advanced/" -bin_PROGRAMS = ui-properties - -ui_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS) -ui_properties_SOURCES = \ - prefs-widget.c prefs-widget.h\ - prefs-widget-mdi.c prefs-widget-mdi.h\ - prefs-widget-dialogs.c prefs-widget-dialogs.h\ - prefs-widget-app.c prefs-widget-app.h\ - preferences.c preferences.h\ - main.c - -pixmap_DATA = - -## -## You should not need to modify anything below this line -## -@XML_I18N_MERGE_DESKTOP_RULE@ -@GNOMECC_CAPPLETS_DESKTOP_IN_RULE@ - -INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS) -CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) -EXTRA_DIST = $(GNOMECC_CAPPLETS_EXTRA_DIST) -iconsdir = $(GNOMECC_ICONS_DIR) -Gladedir = $(GNOMECC_GLADE_DIR) -pixmapdir = $(GNOMECC_PIXMAPS_DIR) -Glade_DATA = $(cappletname)-properties.glade -icons_DATA = $(cappletname)-capplet.png -desktop = $(cappletname).desktop -all-local: $(desktop) diff --git a/capplets/ui-properties/behavior-capplet.png b/capplets/ui-properties/behavior-capplet.png Binary files differdeleted file mode 100644 index 936b63074..000000000 --- a/capplets/ui-properties/behavior-capplet.png +++ /dev/null diff --git a/capplets/ui-properties/behavior-properties.glade b/capplets/ui-properties/behavior-properties.glade deleted file mode 100644 index ccf52ba46..000000000 --- a/capplets/ui-properties/behavior-properties.glade +++ /dev/null @@ -1,924 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>New-ui-properties</name> - <program_name>new-ui-properties</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>.</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <output_translatable_strings>True</output_translatable_strings> - <translatable_strings_file>ui-properties.glade.h</translatable_strings_file> -</project> - -<widget> - <class>GtkWindow</class> - <name>window4</name> - <title>window4</title> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>True</allow_grow> - <auto_shrink>False</auto_shrink> - - <widget> - <class>GtkVBox</class> - <name>prefs_widget</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - - <widget> - <class>GtkNotebook</class> - <name>notebook1</name> - <can_focus>True</can_focus> - <show_tabs>True</show_tabs> - <show_border>True</show_border> - <tab_pos>GTK_POS_TOP</tab_pos> - <scrollable>False</scrollable> - <tab_hborder>2</tab_hborder> - <tab_vborder>2</tab_vborder> - <popup_enable>False</popup_enable> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - - <widget> - <class>GtkTable</class> - <name>table3</name> - <border_width>4</border_width> - <rows>2</rows> - <columns>2</columns> - <homogeneous>True</homogeneous> - <row_spacing>4</row_spacing> - <column_spacing>4</column_spacing> - - <widget> - <class>GtkFrame</class> - <name>frame7</name> - <label>Menus</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkVBox</class> - <name>vbox2</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - - <widget> - <class>GtkCheckButton</class> - <name>menubar_detachable_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:48:47 GMT</last_modification_time> - </signal> - <label>Menu bars are detachable</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>menubar_relief_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:48:53 GMT</last_modification_time> - </signal> - <label>Menu bars have a border</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>menus_have_tearoff_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:49:03 GMT</last_modification_time> - </signal> - <label>Menus can be torn off</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>menus_have_icons_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:49:11 GMT</last_modification_time> - </signal> - <label>Menu items have icons</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkFrame</class> - <name>frame8</name> - <label>Status Bar</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkVBox</class> - <name>vbox3</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - - <widget> - <class>GtkCheckButton</class> - <name>statusbar_not_dialog_toggle</name> - <visible>False</visible> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 05:09:02 GMT</last_modification_time> - </signal> - <label>Use status bar instead of dialog when possible</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>statusbar_is_interactive_toggle</name> - <visible>False</visible> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:49:20 GMT</last_modification_time> - </signal> - <label>Status bar is interactive when possible</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkHSeparator</class> - <name>hseparator1</name> - <visible>False</visible> - <child> - <padding>2</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>statusbar_meter_on_left_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Fri, 08 Dec 2000 20:02:09 GMT</last_modification_time> - </signal> - <label>Progress bar is on the left</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>progressbar</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>statusbar_meter_on_right_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Fri, 08 Dec 2000 20:02:15 GMT</last_modification_time> - </signal> - <label>Progress bar is on the right</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>progressbar</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkFrame</class> - <name>frame6</name> - <label>Tool Bars</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <left_attach>0</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkTable</class> - <name>table4</name> - <border_width>4</border_width> - <rows>4</rows> - <columns>2</columns> - <homogeneous>True</homogeneous> - <row_spacing>0</row_spacing> - <column_spacing>0</column_spacing> - - <widget> - <class>GtkCheckButton</class> - <name>toolbar_relief_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:49:42 GMT</last_modification_time> - </signal> - <label>Tool bars have a border</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>toolbar_relief_btn_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:49:48 GMT</last_modification_time> - </signal> - <label>Tool bar buttons pop up on mouse over</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>toolbar_lines_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:49:53 GMT</last_modification_time> - </signal> - <label>Tool bars have line separators</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>toolbar_detachable_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:49:38 GMT</last_modification_time> - </signal> - <label>Tool bars are detachable</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>toolbar_icons_only_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Fri, 08 Dec 2000 19:27:09 GMT</last_modification_time> - </signal> - <label>Tool bar buttons are icons only</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>toolbar_icons</group> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>toolbar_text_below_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Fri, 08 Dec 2000 19:27:18 GMT</last_modification_time> - </signal> - <label>Tool bar buttons are text below icons</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>toolbar_icons</group> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label6</name> - <label>Interface</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkVBox</class> - <name>vbox8</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - - <widget> - <class>GtkFrame</class> - <name>frame9</name> - <label>Dialogs</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - - <widget> - <class>GtkVBox</class> - <name>vbox9</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - - <widget> - <class>GtkCheckButton</class> - <name>dialog_icons_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 05:08:48 GMT</last_modification_time> - </signal> - <label>Dialog buttons have icons</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>dialog_centered_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 05:09:12 GMT</last_modification_time> - </signal> - <label>Place dialogs over application window when possible</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkTable</class> - <name>table5</name> - <rows>3</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>4</row_spacing> - <column_spacing>4</column_spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label2</name> - <label>Dialogs open</label> - <justify>GTK_JUSTIFY_RIGHT</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>dialog_position_select</name> - <can_focus>True</can_focus> - <items>Wherever the Window Manager places them -At the center of the screen -At the mouse pointer -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label3</name> - <label>Dialogs are treated</label> - <justify>GTK_JUSTIFY_RIGHT</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>dialog_type_select</name> - <can_focus>True</can_focus> - <items>Like any other window -Specially by the window manager -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label1</name> - <label>Dialog Buttons</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>dialog_buttons_style_select</name> - <can_focus>True</can_focus> - <items>Default (Spread out - big) -Spread out -Spread out (big) -Left aligned -Right aligned -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GtkFrame</class> - <name>frame10</name> - <label>Multiple Documents</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - - <widget> - <class>GtkTable</class> - <name>table2</name> - <border_width>5</border_width> - <rows>2</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>5</row_spacing> - <column_spacing>5</column_spacing> - - <widget> - <class>GtkOptionMenu</class> - <name>mdi_mode_select</name> - <can_focus>True</can_focus> - <items>Notebook tabs -Seperate windows -The same window -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>mdi_tab_pos_select</name> - <can_focus>True</can_focus> - <items>Left -Right -Top -Bottom -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label8</name> - <label>When opening Multiple documents, use</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label9</name> - <label>When using Notebook tabs, place the tabs on the</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label7</name> - <label>Miscellaneous</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox2</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - - <widget> - <class>GnomePixmap</class> - <name>pixmap1</name> - <filename>gnome-warning.png</filename> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label10</name> - <label>Settings will not take effect until applications restart</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/capplets/ui-properties/behavior.desktop.in.in b/capplets/ui-properties/behavior.desktop.in.in deleted file mode 100644 index 65210271a..000000000 --- a/capplets/ui-properties/behavior.desktop.in.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=Behavior -_Comment=Sets the default behavior of GNOME applications -Exec=ui-properties -Icon=gnome-applications.png -Terminal=0 -Type=Application diff --git a/capplets/ui-properties/gnome-warning.png b/capplets/ui-properties/gnome-warning.png Binary files differdeleted file mode 100644 index 5c533b249..000000000 --- a/capplets/ui-properties/gnome-warning.png +++ /dev/null diff --git a/capplets/ui-properties/main.c b/capplets/ui-properties/main.c deleted file mode 100644 index 32e169b4f..000000000 --- a/capplets/ui-properties/main.c +++ /dev/null @@ -1,287 +0,0 @@ -/* -*- mode: c; style: linux -*- */ - -/* main.c - * Copyright (C) 2000 Helix Code, Inc. - * - * Written by Bradford Hovinen (hovinen@helixcode.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include <gtk/gtk.h> -#include <gnome.h> -#include <libgnomeui/gnome-window-icon.h> -#include <tree.h> -#include <parser.h> -#include <fcntl.h> - -#include <glade/glade.h> - -#include <capplet-widget.h> - -#ifdef HAVE_XIMIAN_ARCHIVER -# include <ximian-archiver/archive.h> -# include <ximian-archiver/location.h> -#endif /* HAVE_XIMIAN_ARCHIVER */ - -#include "preferences.h" -#include "prefs-widget.h" -#include "prefs-widget-app.h" -#include "prefs-widget-dialogs.h" -#include "prefs-widget-mdi.h" - -static Preferences *prefs; -static Preferences *old_prefs; -static PrefsWidget *prefs_widget; - -#ifdef HAVE_XIMIAN_ARCHIVER - -static Archive *archive; -static gboolean outside_location; - -static void -store_archive_data (void) -{ - Location *location; - xmlDocPtr xml_doc; - - if (capplet_get_location () == NULL) - location = archive_get_current_location (archive); - else - location = archive_get_location (archive, - capplet_get_location ()); - - xml_doc = preferences_write_xml (prefs); - location_store_xml (location, "ui-properties-capplet", - xml_doc, STORE_MASK_PREVIOUS); - xmlFreeDoc (xml_doc); - archive_close (archive); -} - -#endif /* HAVE_XIMIAN_ARCHIVER */ - -static void -ok_cb (GtkWidget *widget) -{ -#ifdef HAVE_XIMIAN_ARCHIVER - if (!outside_location) -#endif /* HAVE_XIMIAN_ARCHIVER */ - preferences_save (prefs); - -#ifdef HAVE_XIMIAN_ARCHIVER - store_archive_data (); -#endif /* HAVE_XIMIAN_ARCHIVER */ -} - -static void -cancel_cb (GtkWidget *widget) -{ -#ifdef HAVE_XIMIAN_ARCHIVER - if (!outside_location) -#endif /* HAVE_XIMIAN_ARCHIVER */ - preferences_save (old_prefs); -} - -static void -setup_capplet_widget (void) -{ - preferences_freeze (prefs); - - prefs_widget = prefs_widget_new (prefs); - - gtk_signal_connect (GTK_OBJECT (prefs_widget), "ok", - GTK_SIGNAL_FUNC (ok_cb), NULL); - gtk_signal_connect (GTK_OBJECT (prefs_widget), "cancel", - GTK_SIGNAL_FUNC (cancel_cb), NULL); - - gtk_widget_show (GTK_WIDGET (prefs_widget)); - - preferences_thaw (prefs); -} - -#ifdef HAVE_XIMIAN_ARCHIVER - -static void -do_get_xml (void) -{ - Preferences *prefs; - xmlDocPtr doc; - - prefs = PREFERENCES (preferences_new ()); - preferences_load (prefs); - doc = preferences_write_xml (prefs); - xmlDocDump (stdout, doc); - gtk_object_destroy (GTK_OBJECT (prefs)); -} - -static void -do_set_xml (gboolean apply_settings) -{ - xmlDocPtr doc; - char buffer[16384]; - GString *doc_str; - int t = 0; - - fflush (stdin); - - fcntl (fileno (stdin), F_SETFL, 0); - - doc_str = g_string_new (""); - - while ((t = read (fileno (stdin), buffer, sizeof (buffer) - 1)) != 0) { - buffer[t] = '\0'; - g_string_append (doc_str, buffer); - } - - if (doc_str->len > 0) { - doc = xmlParseDoc (doc_str->str); - g_string_free (doc_str, TRUE); - - if (doc != NULL) { - prefs = preferences_read_xml (doc); - - if (prefs && apply_settings) { - preferences_save (prefs); - return; - } - else if (prefs != NULL) { - return; - } - - xmlFreeDoc (doc); - } - } else { - g_critical ("No data to apply"); - } - - return; -} - -#endif /* HAVE_XIMIAN_ARCHIVER */ - -static void -do_restore_from_defaults (void) -{ - prefs = PREFERENCES (preferences_new ()); - preferences_save (prefs); - preferences_apply_now (prefs); -} - -int -main (int argc, char **argv) -{ - GnomeClient *client; - GnomeClientFlags flags; - gint token, res; - gchar *restart_args[3]; - - bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE); - - glade_gnome_init (); - res = gnome_capplet_init ("behavior", - VERSION, argc, argv, NULL, - 0, NULL); - - if (res < 0) { - g_error ("Could not initialize the capplet."); - } - else if (res == 3) { -#ifdef HAVE_XIMIAN_ARCHIVER - do_get_xml (); -#endif /* HAVE_XIMIAN_ARCHIVER */ - return 0; - } - else if (res == 4) { -#ifdef HAVE_XIMIAN_ARCHIVER - do_set_xml (TRUE); -#endif /* HAVE_XIMIAN_ARCHIVER */ - return 0; - } - else if (res == 5) { - do_restore_from_defaults (); - return 0; - } - - client = gnome_master_client (); - flags = gnome_client_get_flags (client); - - if (flags & GNOME_CLIENT_IS_CONNECTED) { - token = gnome_startup_acquire_token - ("GNOME_UI_PROPERTIES", - gnome_client_get_id (client)); - - if (token) { - gnome_client_set_priority (client, 20); - gnome_client_set_restart_style (client, - GNOME_RESTART_ANYWAY); - restart_args[0] = argv[0]; - restart_args[1] = "--init-session-settings"; - restart_args[2] = NULL; - gnome_client_set_restart_command (client, 2, - restart_args); - } else { - gnome_client_set_restart_style (client, - GNOME_RESTART_NEVER); - } - } else { - token = 1; - } - - gnome_window_icon_set_default_from_file (GNOMECC_ICONS_DIR"/gnome-applications.png"); - -#ifdef HAVE_XIMIAN_ARCHIVER - archive = ARCHIVE (archive_load (FALSE)); - - if (capplet_get_location () != NULL && - strcmp (capplet_get_location (), - archive_get_current_location_id (archive))) - { - outside_location = TRUE; - do_set_xml (FALSE); - if (prefs == NULL) return -1; - preferences_freeze (prefs); - } else { - outside_location = FALSE; - prefs = PREFERENCES (preferences_new ()); - preferences_load (prefs); - } - - if (!outside_location && token) { - preferences_apply_now (prefs); - } - -#else /* !HAVE_XIMIAN_ARCHIVER */ - - prefs = PREFERENCES (preferences_new ()); - preferences_load (prefs); - if (token) preferences_apply_now (prefs); - -#endif /* HAVE_XIMIAN_ARCHIVER */ - - if (!res) { - old_prefs = PREFERENCES (preferences_clone (prefs)); - setup_capplet_widget (); - - capplet_gtk_main (); - } - - return 0; -} diff --git a/capplets/ui-properties/preferences.c b/capplets/ui-properties/preferences.c deleted file mode 100644 index 32d38ea3a..000000000 --- a/capplets/ui-properties/preferences.c +++ /dev/null @@ -1,977 +0,0 @@ -/* -*- mode: c; style: linux -*- */ - -/* preferences.c - * Copyright (C) 2000 Helix Code, Inc. - * - * Written by Bradford Hovinen <hovinen@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <stdlib.h> - -#include <gnome.h> - -#include "preferences.h" - -static GtkObjectClass *parent_class; - -static void preferences_init (Preferences *prefs); -static void preferences_class_init (PreferencesClass *class); - -static gint xml_read_int (xmlNodePtr node); -static xmlNodePtr xml_write_int (gchar *name, - gint number); -static gboolean xml_read_bool (xmlNodePtr node); -static xmlNodePtr xml_write_bool (gchar *name, - gboolean value); - -static gint apply_timeout_cb (Preferences *prefs); - -guint -preferences_get_type (void) -{ - static guint preferences_type = 0; - - if (!preferences_type) { - GtkTypeInfo preferences_info = { - "Preferences", - sizeof (Preferences), - sizeof (PreferencesClass), - (GtkClassInitFunc) preferences_class_init, - (GtkObjectInitFunc) preferences_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - preferences_type = - gtk_type_unique (gtk_object_get_type (), - &preferences_info); - } - - return preferences_type; -} - -static void -preferences_init (Preferences *prefs) -{ - prefs->frozen = FALSE; - prefs->gnome_prefs = g_new0 (GnomePreferences, 1); - - /* FIXME: Code to set default values */ -} - -static void -preferences_class_init (PreferencesClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - object_class->destroy = preferences_destroy; - - parent_class = - GTK_OBJECT_CLASS (gtk_type_class (gtk_object_get_type ())); -} - -GtkObject * -preferences_new (void) -{ - GtkObject *object; - - object = gtk_type_new (preferences_get_type ()); - - return object; -} - -GtkObject * -preferences_clone (Preferences *prefs) -{ - GtkObject *object; - Preferences *new_prefs; - - g_return_val_if_fail (prefs != NULL, NULL); - g_return_val_if_fail (IS_PREFERENCES (prefs), NULL); - g_return_val_if_fail (prefs->gnome_prefs != NULL, NULL); - - object = preferences_new (); - - new_prefs = PREFERENCES (object); - memcpy (new_prefs->gnome_prefs, prefs->gnome_prefs, - sizeof (GnomePreferences)); - new_prefs->dialog_use_icons = prefs->dialog_use_icons; - - return object; -} - -void -preferences_destroy (GtkObject *object) -{ - Preferences *prefs; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_PREFERENCES (object)); - - prefs = PREFERENCES (object); - - if (prefs->gnome_prefs) g_free (prefs->gnome_prefs); - - parent_class->destroy (object); -} - -void -preferences_load (Preferences *prefs) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - gnome_preferences_load_custom (prefs->gnome_prefs); - - prefs->dialog_use_icons = - gnome_config_get_bool ("/Gnome/Icons/ButtonUseIcons=true"); -} - -void -preferences_save (Preferences *prefs) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - gnome_preferences_save_custom (prefs->gnome_prefs); - - gnome_config_set_bool ("/Gnome/Icons/ButtonUseIcons", - prefs->dialog_use_icons); - gnome_config_sync (); -} - -void -preferences_changed (Preferences *prefs) -{ - if (prefs->frozen) return; - - if (prefs->timeout_id) - gtk_timeout_remove (prefs->timeout_id); -} - -void -preferences_apply_now (Preferences *prefs) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - - if (prefs->timeout_id) - gtk_timeout_remove (prefs->timeout_id); - - prefs->timeout_id = 0; - - preferences_save (prefs); -} - -void -preferences_freeze (Preferences *prefs) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - - prefs->frozen++; -} - -void -preferences_thaw (Preferences *prefs) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - - if (prefs->frozen > 0) prefs->frozen--; -} - -Preferences * -preferences_read_xml (xmlDocPtr xml_doc) -{ - Preferences *prefs; - xmlNodePtr root_node, node; - - prefs = PREFERENCES (preferences_new ()); - - root_node = xmlDocGetRootElement (xml_doc); - - if (strcmp (root_node->name, "ui-properties")) - return NULL; - - for (node = root_node->childs; node; node = node->next) { - if (!strcmp (node->name, "dialog-buttons-style")) - prefs->gnome_prefs->dialog_buttons_style = - xml_read_int (node); - else if (!strcmp (node->name, "property-box-buttons-ok")) - prefs->gnome_prefs->property_box_buttons_ok = - xml_read_bool (node); - else if (!strcmp (node->name, "property-box-buttons-apply")) - prefs->gnome_prefs->property_box_buttons_apply = - xml_read_bool (node); - else if (!strcmp (node->name, "property-box-buttons-close")) - prefs->gnome_prefs->property_box_buttons_close = - xml_read_bool (node); - else if (!strcmp (node->name, "property-box-buttons-help")) - prefs->gnome_prefs->property_box_buttons_help = - xml_read_bool (node); - else if (!strcmp (node->name, "statusbar-not-dialog")) - prefs->gnome_prefs->statusbar_not_dialog = - xml_read_bool (node); - else if (!strcmp (node->name, "statusbar-is-interactive")) - prefs->gnome_prefs->statusbar_is_interactive = - xml_read_bool (node); - else if (!strcmp (node->name, "statusbar-meter-on-right")) - prefs->gnome_prefs->statusbar_meter_on_right = - xml_read_bool (node); - else if (!strcmp (node->name, "menubar-detachable")) - prefs->gnome_prefs->menubar_detachable = - xml_read_bool (node); - else if (!strcmp (node->name, "menubar-relief")) - prefs->gnome_prefs->menubar_relief = - xml_read_bool (node); - else if (!strcmp (node->name, "toolbar-detachable")) - prefs->gnome_prefs->toolbar_detachable = - xml_read_bool (node); - else if (!strcmp (node->name, "toolbar-relief")) - prefs->gnome_prefs->toolbar_relief = - xml_read_bool (node); - else if (!strcmp (node->name, "toolbar-relief-btn")) - prefs->gnome_prefs->toolbar_relief_btn = - xml_read_bool (node); - else if (!strcmp (node->name, "toolbar-lines")) - prefs->gnome_prefs->toolbar_lines = - xml_read_bool (node); - else if (!strcmp (node->name, "toolbar-labels")) - prefs->gnome_prefs->toolbar_labels = - xml_read_bool (node); - else if (!strcmp (node->name, "dialog-centered")) - prefs->gnome_prefs->dialog_centered = - xml_read_bool (node); - else if (!strcmp (node->name, "menus-have-tearoff")) - prefs->gnome_prefs->menus_have_tearoff = - xml_read_bool (node); - else if (!strcmp (node->name, "menus-have-icons")) - prefs->gnome_prefs->menus_have_icons = - xml_read_bool (node); - else if (!strcmp (node->name, "disable-imlib-cache")) - prefs->gnome_prefs->disable_imlib_cache = - xml_read_bool (node); - else if (!strcmp (node->name, "dialog-type")) - prefs->gnome_prefs->dialog_type = xml_read_int (node); - else if (!strcmp (node->name, "dialog-position")) - prefs->gnome_prefs->dialog_position = - xml_read_int (node); - else if (!strcmp (node->name, "mdi-mode")) - prefs->gnome_prefs->mdi_mode = xml_read_int (node); - else if (!strcmp (node->name, "mdi-tab-pos")) - prefs->gnome_prefs->mdi_tab_pos = xml_read_int (node); - else if (!strcmp (node->name, "dialog-use-icons")) - prefs->dialog_use_icons = xml_read_bool (node); - } - - return prefs; -} - -xmlDocPtr -preferences_write_xml (Preferences *prefs) -{ - xmlDocPtr doc; - xmlNodePtr node; - - doc = xmlNewDoc ("1.0"); - - node = xmlNewDocNode (doc, NULL, "ui-properties", NULL); - - xmlAddChild (node, - xml_write_int ("dialog-buttons-style", - prefs->gnome_prefs->dialog_buttons_style)); - - xmlAddChild (node, - xml_write_bool ("property-box-buttons-ok", - prefs->gnome_prefs->property_box_buttons_ok)); - xmlAddChild (node, - xml_write_bool ("property-box-buttons-apply", - prefs->gnome_prefs->property_box_buttons_apply)); - xmlAddChild (node, - xml_write_bool ("property-box-buttons-close", - prefs->gnome_prefs->property_box_buttons_close)); - xmlAddChild (node, - xml_write_bool ("property-box-buttons-help", - prefs->gnome_prefs->property_box_buttons_help)); - xmlAddChild (node, - xml_write_bool ("statusbar-not-dialog", - prefs->gnome_prefs->statusbar_not_dialog)); - xmlAddChild (node, - xml_write_bool ("statusbar-is-interactive", - prefs->gnome_prefs->statusbar_is_interactive)); - xmlAddChild (node, - xml_write_bool ("statusbar-meter-on-right", - prefs->gnome_prefs->statusbar_meter_on_right)); - xmlAddChild (node, - xml_write_bool ("menubar-detachable", - prefs->gnome_prefs->menubar_detachable)); - xmlAddChild (node, - xml_write_bool ("menubar-relief", - prefs->gnome_prefs->menubar_relief)); - xmlAddChild (node, - xml_write_bool ("toolbar-detachable", - prefs->gnome_prefs->toolbar_detachable)); - xmlAddChild (node, - xml_write_bool ("toolbar-relief", - prefs->gnome_prefs->toolbar_relief)); - xmlAddChild (node, - xml_write_bool ("toolbar-relief-btn", - prefs->gnome_prefs->toolbar_relief_btn)); - xmlAddChild (node, - xml_write_bool ("toolbar-lines", - prefs->gnome_prefs->toolbar_lines)); - xmlAddChild (node, - xml_write_bool ("toolbar-labels", - prefs->gnome_prefs->toolbar_labels)); - xmlAddChild (node, - xml_write_bool ("dialog-centered", - prefs->gnome_prefs->dialog_centered)); - xmlAddChild (node, - xml_write_bool ("menus-have-tearoff", - prefs->gnome_prefs->menus_have_tearoff)); - xmlAddChild (node, - xml_write_bool ("menus-have-icons", - prefs->gnome_prefs->menus_have_icons)); - xmlAddChild (node, - xml_write_bool ("disable-imlib-cache", - prefs->gnome_prefs->disable_imlib_cache)); - - xmlAddChild (node, - xml_write_int ("dialog-type", - prefs->gnome_prefs->dialog_type)); - xmlAddChild (node, - xml_write_int ("dialog-position", - prefs->gnome_prefs->dialog_position)); - xmlAddChild (node, - xml_write_int ("mdi-mode", - prefs->gnome_prefs->mdi_mode)); - xmlAddChild (node, - xml_write_int ("mdi-tab-pos", - prefs->gnome_prefs->mdi_tab_pos)); - - xmlAddChild (node, - xml_write_bool ("dialog-use-icons", - prefs->dialog_use_icons)); - - xmlDocSetRootElement (doc, node); - - return doc; -} - -/* Read a numeric value from a node */ - -static gint -xml_read_int (xmlNodePtr node) -{ - char *text; - - text = xmlNodeGetContent (node); - - if (text == NULL) - return 0; - else - return atoi (text); -} - -/* Write out a numeric value in a node */ - -static xmlNodePtr -xml_write_int (gchar *name, gint number) -{ - xmlNodePtr node; - gchar *str; - - g_return_val_if_fail (name != NULL, NULL); - - str = g_strdup_printf ("%d", number); - node = xmlNewNode (NULL, name); - xmlNodeSetContent (node, str); - g_free (str); - - return node; -} - -/* Read a boolean value from a node */ - -static gboolean -xml_read_bool (xmlNodePtr node) -{ - char *text; - - text = xmlNodeGetContent (node); - - if (!g_strcasecmp (text, "true")) - return TRUE; - else - return FALSE; -} - -/* Write out a boolean value in a node */ - -static xmlNodePtr -xml_write_bool (gchar *name, gboolean value) -{ - xmlNodePtr node; - - g_return_val_if_fail (name != NULL, NULL); - - node = xmlNewNode (NULL, name); - - if (value) - xmlNodeSetContent (node, "true"); - else - xmlNodeSetContent (node, "false"); - - return node; -} - -static gint -apply_timeout_cb (Preferences *prefs) -{ - preferences_apply_now (prefs); - - return TRUE; -} - -GtkButtonBoxStyle -preferences_get_dialog_buttons_style (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->dialog_buttons_style; -} - -int -preferences_get_property_box_buttons_ok (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->property_box_buttons_ok; -} - -int -preferences_get_property_box_buttons_apply (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->property_box_buttons_apply; -} - -int -preferences_get_property_box_buttons_close (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->property_box_buttons_close; -} - -int -preferences_get_property_box_buttons_help (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->property_box_buttons_help; -} - -int -preferences_get_statusbar_not_dialog (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->statusbar_not_dialog; -} - -int -preferences_get_statusbar_is_interactive (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->statusbar_is_interactive; -} - -int -preferences_get_statusbar_meter_on_right (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->statusbar_meter_on_right; -} - -int -preferences_get_statusbar_meter_on_left (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return !prefs->gnome_prefs->statusbar_meter_on_right; -} - -int -preferences_get_menubar_detachable (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->menubar_detachable; -} - -int -preferences_get_menubar_relief (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->menubar_relief; -} - -int -preferences_get_toolbar_detachable (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->toolbar_detachable; -} - -int -preferences_get_toolbar_relief (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->toolbar_relief; -} - -int -preferences_get_toolbar_relief_btn (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->toolbar_relief_btn; -} - -int -preferences_get_toolbar_lines (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->toolbar_lines; -} - -int -preferences_get_toolbar_icons_only (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return !prefs->gnome_prefs->toolbar_labels; -} - -int -preferences_get_toolbar_text_below (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->toolbar_labels; -} - -int -preferences_get_dialog_centered (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->dialog_centered; -} - -int -preferences_get_menus_have_tearoff (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->menus_have_tearoff; -} - -int -preferences_get_menus_have_icons (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->menus_have_icons; -} - -int -preferences_get_disable_imlib_cache (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->disable_imlib_cache; -} - -GtkWindowType -preferences_get_dialog_type (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->dialog_type; -} - -GtkWindowPosition -preferences_get_dialog_position (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->dialog_position; -} - -GnomeMDIMode -preferences_get_mdi_mode (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->mdi_mode; -} - -GtkPositionType -preferences_get_mdi_tab_pos (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->gnome_prefs->mdi_tab_pos; -} - -int -preferences_get_dialog_icons (Preferences *prefs) -{ - g_return_val_if_fail (prefs != NULL, 0); - g_return_val_if_fail (IS_PREFERENCES (prefs), 0); - g_return_val_if_fail (prefs->gnome_prefs != NULL, 0); - - return prefs->dialog_use_icons; -} - -void -preferences_set_dialog_buttons_style (Preferences *prefs, int style) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->dialog_buttons_style = style; -} - -void -preferences_set_property_box_buttons_ok (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->property_box_buttons_ok = s; -} - -void -set_property_set_property_box_buttons_apply (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->property_box_buttons_apply = s; -} - -void -preferences_set_property_box_buttons_close (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->property_box_buttons_close = s; -} - -void -preferences_set_property_box_buttons_help (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->property_box_buttons_help = s; -} - -void -preferences_set_statusbar_not_dialog (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->statusbar_not_dialog = s; -} - -void -preferences_set_statusbar_is_interactive (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->statusbar_is_interactive = s; -} - -void -preferences_set_statusbar_meter_on_right (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->statusbar_meter_on_right = s; -} - -void -preferences_set_statusbar_meter_on_left (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->statusbar_meter_on_right = !s; -} - -void -preferences_set_menubar_detachable (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->menubar_detachable = s; -} - -void -preferences_set_menubar_relief (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->menubar_relief = s; -} - -void -preferences_set_toolbar_detachable (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->toolbar_detachable = s; -} - -void -preferences_set_toolbar_relief (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->toolbar_relief = s; -} - -void -preferences_set_toolbar_relief_btn (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->toolbar_relief_btn = s; -} - -void -preferences_set_toolbar_lines (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->toolbar_lines = s; -} - -void -preferences_set_toolbar_icons_only (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->toolbar_labels = !s; -} - -void -preferences_set_toolbar_text_below (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->toolbar_labels = s; -} - -void -preferences_set_dialog_centered (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->dialog_centered = s; -} - -void -preferences_set_menus_have_tearoff (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->menus_have_tearoff = s; -} - -void -preferences_set_menus_have_icons (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->menus_have_icons = s; -} - -void -preferences_set_disable_imlib_cache (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->disable_imlib_cache = s; -} - -void -preferences_set_dialog_type (Preferences *prefs, int type) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->dialog_type = type; -} - -void -preferences_set_dialog_position (Preferences *prefs, int pos) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->dialog_position = pos; -} - -void -preferences_set_mdi_mode (Preferences *prefs, int mode) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->mdi_mode = mode; -} - -void -preferences_set_mdi_tab_pos (Preferences *prefs, int type) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->gnome_prefs->mdi_tab_pos = type; -} - -void -preferences_set_dialog_icons (Preferences *prefs, int s) -{ - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - g_return_if_fail (prefs->gnome_prefs != NULL); - - prefs->dialog_use_icons = s; -} diff --git a/capplets/ui-properties/preferences.h b/capplets/ui-properties/preferences.h deleted file mode 100644 index 721665dcb..000000000 --- a/capplets/ui-properties/preferences.h +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- mode: c; style: linux -*- */ - -/* preferences.h - * Copyright (C) 2000 Helix Code, Inc. - * - * Written by Bradford Hovinen <hovinen@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef __PREFERENCES_H -#define __PREFERENCES_H - -#include <gtk/gtk.h> -#include <gnome.h> - -#include <tree.h> - -#define PREFERENCES(obj) GTK_CHECK_CAST (obj, preferences_get_type (), Preferences) -#define PREFERENCES_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, preferences_get_type (), PreferencesClass) -#define IS_PREFERENCES(obj) GTK_CHECK_TYPE (obj, preferences_get_type ()) - -typedef struct _Preferences Preferences; -typedef struct _PreferencesClass PreferencesClass; - -struct _Preferences -{ - GtkObject object; - - gint frozen; - guint timeout_id; - - GnomePreferences *gnome_prefs; - - gboolean dialog_use_icons; -}; - -struct _PreferencesClass -{ - GtkObjectClass klass; -}; - -guint preferences_get_type (void); - -GtkObject *preferences_new (void); -GtkObject *preferences_clone (Preferences *prefs); -void preferences_destroy (GtkObject *object); - -void preferences_load (Preferences *prefs); -void preferences_save (Preferences *prefs); -void preferences_changed (Preferences *prefs); -void preferences_apply_now (Preferences *prefs); - -void preferences_freeze (Preferences *prefs); -void preferences_thaw (Preferences *prefs); - -Preferences *preferences_read_xml (xmlDocPtr xml_doc); -xmlDocPtr preferences_write_xml (Preferences *prefs); - -/* get/set functions. It's really stupid that we need these */ - -int preferences_get_menubar_detachable (Preferences *prefs); -int preferences_get_menubar_relief (Preferences *prefs); -int preferences_get_menus_have_tearoff (Preferences *prefs); -int preferences_get_menus_have_icons (Preferences *prefs); - -int preferences_get_statusbar_not_dialog (Preferences *prefs); -int preferences_get_statusbar_is_interactive (Preferences *prefs); -int preferences_get_statusbar_meter_on_left (Preferences *prefs); -int preferences_get_statusbar_meter_on_right (Preferences *prefs); - -int preferences_get_toolbar_detachable (Preferences *prefs); -int preferences_get_toolbar_relief (Preferences *prefs); -int preferences_get_toolbar_relief_btn (Preferences *prefs); -int preferences_get_toolbar_lines (Preferences *prefs); -int preferences_get_toolbar_icons_only (Preferences *prefs); -int preferences_get_toolbar_text_below (Preferences *prefs); - -int preferences_get_dialog_icons (Preferences *prefs); -int preferences_get_dialog_centered (Preferences *prefs); - -GtkWindowPosition preferences_get_dialog_position (Preferences *prefs); -GtkWindowType preferences_get_dialog_type (Preferences *prefs); -GtkButtonBoxStyle preferences_get_dialog_buttons_style (Preferences *prefs); - -GnomeMDIMode preferences_get_mdi_mode (Preferences *prefs); -GtkPositionType preferences_get_mdi_tab_pos (Preferences *prefs); - -#if 0 -int preferences_get_property_box_buttons_ok (Preferences *prefs); -int preferences_get_property_box_buttons_apply (Preferences *prefs); -int preferences_get_property_box_buttons_close (Preferences *prefs); -int preferences_get_property_box_buttons_help (Preferences *prefs); -int preferences_get_disable_imlib_cache (Preferences *prefs); -#endif - - - - - - -void preferences_set_menubar_detachable (Preferences *prefs, int i); -void preferences_set_menubar_relief (Preferences *prefs, int i); -void preferences_set_menus_have_tearoff (Preferences *prefs, int i); -void preferences_set_menus_have_icons (Preferences *prefs, int i); - -void preferences_set_statusbar_not_dialog (Preferences *prefs, int i); -void preferences_set_statusbar_is_interactive (Preferences *prefs, int i); -void preferences_set_statusbar_meter_on_left (Preferences *prefs, int i); -void preferences_set_statusbar_meter_on_right (Preferences *prefs, int i); - -void preferences_set_toolbar_detachable (Preferences *prefs, int i); -void preferences_set_toolbar_relief (Preferences *prefs, int i); -void preferences_set_toolbar_relief_btn (Preferences *prefs, int i); -void preferences_set_toolbar_lines (Preferences *prefs, int i); -void preferences_set_toolbar_icons_only (Preferences *prefs, int i); -void preferences_set_toolbar_text_below (Preferences *prefs, int i); - -void preferences_set_dialog_icons (Preferences *prefs, int i); -void preferences_set_dialog_centered (Preferences *prefs, int i); - -void preferences_set_dialog_position (Preferences *prefs, int i); -void preferences_set_dialog_type (Preferences *prefs, int i); -void preferences_set_dialog_buttons_style (Preferences *prefs, int i); - -void preferences_set_mdi_mode (Preferences *prefs, int i); -void preferences_set_mdi_tab_pos (Preferences *prefs, int i); - -#if 0 -void preferences_set_property_box_buttons_ok (Preferences *prefs, int i); -void preferences_set_property_box_buttons_apply (Preferences *prefs, int i); -void preferences_set_property_box_buttons_close (Preferences *prefs, int i); -void preferences_set_property_box_buttons_help (Preferences *prefs, int i); -void preferences_set_disable_imlib_cache (Preferences *prefs, int i); -#endif - -#endif /* __PREFERENCES_H */ diff --git a/capplets/ui-properties/prefs-widget-app.c b/capplets/ui-properties/prefs-widget-app.c deleted file mode 100644 index 77fa190d9..000000000 --- a/capplets/ui-properties/prefs-widget-app.c +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- mode: c; style: linux -*- */ - -/* prefs-widget-app.c - * Copyright (C) 2000 Helix Code, Inc. - * - * Written by Bradford Hovinen <hovinen@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "prefs-widget-app.h" - -#define WID(str) (glade_xml_get_widget (prefs_widget->dialog_data, str)) - -static PrefsWidgetClass *parent_class; - -static widget_desc_t widget_desc[] = { - WD_CHECK (menubar_detachable, "menubar_detachable"), - WD_CHECK (menubar_relief, "menubar_relief"), - WD_CHECK (menus_have_tearoff, "menus_have_tearoff"), - WD_CHECK (menus_have_icons, "menus_have_icons"), - WD_CHECK (statusbar_is_interactive, "statusbar_is_interactive"), - WD_CHECK (statusbar_meter_on_right, "statusbar_meter_on_right"), - WD_CHECK (toolbar_detachable, "toolbar_detachable"), - WD_CHECK (toolbar_relief, "toolbar_relief"), - WD_CHECK (toolbar_relief_btn, "toolbar_relief_btn"), - WD_CHECK (toolbar_lines, "toolbar_lines"), -/* WD_CHECK (toolbar_labels, "toolbar_labels"), */ - WD_END -}; - -static void prefs_widget_app_init (PrefsWidgetApp *prefs_widget_app); -static void prefs_widget_app_class_init (PrefsWidgetAppClass *class); - -guint -prefs_widget_app_get_type (void) -{ - static guint prefs_widget_app_type = 0; - - if (!prefs_widget_app_type) { - GtkTypeInfo prefs_widget_app_info = { - "PrefsWidgetApp", - sizeof (PrefsWidgetApp), - sizeof (PrefsWidgetAppClass), - (GtkClassInitFunc) prefs_widget_app_class_init, - (GtkObjectInitFunc) prefs_widget_app_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - prefs_widget_app_type = - gtk_type_unique (prefs_widget_get_type (), - &prefs_widget_app_info); - } - - return prefs_widget_app_type; -} - -static void -prefs_widget_app_init (PrefsWidgetApp *prefs_widget_app) -{ -} - -static void -prefs_widget_app_class_init (PrefsWidgetAppClass *class) -{ - PrefsWidgetClass *prefs_widget_class; - - prefs_widget_class = PREFS_WIDGET_CLASS (class); - prefs_widget_class->widget_desc = widget_desc; - - parent_class = PREFS_WIDGET_CLASS - (gtk_type_class (prefs_widget_get_type ())); -} - -GtkWidget * -prefs_widget_app_new (Preferences *prefs) -{ - GtkWidget *widget, *dlg_widget; - GladeXML *dialog_data; - - g_return_val_if_fail (prefs == NULL || IS_PREFERENCES (prefs), NULL); - - dialog_data = glade_xml_new (GNOMECC_GLADE_DIR "/behavior-properties.glade", - "prefs_widget_app"); - - widget = gtk_widget_new (prefs_widget_app_get_type (), - "dialog_data", dialog_data, - "preferences", prefs, - NULL); - - dlg_widget = glade_xml_get_widget (dialog_data, "prefs_widget_app"); - gtk_container_add (GTK_CONTAINER (widget), dlg_widget); - - return widget; -} diff --git a/capplets/ui-properties/prefs-widget-app.h b/capplets/ui-properties/prefs-widget-app.h deleted file mode 100644 index 4a71318c1..000000000 --- a/capplets/ui-properties/prefs-widget-app.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- mode: c; style: linux -*- */ - -/* prefs-widget-app.h - * Copyright (C) 2000 Helix Code, Inc. - * - * Written by Bradford Hovinen <hovinen@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef __PREFS_WIDGET_APP_H -#define __PREFS_WIDGET_APP_H - -#include <gtk/gtk.h> -#include <glade/glade.h> - -#include "preferences.h" -#include "prefs-widget.h" - -#define PREFS_WIDGET_APP(obj) GTK_CHECK_CAST (obj, prefs_widget_app_get_type (), PrefsWidgetApp) -#define PREFS_WIDGET_APP_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, prefs_widget_app_get_type (), PrefsWidgetAppClass) -#define IS_PREFS_WIDGET_APP(obj) GTK_CHECK_TYPE (obj, prefs_widget_app_get_type ()) - -typedef struct _PrefsWidgetApp PrefsWidgetApp; -typedef struct _PrefsWidgetAppClass PrefsWidgetAppClass; - -struct _PrefsWidgetApp -{ - PrefsWidget prefs_widget; -}; - -struct _PrefsWidgetAppClass -{ - PrefsWidgetClass parent_class; -}; - -guint prefs_widget_app_get_type (void); - -GtkWidget *prefs_widget_app_new (Preferences *prefs); - -#endif /* __PREFS_WIDGET_APP_H */ diff --git a/capplets/ui-properties/prefs-widget-dialogs.c b/capplets/ui-properties/prefs-widget-dialogs.c deleted file mode 100644 index dca4cc867..000000000 --- a/capplets/ui-properties/prefs-widget-dialogs.c +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- mode: c; style: linux -*- */ - -/* prefs-widget-dialogs.c - * Copyright (C) 2000 Helix Code, Inc. - * - * Written by Bradford Hovinen <hovinen@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "prefs-widget-dialogs.h" - -#define WID(str) (glade_xml_get_widget (prefs_widget->dialog_data, str)) - -static PrefsWidgetClass *parent_class; - -static widget_desc_t widget_desc[] = { - WD_OPTION (dialog_buttons_style, "dialog_buttons_style"), - WD_CHECK (statusbar_not_dialog, "statusbar_not_dialog"), - WD_OPTION (dialog_position, "dialog_position"), - WD_OPTION (dialog_type, "dialog_type"), - WD_CHECK (dialog_centered, "dialog_centered"), - WD_CHECK (dialog_icons, "dialog_icons"), - WD_END -}; - -static void prefs_widget_dialogs_init (PrefsWidgetDialogs *prefs_widget_dlgs); -static void prefs_widget_dialogs_class_init (PrefsWidgetDialogsClass *class); - -guint -prefs_widget_dialogs_get_type (void) -{ - static guint prefs_widget_dialogs_type = 0; - - if (!prefs_widget_dialogs_type) { - GtkTypeInfo prefs_widget_dialogs_info = { - "PrefsWidgetDialogs", - sizeof (PrefsWidgetDialogs), - sizeof (PrefsWidgetDialogsClass), - (GtkClassInitFunc) prefs_widget_dialogs_class_init, - (GtkObjectInitFunc) prefs_widget_dialogs_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - prefs_widget_dialogs_type = - gtk_type_unique (prefs_widget_get_type (), - &prefs_widget_dialogs_info); - } - - return prefs_widget_dialogs_type; -} - -static void -prefs_widget_dialogs_init (PrefsWidgetDialogs *prefs_widget_dialogs) -{ -} - -static void -prefs_widget_dialogs_class_init (PrefsWidgetDialogsClass *class) -{ - PrefsWidgetClass *prefs_widget_class; - - prefs_widget_class = PREFS_WIDGET_CLASS (class); - prefs_widget_class->widget_desc = widget_desc; - - parent_class = PREFS_WIDGET_CLASS - (gtk_type_class (prefs_widget_get_type ())); -} - -GtkWidget * -prefs_widget_dialogs_new (Preferences *prefs) -{ - GtkWidget *widget, *dlg_widget; - GladeXML *dialog_data; - - g_return_val_if_fail (prefs == NULL || IS_PREFERENCES (prefs), NULL); - - dialog_data = - glade_xml_new (GNOMECC_GLADE_DIR "/behavior-properties.glade", - "prefs_widget_dialogs"); - - widget = gtk_widget_new (prefs_widget_dialogs_get_type (), - "dialog_data", dialog_data, - "preferences", prefs, - NULL); - - dlg_widget = glade_xml_get_widget (dialog_data, - "prefs_widget_dialogs"); - gtk_container_add (GTK_CONTAINER (widget), dlg_widget); - - return widget; -} diff --git a/capplets/ui-properties/prefs-widget-dialogs.h b/capplets/ui-properties/prefs-widget-dialogs.h deleted file mode 100644 index e7e2d587d..000000000 --- a/capplets/ui-properties/prefs-widget-dialogs.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- mode: c; style: linux -*- */ - -/* prefs-widget-dialogs.h - * Copyright (C) 2000 Helix Code, Inc. - * - * Written by Bradford Hovinen <hovinen@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef __PREFS_WIDGET_DIALOGS_H -#define __PREFS_WIDGET_DIALOGS_H - -#include <gtk/gtk.h> -#include <glade/glade.h> - -#include "preferences.h" -#include "prefs-widget.h" - -#define PREFS_WIDGET_DIALOGS(obj) GTK_CHECK_CAST (obj, prefs_widget_dialogs_get_type (), PrefsWidget) -#define PREFS_WIDGET_DIALOGS_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, prefs_widget_dialogs_get_type (), PrefsWidgetClass) -#define IS_PREFS_WIDGET_DIALOGS(obj) GTK_CHECK_TYPE (obj, prefs_widget_dialogs_get_type ()) - -typedef struct _PrefsWidgetDialogs PrefsWidgetDialogs; -typedef struct _PrefsWidgetDialogsClass PrefsWidgetDialogsClass; - -struct _PrefsWidgetDialogs -{ - PrefsWidget prefs_widget; -}; - -struct _PrefsWidgetDialogsClass -{ - PrefsWidgetClass parent_class; -}; - -guint prefs_widget_dialogs_get_type (void); - -GtkWidget *prefs_widget_dialogs_new (Preferences *prefs); - -#endif /* __PREFS_WIDGET_DIALOGS_H */ diff --git a/capplets/ui-properties/prefs-widget-mdi.c b/capplets/ui-properties/prefs-widget-mdi.c deleted file mode 100644 index ce78cb710..000000000 --- a/capplets/ui-properties/prefs-widget-mdi.c +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- mode: c; style: linux -*- */ - -/* prefs-widget-mdi.c - * Copyright (C) 2000 Helix Code, Inc. - * - * Written by Bradford Hovinen <hovinen@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "prefs-widget-mdi.h" - -#define WID(str) (glade_xml_get_widget (prefs_widget->dialog_data, str)) - -static PrefsWidgetClass *parent_class; - -static widget_desc_t widget_desc[] = { - WD_OPTION (mdi_mode, "mdi_mode"), - WD_OPTION (mdi_tab_pos, "mdi_tab_pos"), - WD_END -}; - -static void prefs_widget_mdi_init (PrefsWidgetMDI *prefs_widget_mdi); -static void prefs_widget_mdi_class_init (PrefsWidgetMDIClass *class); - -guint -prefs_widget_mdi_get_type (void) -{ - static guint prefs_widget_mdi_type = 0; - - if (!prefs_widget_mdi_type) { - GtkTypeInfo prefs_widget_mdi_info = { - "PrefsWidgetMDI", - sizeof (PrefsWidgetMDI), - sizeof (PrefsWidgetMDIClass), - (GtkClassInitFunc) prefs_widget_mdi_class_init, - (GtkObjectInitFunc) prefs_widget_mdi_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - prefs_widget_mdi_type = - gtk_type_unique (prefs_widget_get_type (), - &prefs_widget_mdi_info); - } - - return prefs_widget_mdi_type; -} - -static void -prefs_widget_mdi_init (PrefsWidgetMDI *prefs_widget_mdi) -{ -} - -static void -prefs_widget_mdi_class_init (PrefsWidgetMDIClass *class) -{ - PrefsWidgetClass *prefs_widget_class; - - prefs_widget_class = PREFS_WIDGET_CLASS (class); - prefs_widget_class->widget_desc = widget_desc; - - parent_class = PREFS_WIDGET_CLASS - (gtk_type_class (prefs_widget_get_type ())); -} - -GtkWidget * -prefs_widget_mdi_new (Preferences *prefs) -{ - GtkWidget *widget, *dlg_widget; - GladeXML *dialog_data; - - g_return_val_if_fail (prefs == NULL || IS_PREFERENCES (prefs), NULL); - - dialog_data = - glade_xml_new (GNOMECC_GLADE_DIR "/behavior-properties.glade", - "prefs_widget_mdi"); - - widget = gtk_widget_new (prefs_widget_mdi_get_type (), - "dialog_data", dialog_data, - "preferences", prefs, - NULL); - - dlg_widget = glade_xml_get_widget (dialog_data, "prefs_widget_mdi"); - gtk_container_add (GTK_CONTAINER (widget), dlg_widget); - - return widget; -} diff --git a/capplets/ui-properties/prefs-widget-mdi.h b/capplets/ui-properties/prefs-widget-mdi.h deleted file mode 100644 index 84063c2cf..000000000 --- a/capplets/ui-properties/prefs-widget-mdi.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- mode: c; style: linux -*- */ - -/* prefs-widget-mdi.h - * Copyright (C) 2000 Helix Code, Inc. - * - * Written by Bradford Hovinen <hovinen@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef __PREFS_WIDGET_MDI_H -#define __PREFS_WIDGET_MDI_H - -#include <gtk/gtk.h> -#include <glade/glade.h> - -#include "preferences.h" -#include "prefs-widget.h" - -#define PREFS_WIDGET_MDI(obj) GTK_CHECK_CAST (obj, prefs_widget_mdi_get_type (), PrefsWidgetMDI) -#define PREFS_WIDGET_MDI_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, prefs_widget_mdi_get_type (), PrefsWidgetMDIClass) -#define IS_PREFS_WIDGET_MDI(obj) GTK_CHECK_TYPE (obj, prefs_widget_mdi_get_type ()) - -typedef struct _PrefsWidgetMDI PrefsWidgetMDI; -typedef struct _PrefsWidgetMDIClass PrefsWidgetMDIClass; - -struct _PrefsWidgetMDI -{ - PrefsWidget prefs_widget; -}; - -struct _PrefsWidgetMDIClass -{ - PrefsWidgetClass parent_class; -}; - -guint prefs_widget_mdi_get_type (void); - -GtkWidget *prefs_widget_mdi_new (Preferences *prefs); - -#endif /* __PREFS_WIDGET_MDI_H */ diff --git a/capplets/ui-properties/prefs-widget.c b/capplets/ui-properties/prefs-widget.c deleted file mode 100644 index 6c314ada3..000000000 --- a/capplets/ui-properties/prefs-widget.c +++ /dev/null @@ -1,460 +0,0 @@ -/* -*- mode: c; style: linux -*- */ - -/* prefs-widget.c - * Copyright (C) 2000 Helix Code, Inc. - * - * Written by Bradford Hovinen <hovinen@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <glade/glade.h> - -#include "prefs-widget.h" - -#define WID(str) (glade_xml_get_widget (prefs_widget->dialog_data, str)) - -static widget_desc_t widget_desc[] = { - WD_CHECK (menubar_detachable, "menubar_detachable"), - WD_CHECK (menubar_relief, "menubar_relief"), - WD_CHECK (menus_have_tearoff, "menus_have_tearoff"), - WD_CHECK (menus_have_icons, "menus_have_icons"), - - WD_CHECK (statusbar_not_dialog, "statusbar_not_dialog"), - WD_CHECK (statusbar_is_interactive, "statusbar_is_interactive"), - WD_CHECK (statusbar_meter_on_left , "statusbar_meter_on_left"), - WD_CHECK (statusbar_meter_on_right, "statusbar_meter_on_right"), - - WD_CHECK (toolbar_detachable, "toolbar_detachable"), - WD_CHECK (toolbar_relief, "toolbar_relief"), - WD_CHECK (toolbar_relief_btn, "toolbar_relief_btn"), - WD_CHECK (toolbar_lines, "toolbar_lines"), - WD_CHECK (toolbar_icons_only, "toolbar_icons_only"), - WD_CHECK (toolbar_text_below, "toolbar_text_below"), - - WD_CHECK (dialog_icons, "dialog_icons"), - WD_CHECK (dialog_centered, "dialog_centered"), - - WD_OPTION (dialog_position, "dialog_position"), - WD_OPTION (dialog_type, "dialog_type"), - WD_OPTION (dialog_buttons_style, "dialog_buttons_style"), - - WD_OPTION (mdi_mode, "mdi_mode"), - WD_OPTION (mdi_tab_pos, "mdi_tab_pos"), - - WD_END -}; - -enum { - ARG_0, - ARG_PREFERENCES, - ARG_DIALOG_DATA -}; - -enum { - READ_PREFERENCES, - LAST_SIGNAL -}; - -static guint prefs_widget_signals[LAST_SIGNAL] = { 0 }; - -static CappletWidgetClass *parent_class; - -static void prefs_widget_init (PrefsWidget *prefs_widget); -static void prefs_widget_class_init (PrefsWidgetClass *class); - -static void prefs_widget_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); -static void prefs_widget_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); - -static void read_preferences (PrefsWidget *prefs_widget, - Preferences *prefs); - -static void register_callbacks (PrefsWidget *prefs_widget, - GladeXML *dialog_data); - -static widget_desc_t * const find_widget_desc_with_name - (PrefsWidget *prefs_widget, - const char *name); - -static void toggled_cb (GtkToggleButton *tb, - PrefsWidget *prefs_widget); -static void selected_cb (GtkMenuItem *mi, - PrefsWidget *prefs_widget); - -guint -prefs_widget_get_type (void) -{ - static guint prefs_widget_type = 0; - - if (!prefs_widget_type) { - GtkTypeInfo prefs_widget_info = { - "PrefsWidget", - sizeof (PrefsWidget), - sizeof (PrefsWidgetClass), - (GtkClassInitFunc) prefs_widget_class_init, - (GtkObjectInitFunc) prefs_widget_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - prefs_widget_type = - gtk_type_unique (capplet_widget_get_type (), - &prefs_widget_info); - } - - return prefs_widget_type; -} - -static void -prefs_widget_init (PrefsWidget *prefs_widget) -{ -} - -static void -prefs_widget_class_init (PrefsWidgetClass *class) -{ - GtkObjectClass *object_class; - - gtk_object_add_arg_type ("PrefsWidget::preferences", - GTK_TYPE_POINTER, - GTK_ARG_READWRITE, - ARG_PREFERENCES); - gtk_object_add_arg_type ("PrefsWidget::dialog_data", - GTK_TYPE_POINTER, - GTK_ARG_READWRITE, - ARG_DIALOG_DATA); - - object_class = GTK_OBJECT_CLASS (class); - object_class->set_arg = prefs_widget_set_arg; - object_class->get_arg = prefs_widget_get_arg; - - prefs_widget_signals[READ_PREFERENCES] = - gtk_signal_new ("read-preferences", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (PrefsWidgetClass, - read_preferences), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); - - gtk_object_class_add_signals (object_class, prefs_widget_signals, - LAST_SIGNAL); - - class->read_preferences = read_preferences; - - parent_class = CAPPLET_WIDGET_CLASS - (gtk_type_class (capplet_widget_get_type ())); - - class->widget_desc = widget_desc; -} - -static void -prefs_widget_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - PrefsWidget *prefs_widget; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_PREFS_WIDGET (object)); - - prefs_widget = PREFS_WIDGET (object); - - switch (arg_id) { - case ARG_PREFERENCES: - if (prefs_widget->prefs) - gtk_object_unref (GTK_OBJECT (prefs_widget->prefs)); - - prefs_widget->prefs = GTK_VALUE_POINTER (*arg); - - if (prefs_widget->prefs) { - gtk_object_ref (GTK_OBJECT (prefs_widget->prefs)); - if (prefs_widget->dialog_data) - gtk_signal_emit - (GTK_OBJECT (prefs_widget), - prefs_widget_signals - [READ_PREFERENCES], - prefs_widget->prefs, NULL); - } - - break; - - case ARG_DIALOG_DATA: - if (prefs_widget->dialog_data) - gtk_object_unref - (GTK_OBJECT (prefs_widget->dialog_data)); - - prefs_widget->dialog_data = GTK_VALUE_POINTER (*arg); - - if (prefs_widget->dialog_data) { - gtk_object_ref - (GTK_OBJECT (prefs_widget->dialog_data)); - if (prefs_widget->prefs) - gtk_signal_emit - (GTK_OBJECT (prefs_widget), - prefs_widget_signals - [READ_PREFERENCES], - prefs_widget->prefs, NULL); - register_callbacks (prefs_widget, - prefs_widget->dialog_data); - } - - break; - - default: - g_warning ("Bad argument set"); - break; - } -} - -static void -prefs_widget_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - PrefsWidget *prefs_widget; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_PREFS_WIDGET (object)); - - prefs_widget = PREFS_WIDGET (object); - - switch (arg_id) { - case ARG_PREFERENCES: - GTK_VALUE_POINTER (*arg) = prefs_widget->prefs; - break; - - case ARG_DIALOG_DATA: - GTK_VALUE_POINTER (*arg) = prefs_widget->dialog_data; - break; - - default: - g_warning ("Bad argument get"); - break; - } -} - -GtkWidget * -prefs_widget_new (Preferences *prefs) -{ - GtkWidget *widget, *dlg_widget; - GladeXML *dialog_data; - - g_return_val_if_fail (prefs == NULL || IS_PREFERENCES (prefs), NULL); - - dialog_data = glade_xml_new (GNOMECC_GLADE_DIR "/behavior-properties.glade", - "prefs_widget"); - - widget = gtk_widget_new (prefs_widget_get_type (), - "preferences", prefs, - "dialog_data", dialog_data, - NULL); - - dlg_widget = glade_xml_get_widget (dialog_data, "prefs_widget"); - gtk_container_add (GTK_CONTAINER (widget), dlg_widget); - - return widget; -} - -void -prefs_widget_set_preferences (PrefsWidget *prefs_widget, Preferences *prefs) -{ - g_return_if_fail (prefs_widget != NULL); - g_return_if_fail (IS_PREFS_WIDGET (prefs_widget)); - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - - gtk_object_set (GTK_OBJECT (prefs_widget), "preferences", prefs, NULL); -} - -static void -read_preferences (PrefsWidget *prefs_widget, Preferences *prefs) -{ - widget_desc_t *widget_desc; - int i; - - g_return_if_fail (prefs_widget != NULL); - g_return_if_fail (IS_PREFS_WIDGET (prefs_widget)); - g_return_if_fail (prefs != NULL); - g_return_if_fail (IS_PREFERENCES (prefs)); - - widget_desc = - PREFS_WIDGET_CLASS (GTK_OBJECT - (prefs_widget)->klass)->widget_desc; - - g_return_if_fail (widget_desc != NULL); - - for (i = 0; widget_desc[i].type != WDTYPE_NONE; i++) { - g_return_if_fail (widget_desc[i].name != NULL); - g_return_if_fail (widget_desc[i].get_func != NULL); - g_return_if_fail (widget_desc[i].set_func != NULL); - - switch (widget_desc[i].type) { - case WDTYPE_CHECK: - gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (WID (widget_desc[i].name)), - widget_desc[i].get_func (prefs)); - - break; - - case WDTYPE_OPTION: - gtk_option_menu_set_history - (GTK_OPTION_MENU (WID (widget_desc[i].name)), - widget_desc[i].get_func (prefs)); - break; - - case WDTYPE_NONE: - g_assert_not_reached (); - break; - } - } -} - -static void -register_callbacks (PrefsWidget *prefs_widget, GladeXML *dialog_data) -{ - widget_desc_t *widget_desc; - int i, j; - GtkWidget *menu; - GList *node; - - g_return_if_fail (prefs_widget != NULL); - g_return_if_fail (IS_PREFS_WIDGET (prefs_widget)); - g_return_if_fail (dialog_data != NULL); - g_return_if_fail (GLADE_IS_XML (dialog_data)); - - widget_desc = PREFS_WIDGET_CLASS (GTK_OBJECT - (prefs_widget)->klass)->widget_desc; - - if (widget_desc == NULL) - return; - - glade_xml_signal_connect_data (dialog_data, "toggled_cb", - GTK_SIGNAL_FUNC (toggled_cb), - prefs_widget); - - for (i = 0; widget_desc[i].type != WDTYPE_NONE; i++) { - g_return_if_fail (widget_desc[i].name != NULL); - g_return_if_fail (widget_desc[i].get_func != NULL); - g_return_if_fail (widget_desc[i].set_func != NULL); - - if (widget_desc[i].type != WDTYPE_OPTION) - continue; - - menu = glade_xml_get_widget (dialog_data, - widget_desc[i].name); - - g_return_if_fail (menu != NULL); - g_return_if_fail (GTK_IS_OPTION_MENU (menu)); - - node = GTK_MENU_SHELL (gtk_option_menu_get_menu - (GTK_OPTION_MENU - (menu)))->children; - - for (j = 0; node; j++, node = node->next) { - gtk_signal_connect (GTK_OBJECT (node->data), - "activate", - GTK_SIGNAL_FUNC - (selected_cb), - prefs_widget); - gtk_object_set_data (GTK_OBJECT (node->data), - "index", - GINT_TO_POINTER (j)); - gtk_object_set_data (GTK_OBJECT (node->data), - "name", - widget_desc[i].name); - } - } -} - -static widget_desc_t * const -find_widget_desc_with_name (PrefsWidget *prefs_widget, const char *name) -{ - widget_desc_t *widget_desc; - int i; - - g_return_val_if_fail (prefs_widget != NULL, NULL); - g_return_val_if_fail (IS_PREFS_WIDGET (prefs_widget), NULL); - g_return_val_if_fail (name != NULL, NULL); - - widget_desc = - PREFS_WIDGET_CLASS (GTK_OBJECT - (prefs_widget)->klass)->widget_desc; - - g_return_val_if_fail (widget_desc != NULL, NULL); - - for (i = 0; widget_desc[i].type != WDTYPE_NONE; i++) { - if (!strcmp (widget_desc[i].name, name)) - return &(widget_desc[i]); - } - - return NULL; -} - -static void -toggled_cb (GtkToggleButton *tb, PrefsWidget *prefs_widget) -{ - const char *widget_name; - widget_desc_t *widget_desc; - - g_return_if_fail (tb != NULL); - g_return_if_fail (GTK_IS_TOGGLE_BUTTON (tb)); - g_return_if_fail (prefs_widget != NULL); - g_return_if_fail (IS_PREFS_WIDGET (prefs_widget)); - - widget_name = glade_get_widget_name (GTK_WIDGET (tb)); - g_return_if_fail (widget_name != NULL); - widget_desc = find_widget_desc_with_name (prefs_widget, widget_name); - g_return_if_fail (widget_desc != NULL); - - widget_desc->set_func (prefs_widget->prefs, - gtk_toggle_button_get_active (tb)); - - preferences_changed (prefs_widget->prefs); - capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE); -} - -static void -selected_cb (GtkMenuItem *mi, PrefsWidget *prefs_widget) -{ - const char *widget_name; - widget_desc_t *widget_desc; - gint index = 0; - - g_return_if_fail (mi != NULL); - g_return_if_fail (GTK_IS_MENU_ITEM (mi)); - g_return_if_fail (prefs_widget != NULL); - g_return_if_fail (IS_PREFS_WIDGET (prefs_widget)); - - index = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (mi), "index")); - widget_name = gtk_object_get_data (GTK_OBJECT (mi), "name"); - g_return_if_fail (widget_name != NULL); - widget_desc = find_widget_desc_with_name (prefs_widget, widget_name); - g_return_if_fail (widget_desc != NULL); - - /* Only set it if it really changed */ - if (widget_desc->get_func (prefs_widget->prefs) != index) - { - widget_desc->set_func (prefs_widget->prefs, index); - - preferences_changed (prefs_widget->prefs); - capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE); - } -} diff --git a/capplets/ui-properties/prefs-widget.h b/capplets/ui-properties/prefs-widget.h deleted file mode 100644 index 1392a6a65..000000000 --- a/capplets/ui-properties/prefs-widget.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- mode: c; style: linux -*- */ - -/* prefs-widget.h - * Copyright (C) 2000 Helix Code, Inc. - * - * Written by Bradford Hovinen <hovinen@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef __PREFS_WIDGET_H -#define __PREFS_WIDGET_H - -#include <gtk/gtk.h> -#include <glade/glade.h> -#include <capplet-widget.h> - -#include "preferences.h" - -/* Generic widget descriptors to make maintenance easier */ - -typedef enum _widget_desc_type_t { - WDTYPE_NONE, - WDTYPE_CHECK, - WDTYPE_OPTION -} widget_desc_type_t; - -struct _widget_desc_t -{ - widget_desc_type_t type; - char *name; - gint (*get_func) (Preferences *); - void (*set_func) (Preferences *, gint); -}; - -typedef struct _widget_desc_t widget_desc_t; - -#define WD_CHECK(name, namestr) \ - { WDTYPE_CHECK, namestr "_toggle", \ - (gint (*) (Preferences *)) preferences_get_##name, \ - (void (*) (Preferences *, gint)) preferences_set_##name } -#define WD_OPTION(name, namestr) \ - { WDTYPE_OPTION, namestr "_select", \ - (gint (*) (Preferences *)) preferences_get_##name, \ - (void (*) (Preferences *, gint)) preferences_set_##name } -#define WD_END \ - { WDTYPE_NONE, NULL, NULL, NULL } - -/* Preferences widget class proper */ - -#define PREFS_WIDGET(obj) GTK_CHECK_CAST (obj, prefs_widget_get_type (), PrefsWidget) -#define PREFS_WIDGET_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, prefs_widget_get_type (), PrefsWidgetClass) -#define IS_PREFS_WIDGET(obj) GTK_CHECK_TYPE (obj, prefs_widget_get_type ()) - -typedef struct _PrefsWidget PrefsWidget; -typedef struct _PrefsWidgetClass PrefsWidgetClass; - -struct _PrefsWidget -{ - CappletWidget capplet_widget; - - Preferences *prefs; - GladeXML *dialog_data; -}; - -struct _PrefsWidgetClass -{ - CappletWidgetClass parent_class; - - void (*read_preferences) (PrefsWidget *prefs_widget, - Preferences *prefs); - - widget_desc_t *widget_desc; -}; - -guint prefs_widget_get_type (void); - -GtkWidget *prefs_widget_new (Preferences *prefs); - -void prefs_widget_set_preferences (PrefsWidget *prefs_widget, - Preferences *prefs); - -#endif /* __PREFS_WIDGET_H */ diff --git a/capplets/ui-properties/ui-properties.glade b/capplets/ui-properties/ui-properties.glade deleted file mode 100644 index ccf52ba46..000000000 --- a/capplets/ui-properties/ui-properties.glade +++ /dev/null @@ -1,924 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>New-ui-properties</name> - <program_name>new-ui-properties</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>.</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <output_translatable_strings>True</output_translatable_strings> - <translatable_strings_file>ui-properties.glade.h</translatable_strings_file> -</project> - -<widget> - <class>GtkWindow</class> - <name>window4</name> - <title>window4</title> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>True</allow_grow> - <auto_shrink>False</auto_shrink> - - <widget> - <class>GtkVBox</class> - <name>prefs_widget</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - - <widget> - <class>GtkNotebook</class> - <name>notebook1</name> - <can_focus>True</can_focus> - <show_tabs>True</show_tabs> - <show_border>True</show_border> - <tab_pos>GTK_POS_TOP</tab_pos> - <scrollable>False</scrollable> - <tab_hborder>2</tab_hborder> - <tab_vborder>2</tab_vborder> - <popup_enable>False</popup_enable> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - - <widget> - <class>GtkTable</class> - <name>table3</name> - <border_width>4</border_width> - <rows>2</rows> - <columns>2</columns> - <homogeneous>True</homogeneous> - <row_spacing>4</row_spacing> - <column_spacing>4</column_spacing> - - <widget> - <class>GtkFrame</class> - <name>frame7</name> - <label>Menus</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkVBox</class> - <name>vbox2</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - - <widget> - <class>GtkCheckButton</class> - <name>menubar_detachable_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:48:47 GMT</last_modification_time> - </signal> - <label>Menu bars are detachable</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>menubar_relief_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:48:53 GMT</last_modification_time> - </signal> - <label>Menu bars have a border</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>menus_have_tearoff_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:49:03 GMT</last_modification_time> - </signal> - <label>Menus can be torn off</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>menus_have_icons_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:49:11 GMT</last_modification_time> - </signal> - <label>Menu items have icons</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkFrame</class> - <name>frame8</name> - <label>Status Bar</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkVBox</class> - <name>vbox3</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - - <widget> - <class>GtkCheckButton</class> - <name>statusbar_not_dialog_toggle</name> - <visible>False</visible> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 05:09:02 GMT</last_modification_time> - </signal> - <label>Use status bar instead of dialog when possible</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>statusbar_is_interactive_toggle</name> - <visible>False</visible> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:49:20 GMT</last_modification_time> - </signal> - <label>Status bar is interactive when possible</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkHSeparator</class> - <name>hseparator1</name> - <visible>False</visible> - <child> - <padding>2</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>statusbar_meter_on_left_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Fri, 08 Dec 2000 20:02:09 GMT</last_modification_time> - </signal> - <label>Progress bar is on the left</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>progressbar</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>statusbar_meter_on_right_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Fri, 08 Dec 2000 20:02:15 GMT</last_modification_time> - </signal> - <label>Progress bar is on the right</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>progressbar</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkFrame</class> - <name>frame6</name> - <label>Tool Bars</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <left_attach>0</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkTable</class> - <name>table4</name> - <border_width>4</border_width> - <rows>4</rows> - <columns>2</columns> - <homogeneous>True</homogeneous> - <row_spacing>0</row_spacing> - <column_spacing>0</column_spacing> - - <widget> - <class>GtkCheckButton</class> - <name>toolbar_relief_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:49:42 GMT</last_modification_time> - </signal> - <label>Tool bars have a border</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>toolbar_relief_btn_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:49:48 GMT</last_modification_time> - </signal> - <label>Tool bar buttons pop up on mouse over</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>toolbar_lines_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:49:53 GMT</last_modification_time> - </signal> - <label>Tool bars have line separators</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>toolbar_detachable_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 02:49:38 GMT</last_modification_time> - </signal> - <label>Tool bars are detachable</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>toolbar_icons_only_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Fri, 08 Dec 2000 19:27:09 GMT</last_modification_time> - </signal> - <label>Tool bar buttons are icons only</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>toolbar_icons</group> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>toolbar_text_below_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Fri, 08 Dec 2000 19:27:18 GMT</last_modification_time> - </signal> - <label>Tool bar buttons are text below icons</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>toolbar_icons</group> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label6</name> - <label>Interface</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkVBox</class> - <name>vbox8</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - - <widget> - <class>GtkFrame</class> - <name>frame9</name> - <label>Dialogs</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - - <widget> - <class>GtkVBox</class> - <name>vbox9</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - - <widget> - <class>GtkCheckButton</class> - <name>dialog_icons_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 05:08:48 GMT</last_modification_time> - </signal> - <label>Dialog buttons have icons</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>dialog_centered_toggle</name> - <can_focus>True</can_focus> - <signal> - <name>toggled</name> - <handler>toggled_cb</handler> - <last_modification_time>Sun, 24 Sep 2000 05:09:12 GMT</last_modification_time> - </signal> - <label>Place dialogs over application window when possible</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkTable</class> - <name>table5</name> - <rows>3</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>4</row_spacing> - <column_spacing>4</column_spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label2</name> - <label>Dialogs open</label> - <justify>GTK_JUSTIFY_RIGHT</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>dialog_position_select</name> - <can_focus>True</can_focus> - <items>Wherever the Window Manager places them -At the center of the screen -At the mouse pointer -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label3</name> - <label>Dialogs are treated</label> - <justify>GTK_JUSTIFY_RIGHT</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>dialog_type_select</name> - <can_focus>True</can_focus> - <items>Like any other window -Specially by the window manager -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label1</name> - <label>Dialog Buttons</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>dialog_buttons_style_select</name> - <can_focus>True</can_focus> - <items>Default (Spread out - big) -Spread out -Spread out (big) -Left aligned -Right aligned -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GtkFrame</class> - <name>frame10</name> - <label>Multiple Documents</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - - <widget> - <class>GtkTable</class> - <name>table2</name> - <border_width>5</border_width> - <rows>2</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>5</row_spacing> - <column_spacing>5</column_spacing> - - <widget> - <class>GtkOptionMenu</class> - <name>mdi_mode_select</name> - <can_focus>True</can_focus> - <items>Notebook tabs -Seperate windows -The same window -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>mdi_tab_pos_select</name> - <can_focus>True</can_focus> - <items>Left -Right -Top -Bottom -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label8</name> - <label>When opening Multiple documents, use</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label9</name> - <label>When using Notebook tabs, place the tabs on the</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label7</name> - <label>Miscellaneous</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox2</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - - <widget> - <class>GnomePixmap</class> - <name>pixmap1</name> - <filename>gnome-warning.png</filename> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label10</name> - <label>Settings will not take effect until applications restart</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/capplets/ui-properties/ui-properties.glade.h b/capplets/ui-properties/ui-properties.glade.h deleted file mode 100644 index 14a846355..000000000 --- a/capplets/ui-properties/ui-properties.glade.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Translatable strings file generated by Glade. - * Add this file to your project's POTFILES.in. - * DO NOT compile it as part of your application. - */ - -gchar *s = N_("window4"); -gchar *s = N_("Menus"); -gchar *s = N_("Menu bars are detachable"); -gchar *s = N_("Menu bars have a border"); -gchar *s = N_("Menus can be torn off"); -gchar *s = N_("Menu items have icons"); -gchar *s = N_("Status Bar"); -gchar *s = N_("Use status bar instead of dialog when possible"); -gchar *s = N_("Status bar is interactive when possible"); -gchar *s = N_("Progress bar is on the left"); -gchar *s = N_("Progress bar is on the right"); -gchar *s = N_("Tool Bars"); -gchar *s = N_("Tool bars have a border"); -gchar *s = N_("Tool bar buttons pop up on mouse over"); -gchar *s = N_("Tool bars have line separators"); -gchar *s = N_("Tool bars are detachable"); -gchar *s = N_("Tool bar buttons are icons only"); -gchar *s = N_("Tool bar buttons are text below icons"); -gchar *s = N_("Interface"); -gchar *s = N_("Dialogs"); -gchar *s = N_("Dialog buttons have icons"); -gchar *s = N_("Place dialogs over application window when possible"); -gchar *s = N_("Dialogs open"); -gchar *s = N_("Wherever the Window Manager places them"); -gchar *s = N_("At the center of the screen"); -gchar *s = N_("At the mouse pointer"); -gchar *s = N_("Dialogs are treated"); -gchar *s = N_("Like any other window"); -gchar *s = N_("Specially by the window manager"); -gchar *s = N_("Dialog Buttons"); -gchar *s = N_("Default (Spread out - big)"); -gchar *s = N_("Spread out"); -gchar *s = N_("Spread out (big)"); -gchar *s = N_("Left aligned"); -gchar *s = N_("Right aligned"); -gchar *s = N_("Multiple Documents"); -gchar *s = N_("Notebook tabs"); -gchar *s = N_("Seperate windows"); -gchar *s = N_("The same window"); -gchar *s = N_("Left"); -gchar *s = N_("Right"); -gchar *s = N_("Top"); -gchar *s = N_("Bottom"); -gchar *s = N_("When opening Multiple documents, use"); -gchar *s = N_("When using Notebook tabs, place the tabs on the"); -gchar *s = N_("Miscellaneous"); -gchar *s = N_("Settings will not take effect until applications restart"); diff --git a/capplets/url-properties/ChangeLog b/capplets/url-properties/ChangeLog deleted file mode 100644 index 28cf488c1..000000000 --- a/capplets/url-properties/ChangeLog +++ /dev/null @@ -1,45 +0,0 @@ -2001-07-27 Bradford Hovinen <hovinen@ximian.com> - - * RELEASE : 1.5.2 - -2001-07-24 Chema Celorio <chema@celorio.com> - - * url-properties.c: set the usize of the window - -2001-07-20 Chema Celorio <chema@celorio.com> - - * RELEASE : 1.5.0 - -1999-06-11 Ettore Perazzoli <ettore@comm2000.it> - - * url-properties.c (main): Exit with an error if - `gnome_capplet_init()' returns an error. Bug reported by Nicola - Pero <n.pero@mi.flashnet.it>. - -1999-05-16 Jacob Berkman <jberk+@cmu.edu> - - * url-properties.c (url_capplet_commit): added a - gnome_config_sync() so the changes actually get saved. - (gnome bug #169) - -1998-12-12 Nuno Ferreira <nmrf@rnl.ist.utl.pt> - - * url-properties.c: Change included "config.h" to <config.h>. - - * url-properties.desktop: Added Portuguese translation. - -1998-12-11 Nuno Ferreira <nmrf@rnl.ist.utl.pt> - - * .cvsignore: Added this file. - -1998-12-08 James Henstridge <james@daa.com.au> - * url-properties.c: forgot the copyright message at the top of the - file. - -1998-12-08 James Henstridge <james@daa.com.au> - - * url-properties.c, url-properties.desktop, Makefile.am: A new capplet - that can be used to configure the behaviour of the gnome_url_show - function. - - diff --git a/capplets/url-properties/Makefile.am b/capplets/url-properties/Makefile.am deleted file mode 100644 index 812363789..000000000 --- a/capplets/url-properties/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -cappletname = url -cappletgroup = "Advanced/" -bin_PROGRAMS = url-properties - -url_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS) -url_properties_SOURCES = url-properties.c - -pixmap_DATA = - -## -## You should not need to modify anything below this line -## -@XML_I18N_MERGE_DESKTOP_RULE@ -@GNOMECC_CAPPLETS_DESKTOP_IN_RULE@ - -INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS) -CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) -EXTRA_DIST = $(GNOMECC_CAPPLETS_EXTRA_DIST) -iconsdir = $(GNOMECC_ICONS_DIR) -Gladedir = $(GNOMECC_GLADE_DIR) -pixmapdir = $(GNOMECC_PIXMAPS_DIR) -Glade_DATA = $(cappletname)-properties.glade -icons_DATA = $(cappletname)-capplet.png -desktop = $(cappletname).desktop -all-local: $(desktop) diff --git a/capplets/url-properties/url-capplet.png b/capplets/url-properties/url-capplet.png Binary files differdeleted file mode 100644 index ff224b2ea..000000000 --- a/capplets/url-properties/url-capplet.png +++ /dev/null diff --git a/capplets/url-properties/url-properties.c b/capplets/url-properties/url-properties.c deleted file mode 100644 index f6296d0d5..000000000 --- a/capplets/url-properties/url-properties.c +++ /dev/null @@ -1,292 +0,0 @@ -/* url-properties -- a capplet to configure the behaviour of gnome_url_show - * Copyright (C) 1998 James Henstridge <james@daa.com.au> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include <string.h> -#include <gtk/gtk.h> -#include "capplet-widget.h" -#include <gnome.h> - -GtkWidget *capplet, *protocol, *combo, *clist; - -void url_capplet_revert(void); -void url_capplet_commit(void); -void url_capplet_cancel(void); - -void build_capplet(void); - -int -main(int argc, char *argv[]) { - gint init_ret; - - bindtextdomain(PACKAGE, GNOMELOCALEDIR); - textdomain(PACKAGE); - - init_ret = gnome_capplet_init("url-properties", VERSION, argc, argv, - NULL, 0, NULL); - if (init_ret == 1) { - /* nothing to init */ - return 0; - } else if (init_ret == -1) { - g_error (_("Error initializing the `url-properties' capplet.")); - } - - build_capplet(); - url_capplet_revert(); /* this will refill the clist */ - - gtk_signal_connect(GTK_OBJECT(capplet), "revert", - GTK_SIGNAL_FUNC(url_capplet_revert), NULL); - gtk_signal_connect(GTK_OBJECT(capplet), "ok", - GTK_SIGNAL_FUNC(url_capplet_commit), NULL); - gtk_signal_connect(GTK_OBJECT(capplet), "cancel", - GTK_SIGNAL_FUNC(url_capplet_cancel), NULL); - - capplet_gtk_main(); - return 0; -} - -void set_handler(GtkEntry *entry); -void remove_handler(GtkButton *button); -void select_clist_row(GtkCList *clist, gint row, gint column); - -void build_capplet(void) { - GtkWidget *vbox, *hbox, *item, *button; - gchar *titles[] = { N_("Protocol"), N_("Command") }; - - capplet = capplet_widget_new(); - vbox = gtk_vbox_new(FALSE, 5); - gtk_widget_set_usize (vbox, 400, 250); - gtk_container_add(GTK_CONTAINER(capplet), vbox); - gtk_widget_show(vbox); - - hbox = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); - gtk_widget_show(hbox); - - protocol = gtk_entry_new(); - gtk_widget_set_usize(protocol, 80, -1); - gtk_box_pack_start(GTK_BOX(hbox), protocol, FALSE, TRUE, 0); - gtk_widget_show(protocol); - - item = gtk_label_new(_("handler:")); - gtk_box_pack_start(GTK_BOX(hbox), item, FALSE, TRUE, 0); - gtk_widget_show(item); - - combo = gtk_combo_new(); - gtk_combo_set_use_arrows(GTK_COMBO(combo), FALSE); - gtk_combo_set_value_in_list(GTK_COMBO(combo), FALSE, FALSE); - gtk_combo_disable_activate(GTK_COMBO(combo)); - - /* set some commonly used handlers */ - item = gtk_list_item_new_with_label(_("Netscape")); - gtk_combo_set_item_string(GTK_COMBO(combo), GTK_ITEM(item), - "gnome-moz-remote '%s'"); - gtk_container_add(GTK_CONTAINER(GTK_COMBO(combo)->list), item); - gtk_widget_show(item); - item = gtk_list_item_new_with_label(_("Netscape (new window)")); - gtk_combo_set_item_string(GTK_COMBO(combo), GTK_ITEM(item), - "gnome-moz-remote --newwin '%s'"); - gtk_container_add(GTK_CONTAINER(GTK_COMBO(combo)->list), item); - gtk_widget_show(item); - - item = gtk_list_item_new_with_label(_("Help browser")); - gtk_combo_set_item_string(GTK_COMBO(combo), GTK_ITEM(item), - "gnome-help-browser '#%s'"); - gtk_container_add(GTK_CONTAINER(GTK_COMBO(combo)->list), item); - gtk_widget_show(item); - item = gtk_list_item_new_with_label(_("Help browser (new window)")); - gtk_combo_set_item_string(GTK_COMBO(combo), GTK_ITEM(item), - "gnome-help-browser '%s'"); - gtk_container_add(GTK_CONTAINER(GTK_COMBO(combo)->list), item); - gtk_widget_show(item); - - gtk_box_pack_start(GTK_BOX(hbox), combo, TRUE, TRUE, 0); - gtk_widget_show(combo); - - gtk_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->entry), "activate", - GTK_SIGNAL_FUNC(set_handler), NULL); - - button = gtk_button_new_with_label(_("Set")); - gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, TRUE, 0); - gtk_widget_show(button); - - gtk_signal_connect_object(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(set_handler), - GTK_OBJECT(GTK_COMBO(combo)->entry)); - - button = gtk_button_new_with_label(_("Remove")); - gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, TRUE, 0); - gtk_widget_show(button); - - gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(remove_handler), NULL); - - item = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(item), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_box_pack_start(GTK_BOX(vbox), item, TRUE, TRUE, 0); - gtk_widget_show(item); - - titles[0] = _(titles[0]); - titles[1] = _(titles[1]); - clist = gtk_clist_new_with_titles(2, titles); - gtk_container_add(GTK_CONTAINER(item), clist); - gtk_widget_show(clist); - - gtk_clist_set_column_width(GTK_CLIST(clist), 0, 50); - gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_BROWSE); - gtk_clist_set_sort_type(GTK_CLIST(clist), GTK_SORT_ASCENDING); - gtk_clist_set_sort_column(GTK_CLIST(clist), 0); - gtk_clist_set_auto_sort(GTK_CLIST(clist), TRUE); - - gtk_signal_connect(GTK_OBJECT(clist), "select_row", - GTK_SIGNAL_FUNC(select_clist_row), NULL); - - gtk_widget_show(capplet); -} - -void url_capplet_revert(void) { - void *iter; - gchar *key, *value; - gint len; - gboolean def = FALSE; - - /* see if the default is set. If not, put in some sensible defaults. - * Maybe this should pass a call through to gnome-url */ - g_free(gnome_config_get_string_with_default( - "/Gnome/URL Handlers/default-show=?", &def)); - if (def) { - gnome_config_set_string("/Gnome/URL Handlers/default-show", - "gnome-moz-remote --newwin \"%s\""); - g_free(gnome_config_get_string_with_default( - "/Gnome/URL Handlers/info-show=?", &def)); - if (def) - gnome_config_set_string("/Gnome/URL Handlers/info-show", - "gnome-help-browser \"%s\""); - g_free(gnome_config_get_string_with_default( - "/Gnome/URL Handlers/man-show=?", &def)); - if (def) - gnome_config_set_string("/Gnome/URL Handlers/man-show", - "gnome-help-browser \"%s\""); - g_free(gnome_config_get_string_with_default( - "/Gnome/URL Handlers/ghelp-show=?", &def)); - if (def) - gnome_config_set_string("/Gnome/URL Handlers/ghelp-show", - "gnome-help-browser \"%s\""); - } - - iter = gnome_config_init_iterator("/Gnome/URL Handlers"); - gtk_clist_freeze(GTK_CLIST(clist)); - gtk_clist_clear(GTK_CLIST(clist)); - while ((iter = gnome_config_iterator_next(iter, &key, &value))) { - len = strlen(key); - if (len > 5 && !strcmp(&key[len-5], "-show")) { - gchar *row[2]; - gint id; - /* it is a *-show key */ - key[len-5] = '\0'; - row[0] = key; - row[1] = value; - - id = gtk_clist_append(GTK_CLIST(clist), row); - if (!g_strcasecmp(key, "default")) - gtk_clist_select_row(GTK_CLIST(clist), id, 0); - } - g_free(key); - g_free(value); - } - gtk_clist_thaw(GTK_CLIST(clist)); -} - -void url_capplet_commit(void) { - gint num_rows, row; - gchar *col1, *col2, *key; - - /* should we be more specific here?*/ - gnome_config_clean_section("/Gnome/URL Handlers"); - num_rows = GTK_CLIST(clist)->rows; - for (row = 0; row < num_rows; row++) { - gtk_clist_get_text(GTK_CLIST(clist), row, 0, &col1); - gtk_clist_get_text(GTK_CLIST(clist), row, 1, &col2); - key = g_strconcat("/Gnome/URL Handlers/", col1, "-show", NULL); - gnome_config_set_string(key, col2); - g_free(key); - } - gnome_config_sync(); - gtk_main_quit(); -} - -void url_capplet_cancel(void) { - gtk_main_quit(); -} - -void set_handler(GtkEntry *entry) { - gint row, num_rows; - gchar *col1, *prot, *cols[2]; - - num_rows = GTK_CLIST(clist)->rows; - prot = gtk_entry_get_text(GTK_ENTRY(protocol)); - for (row = 0; row < num_rows; row++) { - gtk_clist_get_text(GTK_CLIST(clist), row, 0, &col1); - if (!g_strcasecmp(prot, col1)) { - gtk_clist_set_text(GTK_CLIST(clist), row, 1, gtk_entry_get_text(entry)); - capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE); - return; - } - } - /* prot not in clist */ - cols[0] = prot; - cols[1] = gtk_entry_get_text(entry); - gtk_clist_append(GTK_CLIST(clist), cols); - capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE); -} - -void remove_handler(GtkButton *button) { - gint row, num_rows; - gchar *col1, *prot; - - num_rows = GTK_CLIST(clist)->rows; - prot = gtk_entry_get_text(GTK_ENTRY(protocol)); - for (row = 0; row < num_rows; row++) { - gtk_clist_get_text(GTK_CLIST(clist), row, 0, &col1); - if (!g_strcasecmp(prot, col1)) { - gtk_clist_remove(GTK_CLIST(clist), row); - capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE); - gtk_entry_set_text(GTK_ENTRY(protocol), ""); - gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), ""); - if (num_rows > 1) - gtk_clist_select_row(GTK_CLIST(clist), 0, 0); - return; - } - } -} - -void select_clist_row(GtkCList *clist, gint row, gint column) { - gchar *col1, *col2; - - /* get column values */ - gtk_clist_get_text(GTK_CLIST(clist), row, 0, &col1); - gtk_clist_get_text(GTK_CLIST(clist), row, 1, &col2); - - gtk_entry_set_text(GTK_ENTRY(protocol), col1); - - gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), col2); -} diff --git a/capplets/url-properties/url-properties.desktop.in b/capplets/url-properties/url-properties.desktop.in deleted file mode 100644 index 41d585fc8..000000000 --- a/capplets/url-properties/url-properties.desktop.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=URL Handlers -_Comment=Configure which programs are used to display URLs -Exec=url-properties -Icon=gnome-html.png -Terminal=0 -Type=Application diff --git a/capplets/url-properties/url-properties.glade b/capplets/url-properties/url-properties.glade deleted file mode 100644 index e69de29bb..000000000 --- a/capplets/url-properties/url-properties.glade +++ /dev/null diff --git a/capplets/url-properties/url-properties_WITH_TRANSLATIONS b/capplets/url-properties/url-properties_WITH_TRANSLATIONS deleted file mode 100644 index dfa336363..000000000 --- a/capplets/url-properties/url-properties_WITH_TRANSLATIONS +++ /dev/null @@ -1,57 +0,0 @@ -[Desktop Entry] -Name=URL Handlers -Name[pt_BR]=Manipuladores de URL -Name[cs]=Obsluha URL -Name[ca]=Gestors d'URLs -Name[da]=Url-håndterer -Name[de]=Öffnen von URLs -Name[el]=ÖõëëïìÝôñçóç URL -Name[es]=Navegador de URLs -Name[et]=URL käsitlejad -Name[fi]=URL-käsittely -Name[fr]=Gestionnaires d'URLs -Name[gl]=Xestores de URL -Name[hu]=URL kezelõk -Name[it]=Gestori URL -Name[ja]=URL¥Ï¥ó¥É¥é -Name[ko]=URL ó¸® -Name[no]=URL-håndtering -Name[pl]=Obs³uga URL -Name[pt]=URL Handlers -Name[ro]=Tratare URL-uri -Name[ru]=ïÂÒÁÂÏÔÞÉËÉ URL -Name[sl]=URL Upravniki -Name[sv]=URL-hantering -Name[tr]=URL yöneticileri -Name[uk]=ïÂÒÏÂÎÉËÉ URL -Name[wa]=Naivieu di hårdeyes (URLs) -Comment=Configure which programs are used to display URLs -Comment[pt_BR]=Configurar que programas são usados para mostrar URLs. -Comment[cs]=Nastavení programù pro zobrazení URL -Comment[ca]=Seleccionar quins programes usar per mostrar URLs. -Comment[da]=Vælg hvilke programmer der skal bruges til at åbne url'er -Comment[de]=Konfigurieren, womit URLs geöffnet werden -Comment[el]=Ñõèìßæåé ðïéÜ ðñïãñÜììáôá èá äåß÷íïõí ôá URL -Comment[es]=Configura cual programa usar para navegar por las URLs -Comment[et]=Määrab, millised programmid käsitlevad milliseid URL protokolle -Comment[fi]=Aseta, mitä ohjelmia käytetään URL:ien näyttämiseen -Comment[fr]=Configuration des applications utilisées pour afficher les URLs -Comment[gl]=Configura os programas que se van usar para amosar as URL -Comment[hu]=A külömbözõ webhelyek-dokumentumok kezelésének beállítása -Comment[it]=Impostazione dei programmi necessari per visualizzare le URL -Comment[ja]=URL¤òɽ¼¨¤¹¤ë¥×¥í¥°¥é¥à¤ÎÀßÄê -Comment[ko]=URLÀ» Ç¥½ÃÇÒ ¶§ »ç¿ëÇÒ ÇÁ·Î±×·¥ ¼±Åà -Comment[no]=Konfigurer hvilke programmer som brukes til å vise URL'er -Comment[pl]=Konfiguracja programów do obs³ugi URL-i -Comment[pt]=Permite configurar quais os programas usados para mostrar URLs -Comment[ro]=Configuraþi ce programe sunt folosite pentru URL-uri -Comment[ru]=ïÐÒÅÄÅÌÉÔØ ÐÒÏÇÒÁÍÍÕ ÄÌÑ ÐÏËÁÚÁ URL. -Comment[sl]=Nastavi kateri programi naj se uporabijo za prikazovanje URLjev -Comment[sv]=Konfigurera vilka program som används för att visa URL:er -Comment[tr]=URL'leri gösterecek uygulamalarý belirtir -Comment[uk]=÷ÉÚÎÁÞÅÎÎÑ ÐÒÏÇÒÁÍÉ ÄÌÑ ×¦ÄÏÂÒÁÖÅÎÎÑ URL -Comment[wa]=Tchwezixhoz li programe ki vos voloz po naivyî sol rantoele daegnrece et po vey les hårdeyes -Exec=url-properties -Icon=gnome-html.png -Terminal=0 -Type=Application diff --git a/capplets/url-properties/url.desktop.in.in b/capplets/url-properties/url.desktop.in.in deleted file mode 100644 index 41d585fc8..000000000 --- a/capplets/url-properties/url.desktop.in.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=URL Handlers -_Comment=Configure which programs are used to display URLs -Exec=url-properties -Icon=gnome-html.png -Terminal=0 -Type=Application diff --git a/capplets/wm-properties/ChangeLog b/capplets/wm-properties/ChangeLog deleted file mode 100644 index d895f08b8..000000000 --- a/capplets/wm-properties/ChangeLog +++ /dev/null @@ -1,34 +0,0 @@ -2001-09-29 Richard Hestilow <hestilow@ximian.com> - - * wm-properties-capplet.c: Applied patch from drk@sgi.com - to fix bug #60822. - -2001-09-29 Richard Hestilow <hestilow@ximian.com> - - * wm-list.c (wm_list_read_dir): Check if config_tryexec is blank, - and if it is, free it and set it to NULL. - (wm_check_present): If there is no config_tryexec, fall back - on checking the path of the config_exec. Fix for bug #58306. - -2001-09-05 Abel Cheung <maddog@linux.org.hk> - - * wm.desktop.in.in: Rename zh_TW.Big5 to zh_TW . -2001-07-27 Bradford Hovinen <hovinen@ximian.com> - - * RELEASE : 1.5.2 - -2001-07-24 Chema Celorio <chema@celorio.com> - - * wm-properties-capplet.c (wm_setup): add a label and set the usize - -2001-07-20 Chema Celorio <chema@celorio.com> - - * RELEASE : 1.5.0 - -2001-07-19 Chema Celorio <chema@celorio.com> - - * wm-desktops/Makefile.am (wms): distcheck fixes - -2001-07-19 Carlos Perelló Marín <carlos@gnome-db.org> - - * wm-desktops/*.desktop: Adapted to use xml-i18n-tools diff --git a/capplets/wm-properties/Makefile.am b/capplets/wm-properties/Makefile.am deleted file mode 100644 index 1629da473..000000000 --- a/capplets/wm-properties/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -SUBDIRS = wm-desktops - -cappletname = wm -cappletgroup = "Advanced/" -bin_PROGRAMS = wm-properties-capplet - -wm_properties_capplet_LDADD = $(GNOMECC_CAPPLETS_LIBS) -wm_properties_capplet_SOURCES = \ - wm-properties.h \ - wm-properties-capplet.c \ - wm-list.c \ - wm-exec.c - -pixmap_DATA = - -## -## You should not need to modify anything below this line -## -@XML_I18N_MERGE_DESKTOP_RULE@ -@GNOMECC_CAPPLETS_DESKTOP_IN_RULE@ - -INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS) -CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) -EXTRA_DIST = $(GNOMECC_CAPPLETS_EXTRA_DIST) -iconsdir = $(GNOMECC_ICONS_DIR) -Gladedir = $(GNOMECC_GLADE_DIR) -pixmapdir = $(GNOMECC_PIXMAPS_DIR) -Glade_DATA = $(cappletname)-properties.glade -icons_DATA = $(cappletname)-capplet.png -desktop = $(cappletname).desktop -all-local: $(desktop) diff --git a/capplets/wm-properties/wm-capplet.png b/capplets/wm-properties/wm-capplet.png Binary files differdeleted file mode 100644 index ef95bcd47..000000000 --- a/capplets/wm-properties/wm-capplet.png +++ /dev/null diff --git a/capplets/wm-properties/wm-desktops/Enlightenment.desktop.in.in b/capplets/wm-properties/wm-desktops/Enlightenment.desktop.in.in deleted file mode 100644 index 1d9d0a199..000000000 --- a/capplets/wm-properties/wm-desktops/Enlightenment.desktop.in.in +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -_Name=Enlightenment -Exec=enlightenment -TryExec=enlightenment - -[Window Manager] -ConfigExec=e-conf -ConfigTryExec=e-conf -SessionManaged=true diff --git a/capplets/wm-properties/wm-desktops/IceWM.desktop.in.in b/capplets/wm-properties/wm-desktops/IceWM.desktop.in.in deleted file mode 100644 index e12d1a9c0..000000000 --- a/capplets/wm-properties/wm-desktops/IceWM.desktop.in.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=Ice WM -Exec=icewm -TryExec=icewm - -[Window Manager] -SessionManaged=true diff --git a/capplets/wm-properties/wm-desktops/Makefile.am b/capplets/wm-properties/wm-desktops/Makefile.am deleted file mode 100644 index c1e38fa07..000000000 --- a/capplets/wm-properties/wm-desktops/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ -wms = \ - Enlightenment \ - IceWM \ - Scwm \ - WindowMaker \ - twm - -desktop_files = $(wms:=.desktop) -desktop_in_files = $(desktop_files:.desktop=.desktop.in) -desktop_in_in_files = $(desktop_files:.desktop=.desktop.in.in) - -wmdatadir = $(datadir)/gnome/wm-properties -wmdata_DATA = $(desktop_files) - -EXTRA_DIST = $(desktop_in_in_files) - -$(desktop_in_files): %.desktop.in: %.desktop.in.in - sed s#Icon=#Icon=$(GNOMECC_ICONS_DIR)/# < $< > $@ - -$(desktop_files): %.desktop: %.desktop.in - $(top_builddir)/xml-i18n-merge -d $(top_srcdir)/po $< $@ diff --git a/capplets/wm-properties/wm-desktops/Scwm.desktop.in.in b/capplets/wm-properties/wm-desktops/Scwm.desktop.in.in deleted file mode 100644 index 88e0a8c30..000000000 --- a/capplets/wm-properties/wm-desktops/Scwm.desktop.in.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=Scwm -Exec=scwm -TryExec=scwm - -[Window Manager] -SessionManaged=true diff --git a/capplets/wm-properties/wm-desktops/WindowMaker.desktop.in.in b/capplets/wm-properties/wm-desktops/WindowMaker.desktop.in.in deleted file mode 100644 index 7e1cde50e..000000000 --- a/capplets/wm-properties/wm-desktops/WindowMaker.desktop.in.in +++ /dev/null @@ -1,8 +0,0 @@ -[Desktop Entry] -_Name=Window Maker -Exec=wmaker -TryExec=wmaker - -[Window Manager] -SessionManaged=false -ConfigExec=/usr/X11R6/lib/GNUstep/Apps/WPrefs.app/WPrefs diff --git a/capplets/wm-properties/wm-desktops/twm.desktop.in.in b/capplets/wm-properties/wm-desktops/twm.desktop.in.in deleted file mode 100644 index 45aef35a9..000000000 --- a/capplets/wm-properties/wm-desktops/twm.desktop.in.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -_Name=twm -Exec=twm -TryExec=twm - -[Window Manager] -SessionManaged=false diff --git a/capplets/wm-properties/wm-exec.c b/capplets/wm-properties/wm-exec.c deleted file mode 100644 index cf2ab507b..000000000 --- a/capplets/wm-properties/wm-exec.c +++ /dev/null @@ -1,332 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ -/* Copyright (C) 1998 Redhat Software Inc. - * Code available under the Gnu GPL. - * Authors: Owen Taylor <otaylor@redhat.com> - */ - -#include <gtk/gtk.h> -#include <gdk/gdkx.h> -#include <libgnome/libgnome.h> -#include "wm-properties.h" - -typedef struct _RestartInfo RestartInfo; - -struct _RestartInfo { - GnomeDesktopEntry *dentry; - gint retries; - WMResultFunc callback; - gpointer data; -}; - -gboolean -wm_is_running (void) -{ - gboolean result; - gboolean old_warnings = gdk_error_warnings; - guint old_mask; - XWindowAttributes attrs; - - gdk_error_warnings = FALSE; - gdk_error_code = 0; - - XGetWindowAttributes (GDK_DISPLAY(), GDK_ROOT_WINDOW(), &attrs); - - XSelectInput (GDK_DISPLAY(), GDK_ROOT_WINDOW(), - SubstructureRedirectMask); - XSync (GDK_DISPLAY(), False); - if (gdk_error_code == 0) { - result = FALSE; - XSelectInput (GDK_DISPLAY(), GDK_ROOT_WINDOW(), - attrs.your_event_mask); - } else - result = TRUE; - - gdk_error_warnings = old_warnings; - return result; -} - -/* Cut and paste from gnome-libs/gnome_win_hints_wm_exists, except that we - * return the xid instead of a window - */ -static Window -find_gnome_wm_window(void) -{ - Atom r_type; - int r_format; - unsigned long count; - unsigned long bytes_remain; - unsigned char *prop, *prop2; - gint prev_error; - GdkAtom cardinal_atom = gdk_atom_intern ("CARDINAL", FALSE); - - prev_error = gdk_error_warnings; - gdk_error_warnings = 0; - if (XGetWindowProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(), - gdk_atom_intern ("_WIN_SUPPORTING_WM_CHECK", FALSE), - 0, 1, False, cardinal_atom, - &r_type, &r_format, - &count, &bytes_remain, &prop) == Success && prop) - { - if (r_type == cardinal_atom && r_format == 32 && count == 1) - { - Window n = *(long *)prop; - if (XGetWindowProperty(GDK_DISPLAY(), n, - gdk_atom_intern ("_WIN_SUPPORTING_WM_CHECK", FALSE), - 0, 1, False, cardinal_atom, - &r_type, &r_format, &count, &bytes_remain, - &prop2) == Success && prop) - { - if (r_type == cardinal_atom && r_format == 32 && count == 1) - { - XFree(prop); - XFree(prop2); - gdk_error_warnings = prev_error; - return n; - } - XFree(prop2); - } - } - XFree(prop); - } - gdk_error_warnings = prev_error; - return None; -} - -static Window -find_wm_window_from_client (GdkWindow *client) -{ - Window window, frame, parent, root; - Window *children; - unsigned int nchildren; - gboolean old_warnings; - - if (!client) - return None; - - frame = None; - window = GDK_WINDOW_XWINDOW (client); - - old_warnings = gdk_error_warnings; - gdk_error_warnings = FALSE; - gdk_error_code = 0; - - while (XQueryTree (GDK_DISPLAY(), window, - &root, &parent, &children, &nchildren) && - (gdk_error_code == 0)) { - - if (children) - XFree(children); - - if (window == root) - break; - - if (root == parent) { - frame = window; - break; - } - window = parent; - } - - gdk_error_warnings = old_warnings; - - return frame; -} - -static gboolean -window_has_wm_state (Window window) -{ - Atom r_type; - int r_format; - unsigned long count; - unsigned long bytes_remain; - unsigned char *prop; - - if (XGetWindowProperty(GDK_DISPLAY(), window, - gdk_atom_intern ("WM_STATE", FALSE), - 0, 0, False, AnyPropertyType, - &r_type, &r_format, - &count, &bytes_remain, &prop) == Success) { - - if (r_type != None) { - XFree(prop); - return TRUE; - } - } - return FALSE; -} - -static gboolean -descendent_has_wm_state (Window window) -{ - gboolean result = FALSE; - Window parent, root; - Window *children; - unsigned int nchildren; - gint i; - - if (!XQueryTree (GDK_DISPLAY(), window, - &root, &parent, &children, &nchildren)) - return FALSE; - - for (i=0; i<nchildren; i++) { - if (window_has_wm_state (children[i]) || - descendent_has_wm_state (children[i])) { - result = TRUE; - break; - } - } - - if (children) - XFree (children); - - return result; -} - -/* This function tries to find a window manager frame by - * hunting all the children of the root window - */ -static Window -find_wm_window_from_hunt (void) -{ - Window parent, root, frame; - Window *children; - unsigned int nchildren; - gboolean old_warnings; - gint i; - - frame = None; - - old_warnings = gdk_error_warnings; - gdk_error_warnings = FALSE; - gdk_error_code = 0; - - XQueryTree (GDK_DISPLAY(), gdk_root_window, - &root, &parent, &children, &nchildren); - - /* We are looking for a window that doesn't have WIN_STATE - * set on it, but does have a child with WIN_STATE set - */ - for (i=0; i<nchildren; i++) { - if (!window_has_wm_state (children[i]) && - descendent_has_wm_state (children[i])) { - frame = children[i]; - break; - } - } - - if (children) - XFree (children); - - gdk_error_warnings = old_warnings; - - return frame; -} - -static Window -find_wm_window (GdkWindow *client) -{ - Window wm_window = None; - - /* First, try to find a GNOME compliant WM */ - - wm_window = find_gnome_wm_window(); - - if (!wm_window) { - wm_window = find_wm_window_from_client (client); - } - - if (!wm_window) { - wm_window = find_wm_window_from_hunt (); - } - - return wm_window; -} - -static gboolean -start_timeout (gpointer data) -{ - RestartInfo *info = data; - if (wm_is_running ()) { - info->callback(WM_SUCCESS, info->data); - gnome_desktop_entry_free (info->dentry); - g_free (info); - return FALSE; - } else { - info->retries--; - if (info->retries > 0) - return TRUE; - else { - info->callback(WM_CANT_START, info->data); - gnome_desktop_entry_free (info->dentry); - g_free (info); - return FALSE; - } - } -} - -static void -start_do (RestartInfo *info) -{ - gnome_desktop_entry_launch (info->dentry); - - info->retries = 10; - gtk_timeout_add (1000, start_timeout, info); -} - -static gboolean -kill_timeout (gpointer data) -{ - RestartInfo *info = data; - if (!wm_is_running ()) { - start_do (info); - return FALSE; - } else { - info->retries--; - if (info->retries > 0) - return TRUE; - else { - info->callback(WM_ALREADY_RUNNING, info->data); - gnome_desktop_entry_free (info->dentry); - g_free (info); - return FALSE; - } - } -} - -void -wm_restart (WindowManager *new, - GdkWindow *client, - WMResultFunc callback, - gpointer data) -{ - Window wm_window; - RestartInfo *info; - - g_return_if_fail (new->is_present); - - info = g_new (RestartInfo, 1); - info->dentry = gnome_desktop_entry_copy (new->dentry); - info->callback = callback; - info->data = data; - info->retries = 10; - - if (wm_is_running ()) { - wm_window = find_wm_window (client); - if (!wm_window) { - (*callback) (WM_ALREADY_RUNNING, data); - gnome_desktop_entry_free (info->dentry); - g_free (info); - } else { - XKillClient (GDK_DISPLAY(), wm_window); - gtk_timeout_add (1000, kill_timeout, info); - } - } else { - start_do (info); - } -} - -WindowManager * -wm_guess_current (void) -{ - return NULL; -} diff --git a/capplets/wm-properties/wm-list.c b/capplets/wm-properties/wm-list.c deleted file mode 100644 index ae3a95804..000000000 --- a/capplets/wm-properties/wm-list.c +++ /dev/null @@ -1,557 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ -/* Copyright (C) 1998 Redhat Software Inc. - * Code available under the Gnu GPL. - * Authors: Owen Taylor <otaylor@redhat.com>, - * Bradford Hovinen <hovinen@helixcode.com> - */ - -#include <sys/types.h> -#include <dirent.h> -#include <unistd.h> -#include <ctype.h> -#include <libgnome/libgnome.h> -#include "wm-properties.h" - -/* Current list of window managers */ -GList *window_managers = NULL; - -/* List on startup */ -static GList *window_managers_save = NULL; - -/* Current window manager */ -static WindowManager *current_wm = NULL; - -/* Window manager on startup */ -static WindowManager *current_wm_save = NULL; - -static gboolean xml_read_bool (xmlNodePtr node); -static xmlNodePtr xml_write_bool (gchar *name, - gboolean value); - -gboolean -is_blank (gchar *str) -{ - while (*str) { - if (!isspace(*str)) - return FALSE; - str++; - } - return TRUE; -} - -static gint -wm_compare (gconstpointer a, gconstpointer b) -{ - const WindowManager *wm_a = (const WindowManager *)a; - const WindowManager *wm_b = (const WindowManager *)b; - - return g_strcasecmp (wm_a->dentry->name, wm_b->dentry->name); -} - -static void -wm_free (WindowManager *wm) -{ - gnome_desktop_entry_free (wm->dentry); - g_free (wm->config_exec); - g_free (wm->config_tryexec);; - g_free (wm); -} - -void -wm_check_present (WindowManager *wm) -{ - gchar *path; - - if (wm->dentry->exec) { - if (wm->dentry->tryexec) { - path = gnome_is_program_in_path (wm->dentry->tryexec); - wm->is_present = (path != NULL); - if (path) - g_free (path); - } else - wm->is_present = TRUE; - } else - wm->is_present = FALSE; - - if (wm->config_exec) { - if (wm->config_tryexec) { - path = gnome_is_program_in_path (wm->config_tryexec); - wm->is_config_present = (path != NULL); - if (path) - g_free (path); - } else { - path = gnome_is_program_in_path (wm->config_exec); - wm->is_config_present = (path != NULL); - if (path) - g_free (path); - } - } else - wm->is_config_present = FALSE; - -} - -static WindowManager * -wm_copy (WindowManager *wm) -{ - WindowManager *result = g_new (WindowManager, 1); - - result->dentry = gnome_desktop_entry_copy (wm->dentry); - result->config_exec = g_strdup (wm->config_exec); - result->config_tryexec = g_strdup (wm->config_tryexec); - - result->session_managed = wm->session_managed; - result->is_user = wm->is_user; - result->is_present = wm->is_present; - result->is_config_present = wm->is_config_present; - - return result; -} - - -static WindowManager * -wm_list_find (GList *list, gchar *name) -{ - GList *tmp_list = list; - while (tmp_list) { - WindowManager *wm = tmp_list->data; - if (strcmp (wm->dentry->name, name) == 0) - return wm; - - tmp_list = tmp_list->next; - } - - return NULL; -} - -static WindowManager * -wm_list_find_exec (GList *list, gchar *name) -{ - GList *tmp_list = list; - while (tmp_list) { - WindowManager *wm = tmp_list->data; - if (!wm->dentry->exec || !wm->dentry->exec[0]) - continue; - if (strcmp (wm->dentry->exec[0], name) == 0) - return wm; - - tmp_list = tmp_list->next; - } - - return NULL; -} - -static GList * -wm_list_find_files (gchar *directory) -{ - DIR *dir; - struct dirent *child; - GList *result = NULL; - gchar *suffix; - - dir = opendir (directory); - if (dir == NULL) - return NULL; - - while ((child = readdir (dir)) != NULL) { - /* Ignore files without .desktop suffix, and ignore - * .desktop files with no prefix - */ - suffix = child->d_name + strlen (child->d_name) - 8; - /* strlen(".desktop") == 8 */ - - if (suffix <= child->d_name || - strcmp (suffix, ".desktop") != 0) - continue; - - result = g_list_prepend (result, - g_concat_dir_and_file (directory, - child->d_name)); - } - closedir (dir); - - return result; -} - -static void -wm_list_read_dir (gchar *directory, gboolean is_user) -{ - WindowManager *wm; - GList *tmp_list; - GList *files; - gchar *prefix; - - files = wm_list_find_files (directory); - - tmp_list = files; - while (tmp_list) { - wm = g_new (WindowManager, 1); - - wm->dentry = gnome_desktop_entry_load_unconditional (tmp_list->data); - if (!wm->dentry) { - g_free (wm); - tmp_list = tmp_list->next; - continue; - } - - prefix = g_strconcat ("=", wm->dentry->location, "=/Window Manager/", NULL); - gnome_config_push_prefix (prefix); - g_free (prefix); - - wm->config_exec = gnome_config_get_string ("ConfigExec"); - wm->config_tryexec = gnome_config_get_string ("ConfigTryExec"); - wm->session_managed = gnome_config_get_bool ("SessionManaged=0"); - wm->is_user = is_user; - - if (wm->config_exec && is_blank (wm->config_exec)) { - g_free (wm->config_exec); - wm->config_exec = NULL; - } - - if (wm->config_tryexec && is_blank (wm->config_tryexec)) { - g_free (wm->config_tryexec); - wm->config_tryexec = NULL; - } - - gnome_config_pop_prefix (); - - wm_check_present (wm); - - if (wm->dentry->name && wm->dentry->exec && - (wm->is_user || wm->is_present)) { - window_managers = - g_list_insert_sorted (window_managers, - wm, - wm_compare); - window_managers_save = - g_list_insert_sorted (window_managers_save, - wm_copy (wm), - wm_compare); - } else { - wm_free (wm); - } - - - tmp_list = tmp_list->next; - } - g_list_free (files); -} - -void -wm_list_init (void) -{ - gchar *tempdir; - gchar *name; - - tempdir = gnome_unconditional_datadir_file ("gnome/wm-properties/"); - wm_list_read_dir (tempdir, FALSE); - g_free (tempdir); - - tempdir = gnome_util_home_file("wm-properties/"); - wm_list_read_dir (tempdir, TRUE); - g_free (tempdir); - - name = gnome_config_get_string ("wm-properties/Config/Config/Current"); - if (name) { - current_wm = wm_list_find (window_managers, name); - g_free (name); - } - - if (!current_wm) { - name = gnome_config_get_string ("default.wm/Default/WM"); - - if (name) { - current_wm = wm_list_find_exec (window_managers, name); - g_free (name); - } - } - - if (!current_wm) { - gchar *wmfile, *prefix; - - wmfile = gnome_unconditional_datadir_file ("default.wm"); - prefix = g_strconcat ("=", wmfile, "=/Default/WM", NULL); - name = gnome_config_get_string (prefix); - - g_free (wmfile); - g_free (prefix); - - if (name) { - current_wm = wm_list_find_exec (window_managers, name); - g_free (name); - } - } - - if (!current_wm && window_managers) - current_wm = window_managers->data; - - if(current_wm) - current_wm_save = wm_list_find (window_managers_save, current_wm->dentry->name); -} - -void -wm_list_save (void) -{ - GList *old_files; - GList *tmp_list; - gchar *tempdir; - gchar *prefix; - WindowManager *wm; - - /* Clean out the current contents of .gnome/wm-desktops - */ - - tempdir = gnome_util_home_file("wm-properties/"); - old_files = wm_list_find_files (tempdir); - g_free (tempdir); - - tmp_list = old_files; - while (tmp_list) { - prefix = g_strconcat ("=", tmp_list->data, "=", NULL); - gnome_config_clean_file (prefix); - gnome_config_sync_file (prefix); - g_free (prefix); - - tmp_list = tmp_list->next; - } - g_list_free (old_files); - - - /* Save the user's desktops - */ - - tmp_list = window_managers; - while (tmp_list) { - wm = tmp_list->data; - - if (wm->is_user) { - gnome_desktop_entry_save (wm->dentry); - - prefix = g_strconcat ("=", wm->dentry->location, "=/Window Manager/", NULL); - gnome_config_push_prefix (prefix); - g_free (prefix); - - if (wm->config_exec) - gnome_config_set_string ("ConfigExec", wm->config_exec); - if (wm->config_tryexec) - gnome_config_set_string ("ConfigTryExec", wm->config_tryexec); - gnome_config_set_bool ("SessionManaged=0", wm->session_managed); - gnome_config_pop_prefix (); - - } - tmp_list = tmp_list->next; - } - - /* Save the current window manager - */ - if(current_wm) - gnome_config_set_string ("wm-properties/Config/Config/Current", - current_wm->dentry->name); - gnome_config_sync (); -} - -void -wm_list_revert (void) -{ - GList *tmp_list; - gchar *old_name = NULL; - - if(current_wm) - old_name = g_strdup (current_wm->dentry->name); - - g_list_foreach (window_managers, (GFunc)wm_free, NULL); - g_list_free (window_managers); - window_managers = NULL; - - tmp_list = window_managers_save; - while (tmp_list) { - window_managers = g_list_prepend (window_managers, - wm_copy (tmp_list->data)); - tmp_list = tmp_list->next; - } - window_managers = g_list_reverse (window_managers); - current_wm = wm_list_find (window_managers, old_name); - g_free (old_name); -} - -void -wm_list_add (WindowManager *wm) -{ - g_return_if_fail (wm != NULL); - - window_managers = g_list_insert_sorted (window_managers, wm, - wm_compare); -} - -void -wm_list_delete (WindowManager *wm) -{ - GList *node; - - g_return_if_fail (wm != NULL); - g_return_if_fail (wm != current_wm); - - node = g_list_find (window_managers, wm); - g_return_if_fail (node != NULL); - - window_managers = g_list_remove_link (window_managers, node); - g_list_free_1 (node); - wm_free (wm); -} - -void -wm_list_set_current (WindowManager *wm) -{ - current_wm = wm; -} - -WindowManager * -wm_list_get_current (void) -{ - return current_wm; -} - -WindowManager * -wm_list_get_revert (void) -{ - if(current_wm_save) - return wm_list_find (window_managers, current_wm_save->dentry->name); - else - return NULL; -} - -static WindowManager * -wm_read_from_xml (xmlNodePtr wm_node) -{ - xmlNodePtr node; - WindowManager *wm; - gboolean is_current = FALSE; - - if (strcmp (wm_node->name, "window-manager")) return NULL; - - wm = g_new0 (WindowManager, 1); - - wm->dentry = gnome_desktop_entry_load_unconditional - (xmlGetProp (wm_node, "desktop-entry")); - - for (node = wm_node->childs; node; node = node->next) { - if (!strcmp (node->name, "config-exec")) - wm->config_exec = xmlNodeGetContent (node); - else if (!strcmp (node->name, "config-tryexec")) - wm->config_tryexec = xmlNodeGetContent (node); - else if (!strcmp (node->name, "session-managed")) - wm->session_managed = xml_read_bool (node); - else if (!strcmp (node->name, "is-user")) - wm->is_user = xml_read_bool (node); - else if (!strcmp (node->name, "is-current")) - is_current = xml_read_bool (node); /* FIXME: sanity check */ - } - - wm_check_present (wm); - - if (wm->dentry == NULL || - (wm->config_exec != NULL && is_blank (wm->config_exec)) || - wm->dentry->name == NULL || wm->dentry->exec == NULL || - !(wm->is_user || wm->is_present)) - { - g_free (wm); - return NULL; - } - - if (is_current) current_wm = wm; - - return wm; -} - -void -wm_list_read_from_xml (xmlDocPtr doc) -{ - xmlNodePtr root_node, node; - WindowManager *wm; - - root_node = xmlDocGetRootElement (doc); - if (strcmp (root_node->name, "wm-prefs")) return; - - for (node = root_node; node; node = node->next) { - if (!strcmp (node->name, "window-manager")) { - wm = wm_read_from_xml (node); - if (wm) window_managers = - g_list_insert_sorted - (window_managers, wm, wm_compare); - } - } -} - -static xmlNodePtr -wm_write_to_xml (WindowManager *wm) -{ - xmlNodePtr node; - - node = xmlNewNode (NULL, "window-manager"); - - xmlNewProp (node, "desktop-entry", wm->dentry->location); - - if (wm->config_exec != NULL) - xmlNewChild (node, NULL, "config-exec", wm->config_exec); - - xmlAddChild (node, xml_write_bool ("session-managed", - wm->session_managed)); - - xmlAddChild (node, xml_write_bool ("is-user", wm->is_user)); - xmlAddChild (node, xml_write_bool ("is-current", wm == current_wm)); - - return node; -} - -xmlDocPtr -wm_list_write_to_xml (void) -{ - xmlDocPtr doc; - xmlNodePtr root_node, node; - GList *wm_node; - - doc = xmlNewDoc ("1.0"); - root_node = xmlNewDocNode (doc, NULL, "wm-prefs", NULL); - - for (wm_node = window_managers; wm_node; wm_node = wm_node->next) { - node = wm_write_to_xml ((WindowManager *) wm_node->data); - if (node) xmlAddChild (root_node, node); - } - - xmlDocSetRootElement (doc, root_node); - - return doc; -} - -/* Read a boolean value from a node */ - -static gboolean -xml_read_bool (xmlNodePtr node) -{ - char *text; - - text = xmlNodeGetContent (node); - - if (!g_strcasecmp (text, "true")) - return TRUE; - else - return FALSE; -} - -/* Write out a boolean value in a node */ - -static xmlNodePtr -xml_write_bool (gchar *name, gboolean value) -{ - xmlNodePtr node; - - g_return_val_if_fail (name != NULL, NULL); - - node = xmlNewNode (NULL, name); - - if (value) - xmlNodeSetContent (node, "true"); - else - xmlNodeSetContent (node, "false"); - - return node; -} diff --git a/capplets/wm-properties/wm-properties-capplet.c b/capplets/wm-properties/wm-properties-capplet.c deleted file mode 100644 index a5d47fa97..000000000 --- a/capplets/wm-properties/wm-properties-capplet.c +++ /dev/null @@ -1,1253 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ -/* Copyright (C) 1998-1999 Redhat Software Inc. - * Code available under the Gnu GPL. - * Authors: Jonathan Blandford <jrb@redhat.com> - * Owen Taylor <otaylor@redhat.com> - */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include <ctype.h> -#include <parser.h> -#include "wm-properties.h" -#include "capplet-widget.h" -#include "gnome.h" - -#ifdef HAVE_XIMIAN_ARCHIVER -# include <ximian-archiver/archive.h> -# include <ximian-archiver/location.h> -#endif /* HAVE_XIMIAN_ARCHIVER */ - -/* prototypes */ -static void restart (gboolean force); -static void try_callback (void); -static void help_callback (void); -static void ok_callback (void); -static void revert_callback (void); -static void cancel_callback (void); - -/* structures */ - -typedef struct { - GtkWidget *dialog; - GtkWidget *name_entry; - GtkWidget *exec_entry; - GtkWidget *config_entry; - GtkWidget *sm_toggle; -} WMDialog; - -/* vars. */ -static GtkWidget *capplet; -static GtkWidget *delete_button; -static GtkWidget *edit_button; -static GtkWidget *config_button; -static GtkWidget *clist; - -static WindowManager *selected_wm = NULL; - -static GtkWidget *restart_dialog = NULL; -static GtkWidget *restart_label = NULL; -guint restart_dialog_timeout; -gchar *restart_name = NULL; - -/* Time until dialog times out */ -gdouble restart_remaining_time; -gint restart_displayed_time; - -GnomeClient *client = NULL; -gchar *argv0; - -/* Enumeration describing the current state of the capplet. - * in any other state than idle, all controls are !sensitive. - */ -typedef enum { - STATE_IDLE, - STATE_TRY, - STATE_REVERT, - STATE_OK, - STATE_CANCEL, - STATE_TRY_REVERT, /* Currently trying, revert afterwards */ - STATE_TRY_CANCEL /* Currently trying, cancel afterwards */ -} StateType; - -/* The possible transitions between states are described below. - * - - * operation | try revert ok cancel finish - * ===========+================================================= - * IDLE | TRY REVERT OK CANCEL - * TRY | TRY_REVERT OK TRY_CANCEL IDLE - * REVERT | CANCEL CANCEL IDLE - * OK | (quit) - * CANCEL | (quit) - * TRY_REVERT | TRY_CANCEL TRY_CANCEL REVERT - * TRY_CANCEL | CANCEL - * - * When a restart fails, there are three cases - * - * (1) The failure was because the current window manager didn't - * die. We inform the user of the situation, and then - * abort the operation. - * - * (2) The window manager didn't start, and we don't have a - * a fallback. We pop up a error dialog, tell the user - * to start a new window manager, and abort the operation. - * - * (3) The window manager didn't start, and we previously had a - * window manager runnning. We pop up a warning dialog, - * then try to go back to the old window manager. - * - * operation | (1) (2) (3) - * ===========+================================================= - * IDLE | - * TRY | IDLE IDLE TRY - * REVERT | IDLE IDLE REVERT - * OK | (quit) (quit) OK - * CANCEL | (quit) (quit) CANCEL - * TRY_REVERT | REVERT REVERT REVERT - * TRY_CANCEL | CANCEL CANCEL CANCEL - */ - - - -/* Current state - */ -StateType state = STATE_IDLE; - -/* Set TRUE when we've exited the main loop, but restart_pending - */ -gboolean quit_pending = FALSE; - -/* Set TRUE when we're waiting for the WM to restart - */ -gboolean restart_pending = FALSE; - -/* Set TRUE while we are filling in the list - */ -gboolean in_fill = FALSE; - -#ifdef HAVE_XIMIAN_ARCHIVER - -static void -store_archive_data (void) -{ - Archive *archive; - Location *location; - xmlDocPtr xml_doc; - - archive = ARCHIVE (archive_load (FALSE)); - location = archive_get_current_location (archive); - xml_doc = wm_list_write_to_xml (); - location_store_xml (location, "wm-properties-capplet", - xml_doc, STORE_MASK_PREVIOUS); - xmlFreeDoc (xml_doc); - archive_close (archive); -} - -#endif /* HAVE_XIMIAN_ARCHIVER */ - -static GtkWidget * -left_aligned_button (gchar *label) -{ - GtkWidget *button = gtk_button_new_with_label (label); - gtk_misc_set_alignment (GTK_MISC (GTK_BIN (button)->child), - 0.0, 0.5); - gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), - GNOME_PAD_SMALL, 0); - - return button; -} -static void -restart_label_update (void) -{ - gchar *tmp; - - if ((gint)restart_remaining_time != restart_displayed_time) { - restart_displayed_time = restart_remaining_time; - - tmp = g_strdup_printf (_("Starting %s\n" - "(%d seconds left before operation times out)"), - restart_name, - restart_displayed_time); - gtk_label_set_text (GTK_LABEL (restart_label), tmp); - g_free (tmp); - } -} - -static gboolean -restart_dialog_raise (gpointer data) -{ - if (restart_dialog && GTK_WIDGET_REALIZED (restart_dialog)) { - restart_remaining_time -= 0.25; - restart_label_update(); - gdk_window_raise (restart_dialog->window); - } - return TRUE; -} - -static void -restart_dialog_destroyed (GtkWidget *widget) -{ - if (restart_dialog_timeout) { - gtk_timeout_remove (restart_dialog_timeout); - restart_dialog_timeout = 0; - } - - restart_dialog = NULL; -} - -static void -show_restart_dialog (gchar *name) -{ - GtkWidget *hbox; - GtkWidget *frame; - GtkWidget *pixmap; - gchar *tmp; - - if (!restart_dialog) { - restart_dialog = gtk_window_new (GTK_WINDOW_POPUP); - gtk_window_set_position (GTK_WINDOW (restart_dialog), - GTK_WIN_POS_CENTER); - - gtk_signal_connect (GTK_OBJECT (restart_dialog), "destroy", - GTK_SIGNAL_FUNC (restart_dialog_destroyed), - &restart_dialog); - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT); - gtk_container_add (GTK_CONTAINER (restart_dialog), frame); - - hbox = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD); - gtk_container_add (GTK_CONTAINER (frame), hbox); - - tmp = gnome_unconditional_pixmap_file("gnome-info.png"); - if (tmp) { - pixmap = gnome_pixmap_new_from_file(tmp); - g_free(tmp); - gtk_box_pack_start (GTK_BOX (hbox), pixmap, FALSE, FALSE, 0); - } - - restart_label = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (hbox), restart_label, FALSE, FALSE, GNOME_PAD); - } - - if (!restart_dialog_timeout) { - restart_dialog_timeout = gtk_timeout_add (250, restart_dialog_raise, NULL); - } - - restart_remaining_time = 10.0; - restart_displayed_time = -1; - if (restart_name) - g_free (restart_name); - - restart_name = g_strdup (name); - restart_label_update (); - - gtk_widget_show_all (restart_dialog); -} - -static void -hide_restart_dialog (void) -{ - if (restart_dialog) - gtk_widget_destroy (restart_dialog); -} - -static void -update_session (void) -{ - WindowManager *current_wm = wm_list_get_current(); - gchar *session_args[3]; - - if (!current_wm) - return; - - if (current_wm->session_managed) { - gnome_client_set_restart_style (client, - GNOME_RESTART_NEVER); - - } else { - session_args[0] = argv0; - session_args[1] = "--init-session-settings"; - session_args[2] = NULL; - /* We use a priority of 15 so that we start after - * session-managed WM's (priority 10), for safety. - */ - gnome_client_set_priority (client, 15); - gnome_client_set_restart_style (client, - GNOME_RESTART_ANYWAY); - gnome_client_set_restart_command (client, 2, - session_args); - } - - gnome_client_flush (client); -} - -static void -init_session (void) -{ - GnomeClientFlags flags; - gint token; - - client = gnome_master_client (); - flags = gnome_client_get_flags (client); - - if (flags & GNOME_CLIENT_IS_CONNECTED) { - token = gnome_startup_acquire_token("GNOME_WM_PROPERTIES", - gnome_client_get_id(client)); - - if (token) - update_session(); - else { - gnome_client_set_restart_style (client, - GNOME_RESTART_NEVER); - gnome_client_flush (client); - } - } -} - -static void -update_gui (void) -{ - GList *tmp_list; - WindowManager *current_wm = wm_list_get_current(); - gint new_row; - gchar *tmpstr; - - gtk_clist_clear (GTK_CLIST (clist)); - - in_fill = TRUE; - - tmp_list = window_managers; - while (tmp_list) { - gchar *row_text; - WindowManager *wm; - - wm = tmp_list->data; - - if (wm == current_wm) { - row_text = g_strdup_printf (_("%s (Current)"), - wm->dentry->name); - - tmpstr = g_strdup_printf (_("Run Configuration Tool for %s"), - wm->dentry->name); - - gtk_label_set_text (GTK_LABEL (GTK_BIN (config_button)->child), - tmpstr); - gtk_widget_set_sensitive (config_button, - wm->is_config_present); - - g_free (tmpstr); - } else if (wm->is_user && !wm->is_present) { - row_text = g_strconcat (wm->dentry->name, - _(" (Not found)"), NULL); - } else { - row_text = g_strdup (wm->dentry->name); - } - - new_row = gtk_clist_append (GTK_CLIST (clist), &row_text); - gtk_clist_set_row_data (GTK_CLIST (clist), new_row, wm); - - if (wm == selected_wm) - gtk_clist_select_row (GTK_CLIST (clist), new_row, 0); - - g_free (row_text); - - tmp_list = tmp_list->next; - } - - in_fill = FALSE; - - if(selected_wm) { - gtk_widget_set_sensitive (edit_button, selected_wm->is_user); - gtk_widget_set_sensitive (delete_button, selected_wm->is_user); - } else { - gtk_widget_set_sensitive (edit_button, FALSE); - gtk_widget_set_sensitive (delete_button, FALSE); - } - - if (current_wm) - gtk_widget_show(config_button); - else - gtk_widget_hide(config_button); -} - -static void -init_callback (WMResult result, gpointer data) -{ - switch (result) { - case WM_SUCCESS: - break; - case WM_ALREADY_RUNNING: - g_warning (_("wm-properties-capplet: Unable to initialize window manager.\n" - "\tAnother window manager is already running and could not be killed\n")); - break; - case WM_CANT_START: - g_warning (_("wm-properties-capplet: Unable to initialize window manager.\n" - "\t'%s' didn't start\n"), (gchar *)data); - break; - } - - g_free (data); - gtk_main_quit (); -} - -static void -restart_finalize () -{ - wm_list_set_current (selected_wm); - hide_restart_dialog(); - - switch (state) { - case STATE_TRY: - case STATE_REVERT: - gtk_widget_set_sensitive (capplet, TRUE); - update_gui(); - state = STATE_IDLE; - break; - - case STATE_OK: - case STATE_CANCEL: - if (quit_pending) - gtk_main_quit(); - break; - default: - g_warning ("Finalize in state %d!!!\n", state); - return; - } - - restart_pending = FALSE; -} - -static void -restart_failure (WMResult reason) -{ - GtkWidget *msgbox; - WindowManager *current_wm; - gchar *msg = NULL; - gboolean modal = FALSE; - - current_wm = wm_list_get_current (); - - /* Did the previous window manager not die? - */ - if (reason == WM_ALREADY_RUNNING) { - msg = g_strdup (_("Previous window manager did not die\n")); - - switch (state) { - case STATE_TRY: - case STATE_REVERT: - case STATE_OK: - case STATE_CANCEL: - selected_wm = current_wm; - restart_finalize (); - break; - - case STATE_TRY_REVERT: - revert_callback (); - break; - - case STATE_TRY_CANCEL: - cancel_callback (); - break; - - default: - g_warning ("Failure in state %d!!!\n", state); - return; - } - } - /* Is there something reasonable to try to fall back to? - */ - else if (current_wm != selected_wm) { - - switch (state) { - case STATE_TRY: - case STATE_REVERT: - case STATE_OK: - case STATE_CANCEL: - msg = g_strdup_printf (_("Could not start '%s'.\n" - "Falling back to previous window manager '%s'\n"), - selected_wm?selected_wm->dentry->name:"Unknown", - current_wm?current_wm->dentry->name:"Unknown"); - selected_wm = current_wm; - restart(TRUE); - break; - - case STATE_TRY_REVERT: - revert_callback (); - break; - - case STATE_TRY_CANCEL: - cancel_callback (); - break; - - default: - g_warning ("Failure in state %d!!!\n", state); - return; - } - - /* Give up */ - } else { - - switch (state) { - case STATE_OK: - case STATE_CANCEL: - modal = TRUE; /* prevent an immediate exit */ - /* Fall through */ - case STATE_TRY: - case STATE_REVERT: - msg = g_strdup (_("Could not start fallback window manager.\n" - "Please run a window manager manually. You can\n" - "do this by selecting \"Run Program\" in the\n" - "foot menu\n")); - - restart_finalize(); - break; - - case STATE_TRY_REVERT: - revert_callback (); - break; - - case STATE_TRY_CANCEL: - cancel_callback (); - break; - - default: - g_warning ("Failure in state %d!!!\n", state); - return; - } - } - - if (msg) { - msgbox = gnome_message_box_new (msg, - GNOME_MESSAGE_BOX_ERROR, - _("OK"), NULL); - if (modal) - gnome_dialog_run (GNOME_DIALOG (msgbox)); - else - gtk_widget_show (msgbox); - g_free (msg); - } -} - -static void -show_restart_info (void) -{ - gchar *save_session; - GtkWidget *dialog; - - save_session = gnome_is_program_in_path ("save-session"); - if (save_session) { - dialog = gnome_message_box_new ( - _("Your current window manager has been changed. In order for\n" - "this change to be saved, you will need to save your current\n" - "session. You can do so immediately by selecting the \"Save session\n" - "now\" below, or you can save your session later. This can be\n" - "done either selecting \"Save Current Session\" under \"Settings\"\n" - "in the main menu, or by turning on \"Save Current Setup\" when\n" - "you log out.\n"), - GNOME_MESSAGE_BOX_INFO, _("Save Session Later"), _("Save Session Now"), NULL); - } else { - dialog = gnome_message_box_new ( - _("Your current window manager has been changed. In order for\n" - "this change to be saved, you will need to save your current\n" - "session. This can be done by either selecting \"Save Current Session\"\n" - "under \"Settings\" in the main menu, or by turning on\n" - "\"Save Current Setup\" when you log out.\n"), - GNOME_MESSAGE_BOX_INFO, GNOME_STOCK_BUTTON_CLOSE, NULL); - } - if ((gnome_dialog_run_and_close (GNOME_DIALOG (dialog)) == 1) && save_session) { - system (save_session); - } - g_free (save_session); -} - -static void -restart_finish (void) -{ - switch (state) { - case STATE_TRY: - case STATE_REVERT: - case STATE_OK: - case STATE_CANCEL: - hide_restart_dialog(); - show_restart_info(); - restart_finalize(); - break; - - case STATE_TRY_REVERT: - revert_callback (); - break; - - case STATE_TRY_CANCEL: - cancel_callback (); - break; - - default: - g_warning ("Finished in state %d!!!\n", state); - return; - } -} - -static void -restart_callback (WMResult result, gpointer data) -{ - if (result == WM_SUCCESS) - restart_finish (); - else - restart_failure (result); -} - -static void -destroy_callback (GtkWidget *widget, void *data) -{ -} - -static void -restart (gboolean force) -{ - WindowManager *current_wm = wm_list_get_current(), *mywm; - static gboolean last_try_was_twm = FALSE; - const char *twm_argv[] = {"twm", NULL}; - const GnomeDesktopEntry twm_dentry = {"twm", "twm", - 1, (char **)twm_argv, NULL, - NULL, NULL, 0, NULL, - NULL, NULL, 0, 0}; - WindowManager twm_fallback = {(GnomeDesktopEntry*)&twm_dentry, "twm", "twm", 0, 0, 1, 0}; - - if(selected_wm) { - last_try_was_twm = FALSE; - mywm = selected_wm; - } else if(!last_try_was_twm) { - last_try_was_twm = TRUE; - mywm = (WindowManager*)&twm_fallback; - } else { - restart_finalize(); - return; - } - - if (force || current_wm != mywm) { - show_restart_dialog (mywm->dentry->name); - if (state != STATE_OK && state != STATE_CANCEL) - gtk_widget_set_sensitive (capplet, FALSE); - restart_pending = TRUE; - wm_restart (mywm, - capplet->window, - restart_callback, - NULL); - } else { - restart_finalize (); - } -} - -static void -try_callback (void) -{ - if (state != STATE_IDLE) { - g_warning ("try_callback in state %d!!!\n", state); - return; - } - - state = STATE_TRY; - restart(FALSE); -} - -static void -help_callback (void) -{ - gchar *tmp; - - tmp = gnome_help_file_find_file ("users-guide", "gccdesktop.html#GCCWM"); - if (tmp) { - gnome_help_goto(0, tmp); - g_free(tmp); - } else { - GtkWidget *mbox; - - mbox = gnome_message_box_new(_("No help is available/installed for these settings. Please make sure you\nhave the GNOME User's Guide installed on your system."), - GNOME_MESSAGE_BOX_ERROR, - _("Close"), NULL); - - gtk_widget_show(mbox); - } -} - -static void -ok_callback (void) -{ - switch (state) { - case STATE_IDLE: - state = STATE_OK; - restart(FALSE); - break; - - case STATE_TRY: - state = STATE_OK; - break; - - case STATE_REVERT: - state = STATE_CANCEL; - break; - - case STATE_TRY_REVERT: - state = STATE_TRY_CANCEL; - break; - - default: - g_warning ("ok callback in state %d!!!\n", state); - return; - } - - wm_list_save (); -#ifdef HAVE_XIMIAN_ARCHIVER - store_archive_data (); -#endif /* HAVE_XIMIAN_ARCHIVER */ -} - -static void -revert_callback (void) -{ - StateType old_state = state; - - switch (state) { - case STATE_IDLE: - case STATE_TRY_REVERT: - wm_list_revert(); - selected_wm = wm_list_get_revert(); - state = STATE_REVERT; - - restart (old_state == STATE_TRY_REVERT); - update_gui(); - - break; - - case STATE_TRY: - state = STATE_TRY_REVERT; - break; - - default: - g_warning ("revert callback in state %d!!!\n", state); - return; - } -} - -static void -cancel_callback (void) -{ - StateType old_state = state; - - switch (state) { - case STATE_IDLE: - case STATE_TRY_CANCEL: - wm_list_revert(); - selected_wm = wm_list_get_revert(); - state = STATE_CANCEL; - - restart (old_state == STATE_TRY_CANCEL); - - break; - - case STATE_TRY: - state = STATE_TRY_CANCEL; - break; - - case STATE_REVERT: - state = STATE_CANCEL; - break; - - case STATE_TRY_REVERT: - state = STATE_TRY_CANCEL; - break; - - default: - g_warning ("ok callback in state %d!!!\n", state); - return; - } -} - -static WMDialog * -create_dialog (gchar *title) -{ - GtkWidget *label; - GtkWidget *alignment; - GtkWidget *table; - WMDialog *dialog; - - dialog = g_new (WMDialog, 1); - - dialog->dialog = gnome_dialog_new (_("Add New Window Manager"), - _("OK"), _("Cancel"), NULL); - - gnome_dialog_set_default (GNOME_DIALOG (dialog->dialog), 0); - gnome_dialog_close_hides (GNOME_DIALOG (dialog->dialog), TRUE); - - table = gtk_table_new (4, 2, FALSE); - - gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL); - gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (GNOME_DIALOG (dialog->dialog)->vbox), - table); - - label = gtk_label_new (_("Name:")); - gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 0, 1, - GTK_FILL, 0, - 0, 0); - - dialog->name_entry = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table), dialog->name_entry, - 1, 2, 0, 1, - GTK_FILL | GTK_EXPAND, 0, - 0, 0); - - label = gtk_label_new (_("Command:")); - gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 1, 2, - GTK_FILL, 0, - 0, 0); - - dialog->exec_entry = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table), dialog->exec_entry, - 1, 2, 1, 2, - GTK_FILL | GTK_EXPAND, 0, - 0, 0); - - label = gtk_label_new (_("Configuration Command:")); - gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 2, 3, - GTK_FILL, 0, - 0, 0); - - dialog->config_entry = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table), dialog->config_entry, - 1, 2, 2, 3, - GTK_FILL | GTK_EXPAND, 0, - 0, 0); - - alignment = gtk_alignment_new (0.0, 0.5, 0.0, 0.0); - gtk_table_attach (GTK_TABLE (table), alignment, - 0, 2, 3, 4, - GTK_FILL | GTK_EXPAND, 0, - 0, 0); - - dialog->sm_toggle = gtk_check_button_new_with_label (_("Window manager is session managed")); - gtk_container_add (GTK_CONTAINER (alignment), dialog->sm_toggle); - - gtk_window_set_default_size (GTK_WINDOW (dialog->dialog), 400, -1); - gtk_window_set_policy (GTK_WINDOW (dialog->dialog), FALSE, TRUE, FALSE); - gtk_widget_show_all (dialog->dialog); - - return dialog; -} - -static gchar * -extract_entry (GtkWidget *widget) -{ - gchar *tmp; - - g_return_val_if_fail (GTK_IS_ENTRY (widget), NULL); - - tmp = gtk_entry_get_text (GTK_ENTRY (widget)); - if (is_blank (tmp)) - return NULL; - else - return g_strdup (tmp); -} - -static gchar * -make_filename (gchar *name) -{ - gchar *tempname = g_strconcat (name, ".desktop", NULL); - gchar *tempdir = gnome_util_home_file("wm-properties/"); - gchar *tmp = tempname; - gchar *result; - - while (*tmp) { - if (isspace (*tmp) || (*tmp == '/')) - *tmp = '_'; - tmp++; - } - result = g_concat_dir_and_file (tempdir, tempname); - g_free (tempname); - g_free (tempdir); - - return result; -} - -static gboolean -check_dialog (WMDialog *dialog) -{ - GtkWidget *msgbox; - - if (is_blank (gtk_entry_get_text (GTK_ENTRY (dialog->name_entry)))) { - msgbox = gnome_message_box_new (_("Name cannot be empty"), - GNOME_MESSAGE_BOX_ERROR, - _("OK"), NULL); - gnome_dialog_run (GNOME_DIALOG (msgbox)); - return FALSE; - } - if (is_blank (gtk_entry_get_text (GTK_ENTRY (dialog->exec_entry)))) { - msgbox = gnome_message_box_new (_("Command cannot be empty"), - GNOME_MESSAGE_BOX_ERROR, - _("OK"), NULL); - gnome_dialog_run (GNOME_DIALOG (msgbox)); - return FALSE; - } - - return TRUE; -} - -static void -get_dialog_contents (WMDialog *dialog, WindowManager *wm) -{ - gchar *tmp; - - if (wm->dentry->name) - g_free (wm->dentry->name); - wm->dentry->name = extract_entry (dialog->name_entry); - - if (wm->dentry->exec) - g_strfreev (wm->dentry->exec); - tmp = extract_entry (dialog->exec_entry); - gnome_config_make_vector (tmp, &wm->dentry->exec_length, - &wm->dentry->exec); - g_free (tmp); - - if (wm->config_exec) - g_free (wm->config_exec); - wm->config_exec = extract_entry (dialog->config_entry); - - if (wm->dentry->location) - g_free (wm->dentry->location); - wm->dentry->location = make_filename (wm->dentry->name); - - wm->session_managed = !!GTK_TOGGLE_BUTTON (dialog->sm_toggle)->active; - - wm_check_present (wm); -} - -static void -edit_dialog (void) -{ - WMDialog *dialog; - gchar *tmp; - gint result; - - if(!selected_wm) - return; - - dialog = create_dialog (_("Edit Window Manager")); - - if (selected_wm->dentry->name) - gtk_entry_set_text (GTK_ENTRY (dialog->name_entry), selected_wm->dentry->name); - - if (selected_wm->dentry->exec) { - tmp = gnome_config_assemble_vector (selected_wm->dentry->exec_length, - (const char **)selected_wm->dentry->exec); - gtk_entry_set_text (GTK_ENTRY (dialog->exec_entry), tmp); - g_free (tmp); - } - - if (selected_wm->config_exec) - gtk_entry_set_text (GTK_ENTRY (dialog->config_entry), selected_wm->config_exec); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->sm_toggle), - selected_wm->session_managed); - - if (!selected_wm->is_user) { - gtk_widget_set_sensitive (dialog->name_entry, FALSE); - gtk_widget_set_sensitive (dialog->exec_entry, FALSE); - gtk_widget_set_sensitive (dialog->config_entry, FALSE); - gtk_widget_set_sensitive (dialog->sm_toggle, FALSE); - } - - do { - gtk_widget_show (dialog->dialog); - result = gnome_dialog_run (GNOME_DIALOG (dialog->dialog)); - } while (result == 0 && !check_dialog (dialog)); - - if (selected_wm->is_user && (result == 0)) { - get_dialog_contents (dialog, selected_wm); - update_gui(); - capplet_widget_state_changed (CAPPLET_WIDGET (capplet), TRUE); - } - - gtk_widget_destroy (dialog->dialog); - g_free (dialog); -} - -static void -add_dialog (void) -{ - WMDialog *dialog = create_dialog (_("Edit Window Manager")); - WindowManager *wm; - gint result; - - do { - result = gnome_dialog_run (GNOME_DIALOG (dialog->dialog)); - } while (result == 0 && !check_dialog (dialog)); - - if (result == 0) { - wm = g_new0 (WindowManager, 1); - wm->dentry = g_new0 (GnomeDesktopEntry, 1); - get_dialog_contents (dialog, wm); - - wm->is_user = TRUE; - - wm_list_add (wm); - - selected_wm = wm; - update_gui(); - - capplet_widget_state_changed (CAPPLET_WIDGET (capplet), TRUE); - } - - gtk_widget_destroy (dialog->dialog); - g_free (dialog); -} - -static void -select_row (GtkCList *the_clist, - gint row, - gint column, - GdkEvent *event, - gpointer data) -{ - WindowManager *wm; - - if (!in_fill) { - wm = gtk_clist_get_row_data (GTK_CLIST (clist), row); - gtk_widget_set_sensitive (edit_button, wm->is_user); - gtk_widget_set_sensitive (delete_button, wm->is_user); - - if (wm != selected_wm) { - selected_wm = wm; - capplet_widget_state_changed (CAPPLET_WIDGET (capplet), TRUE); - } - } -} - -static void -delete (void) -{ - WindowManager *current_wm = wm_list_get_current(); - GtkWidget *msgbox; - - if (current_wm == selected_wm) { - msgbox = gnome_message_box_new ( - _("You cannot delete the current Window Manager"), - GNOME_MESSAGE_BOX_ERROR, _("OK"), NULL); - - gnome_dialog_run (GNOME_DIALOG (msgbox)); - return; - } - - wm_list_delete (selected_wm); - selected_wm = current_wm; - update_gui(); - capplet_widget_state_changed (CAPPLET_WIDGET (capplet), TRUE); -} - - -static void -run_config (GtkWidget *w) -{ - WindowManager *current_wm = wm_list_get_current(); - - if (current_wm - && current_wm->is_config_present - && current_wm->config_exec != NULL) { - gchar *argv[4]; - - argv[0] = "/bin/sh"; - argv[1] = "-c"; - argv[2] = current_wm->config_exec; - argv[3] = NULL; - - gnome_execute_async (NULL, 4, argv); - } -} - -static void -wm_setup (void) -{ - GtkWidget *hbox, *vbox, *bottom; - GtkWidget *util_vbox; - GtkWidget *add_button; - GtkWidget *scrolled_window; - GtkWidget *label; - - capplet = capplet_widget_new (); - gtk_widget_set_usize (capplet, 360, 200); - - vbox = gtk_vbox_new (FALSE, 0); - - label = gtk_label_new (_("Window Manager Selector")); - gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, FALSE, 10); - - hbox = gtk_hbox_new (FALSE, GNOME_PAD); - - gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL); - bottom = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_container_set_border_width (GTK_CONTAINER (bottom), GNOME_PAD_SMALL); - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - clist = gtk_clist_new (1); - gtk_clist_column_titles_hide (GTK_CLIST (clist)); - gtk_clist_set_column_auto_resize (GTK_CLIST (clist), 0, TRUE); - gtk_clist_set_selection_mode (GTK_CLIST (clist), GTK_SELECTION_BROWSE); - - gtk_signal_connect (GTK_OBJECT (clist), "select_row", - GTK_SIGNAL_FUNC (select_row), NULL); - - gtk_container_add (GTK_CONTAINER (scrolled_window), clist); - - gtk_box_pack_start (GTK_BOX (hbox), scrolled_window, TRUE, TRUE, 0); - - util_vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox), util_vbox, FALSE, FALSE, 0); - - add_button = left_aligned_button (_("Add...")); - gtk_signal_connect (GTK_OBJECT (add_button), "clicked", - GTK_SIGNAL_FUNC (add_dialog), NULL); - gtk_box_pack_start (GTK_BOX (util_vbox), add_button, FALSE, FALSE, 0); - - edit_button = left_aligned_button (_("Edit...")); - gtk_signal_connect (GTK_OBJECT (edit_button), "clicked", - GTK_SIGNAL_FUNC (edit_dialog), NULL); - gtk_box_pack_start (GTK_BOX (util_vbox), edit_button, FALSE, FALSE, 0); - - delete_button = left_aligned_button (_("Delete")); - gtk_signal_connect (GTK_OBJECT (delete_button), "clicked", - GTK_SIGNAL_FUNC (delete), NULL); - gtk_box_pack_start (GTK_BOX (util_vbox), delete_button, FALSE, FALSE, 0); - config_button = gtk_button_new_with_label (""); - - gtk_misc_set_padding (GTK_MISC (GTK_BIN (config_button)->child), - GNOME_PAD_SMALL, 0); - gtk_signal_connect (GTK_OBJECT (config_button), "clicked", - GTK_SIGNAL_FUNC (run_config), NULL); - gtk_box_pack_start (GTK_BOX (bottom), config_button, FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); - gtk_box_pack_end (GTK_BOX (vbox), bottom, FALSE, FALSE, 0); - - gtk_container_add (GTK_CONTAINER (capplet), vbox); - - gtk_widget_show_all (capplet); - - update_gui(); -} - -static void do_get_xml (void) -{ - xmlDocPtr doc; - - doc = wm_list_write_to_xml (); - xmlDocDump (stdout, doc); -} - -static void do_set_xml (void) -{ - xmlDocPtr doc; - char *buffer; - int len = 0; - - while (!feof (stdin)) { - if (!len) buffer = g_new (char, 16384); - else buffer = g_renew (char, buffer, len + 16384); - fread (buffer + len, 1, 16384, stdin); - len += 16384; - } - - doc = xmlParseMemory (buffer, strlen (buffer)); - - init_session (); - wm_list_read_from_xml (doc); - wm_list_save (); - update_session (); -} - -int -main (int argc, char **argv) -{ - gint init_results; - - bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE); - - argv0 = g_strdup (argv[0]); - init_results = gnome_capplet_init("wm-properties", VERSION, - argc, argv, NULL, 0, NULL); - - if (init_results < 0) { - g_warning (_("an initialization error occurred while " - "starting 'wm-properties-capplet'.\n" - "aborting...\n")); - exit (1); - } - - /* Read in the list of window managers, and the current - * window manager - */ - wm_list_init(); - selected_wm = wm_list_get_current(); - - if (init_results == 0) { - init_session(); - wm_setup(); - gtk_signal_connect(GTK_OBJECT(capplet), "destroy", - GTK_SIGNAL_FUNC(destroy_callback), NULL); - gtk_signal_connect (GTK_OBJECT (capplet), "help", - GTK_SIGNAL_FUNC (help_callback), NULL); - gtk_signal_connect (GTK_OBJECT (capplet), "try", - GTK_SIGNAL_FUNC (try_callback), NULL); - gtk_signal_connect (GTK_OBJECT (capplet), "revert", - GTK_SIGNAL_FUNC (revert_callback), NULL); - gtk_signal_connect (GTK_OBJECT (capplet), "cancel", - GTK_SIGNAL_FUNC (cancel_callback), NULL); - gtk_signal_connect (GTK_OBJECT (capplet), "ok", - GTK_SIGNAL_FUNC (ok_callback), NULL); - - capplet_gtk_main (); - - if (restart_pending) { - quit_pending = TRUE; - gtk_main(); - } - - if (state == STATE_OK) { - wm_list_save (); - update_session (); - } - - } - else if (init_results == 3) { - do_get_xml (); - } - else if (init_results == 4) { - do_set_xml (); - } - else { - if (selected_wm && - !selected_wm->session_managed && - !wm_is_running()) { - - wm_restart (selected_wm, NULL, init_callback, - g_strdup (selected_wm->dentry->name)); - gtk_main (); - } - - init_session(); - } - - return 0; -} - diff --git a/capplets/wm-properties/wm-properties.glade b/capplets/wm-properties/wm-properties.glade deleted file mode 100644 index e69de29bb..000000000 --- a/capplets/wm-properties/wm-properties.glade +++ /dev/null diff --git a/capplets/wm-properties/wm-properties.h b/capplets/wm-properties/wm-properties.h deleted file mode 100644 index 9092d8ca7..000000000 --- a/capplets/wm-properties/wm-properties.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ -/* Copyright (C) 1998 Redhat Software Inc. - * Code available under the Gnu GPL. - * Authors: Owen Taylor <otaylor@redhat.com>, - * Bradford Hovinen <hovinen@helixcode.com> - */ - -#include <gdk/gdk.h> -#include <libgnome/libgnome.h> - -#include <tree.h> - -typedef struct _WindowManager WindowManager; - -struct _WindowManager { - GnomeDesktopEntry *dentry; - gchar *config_exec; - gchar *config_tryexec; - gboolean session_managed : 1; - gboolean is_user : 1; - gboolean is_present : 1; - gboolean is_config_present : 1; -}; - -/* Utility functions */ -gboolean is_blank (gchar *str); - -/* Fill in the is_present and is_config_present fields */ -void wm_check_present (WindowManager *wm); - -/* Management of window manager list */ - -void wm_list_init (void); -void wm_list_save (void); -void wm_list_revert (void); -void wm_list_add (WindowManager *window_manager); -void wm_list_delete (WindowManager *window_manager); -void wm_list_set_current (WindowManager *window_manager); -WindowManager *wm_list_get_current (void); -WindowManager *wm_list_get_revert (void); - -void wm_list_read_from_xml (xmlDocPtr doc); -xmlDocPtr wm_list_write_to_xml (void); - -extern GList *window_managers; - -/* Management of current window manager */ - -typedef enum { - WM_SUCCESS, - WM_ALREADY_RUNNING, - WM_CANT_START -} WMResult; - -typedef void (*WMResultFunc) (WMResult result, gpointer data); - -void wm_restart (WindowManager *new, - GdkWindow *client, - WMResultFunc callback, - gpointer data); -gboolean wm_is_running (void); -WindowManager *wm_guess_current (void); diff --git a/capplets/wm-properties/wm.desktop.in.in b/capplets/wm-properties/wm.desktop.in.in deleted file mode 100644 index e4268c52b..000000000 --- a/capplets/wm-properties/wm.desktop.in.in +++ /dev/null @@ -1,61 +0,0 @@ -[Desktop Entry] -Name=Window Manager Selector -Name[pt_BR]=Gerenciador de Janelas -Name[ca]=Gestor de finestres -Name[cs]=Správce oken -Name[da]=Vindueshåndtering -Name[de]=Fenstermanager -Name[el]=Äéá÷åéñéóôÞò Ðáñáèýñùí -Name[es]=Gestor de ventanas -Name[et]=Aknahaldur -Name[fi]=Ikkunointiohjelma -Name[fr]=Gestionnaire de fenêtres -Name[gl]=Xestor de fiestras -Name[hu]=Ablakkezelõ -Name[it]=Window manager -Name[ja]=¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã -Name[ko]=â °ü¸®ÀÚ -Name[lt]=Langø tvarkyklë -Name[no]=Vindushåndterer -Name[pl]=Mened¿er okien -Name[pt]=Gestor de Janelas -Name[ro]=Manager de ferestre -Name[sl]=Upravljalnik oken -Name[sv]=Fönsterhanterare -Name[tr]=Pencere yöneticisi -Name[uk]=÷¦ËÏÎÎÉÊ ÍÅÎÅÄÖÅÒ -Name[wa]=Manaedjeu di purneas -Name[zh_TW]=µøµ¡ºÞ²zµ{¦¡ -Name[zh_CN.GB2312]=ÊÓ´°¹ÜÀí³Ìʽ -Comment=Choose a window manager -Comment[pt_BR]=Selecionar um gerenciador de janelas -Comment[ca]=Permet escollir el gestor de finestres. -Comment[cs]=Volba správce oken -Comment[da]=Vælg en vindueshåndterer. -Comment[de]=Einen Fenstermanager auswählen -Comment[es]=ÅðéëïãÞ äéá÷åéñéóôÞò ðáñáèýñùí -Comment[es]=Permite elegir gestor de ventanas a usar con GNOME -Comment[et]=Määrab aknahalduri -Comment[fi]=Valitse ikkunointiohjelma -Comment[fr]=Configuration du gestionnaire de fenêtres à utiliser avec GNOME -Comment[gl]=Excoller un xestor de fiestras para usar con GNOME -Comment[hu]=Ablakkezelõ választása -Comment[it]=Selezione del Window Manager usato in GNOME -Comment[ja]=¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¤òÁª¤ó¤Ç²¼¤µ¤¤ -Comment[ko]=â °ü¸®ÀÚ ¼±Åà -Comment[lt]=Pasirinkti langø tvarkyklæ -Comment[no]=Velg en vindushåndterer -Comment[pl]=Wybór mened¿era okien -Comment[pt]=Escolha o seu gestor de janelas -Comment[ro]=Alegeþi un manager de ferestre -Comment[sl]=Izberite upravljalca oken -Comment[sv]=Välj en fönsterhanterare -Comment[tr]=Bir pencere yöneticisini seç -Comment[uk]=÷ÉÂ¦Ò ×¦ËÏÎÎÏÇÏ ÍÅÎÅÄÖÅÒÁ -Comment[wa]=Tchwezixhoz li manaedjeu di purneas a eployî avou GNOME -Comment[zh_TW]=¿ï¾Ü±z©Ò¨Ï¥Îªºµøµ¡ºÞ²zµ{¦¡ -Comment[zh_CN.GB2312]=Ñ¡ÔñÄúËùʹÓõÄÊÓ´°¹ÜÀí³Ìʽ -Exec=wm-properties-capplet --sync -Icon=gnome-ccwindowmanager.png -Terminal=0 -Type=Application |