New file. Really saves now. Doesn't notice when a new metatheme is added,
Fri Dec 6 16:54:14 2002 Jonathan Blandford <jrb@redhat.com> * gnome-theme-save-data.c: New file. Really saves now. Doesn't notice when a new metatheme is added, though. Fri Dec 6 16:13:54 2002 Jonathan Blandford <jrb@redhat.com> * gnome-theme-info.c (top_theme_dir_changed_callback): I know C. Really, I do.
This commit is contained in:
parent
0be934661d
commit
628bc1ce2c
8 changed files with 133 additions and 22 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Fri Dec 6 16:13:54 2002 Jonathan Blandford <jrb@redhat.com>
|
||||||
|
|
||||||
|
* gnome-theme-info.c (top_theme_dir_changed_callback): I know C.
|
||||||
|
Really, I do.
|
||||||
|
|
||||||
2002-11-23 Jody Goldberg <jody@gnome.org>
|
2002-11-23 Jody Goldberg <jody@gnome.org>
|
||||||
|
|
||||||
* Release 2.1.3
|
* Release 2.1.3
|
||||||
|
|
|
@ -210,6 +210,7 @@ update_theme_dir (const gchar *theme_dir)
|
||||||
{
|
{
|
||||||
GList *list;
|
GList *list;
|
||||||
|
|
||||||
|
g_print ("changed!\n");
|
||||||
for (list = callbacks; list; list = list->next)
|
for (list = callbacks; list; list = list->next)
|
||||||
{
|
{
|
||||||
ThemeCallbackData *callback_data = list->data;
|
ThemeCallbackData *callback_data = list->data;
|
||||||
|
@ -217,6 +218,10 @@ update_theme_dir (const gchar *theme_dir)
|
||||||
(* callback_data->func) ((gpointer)theme_dir, callback_data->data);
|
(* callback_data->func) ((gpointer)theme_dir, callback_data->data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_print ("no change!\n");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +267,11 @@ top_theme_dir_changed_callback (GnomeVFSMonitorHandle *handle,
|
||||||
GnomeVFSMonitorEventType event_type,
|
GnomeVFSMonitorEventType event_type,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GFreeFunc *func = user_data;
|
typedef void (*ThemeChangedFunc) (const gchar *uri);
|
||||||
|
ThemeChangedFunc func;
|
||||||
|
|
||||||
|
|
||||||
|
func = user_data;
|
||||||
|
|
||||||
switch (event_type)
|
switch (event_type)
|
||||||
{
|
{
|
||||||
|
@ -270,9 +279,13 @@ top_theme_dir_changed_callback (GnomeVFSMonitorHandle *handle,
|
||||||
case GNOME_VFS_MONITOR_EVENT_CREATED:
|
case GNOME_VFS_MONITOR_EVENT_CREATED:
|
||||||
case GNOME_VFS_MONITOR_EVENT_DELETED:
|
case GNOME_VFS_MONITOR_EVENT_DELETED:
|
||||||
if (!strncmp (info_uri, "file://", strlen ("file://")))
|
if (!strncmp (info_uri, "file://", strlen ("file://")))
|
||||||
(*func) ((char *)info_uri + strlen ("file://"));
|
{
|
||||||
|
func (info_uri + strlen ("file://"));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
(*func) ((char *)info_uri);
|
{
|
||||||
|
func (info_uri);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
Fri Dec 6 16:54:14 2002 Jonathan Blandford <jrb@redhat.com>
|
||||||
|
|
||||||
|
* gnome-theme-save-data.c: New file. Really saves now. Doesn't
|
||||||
|
notice when a new metatheme is added, though.
|
||||||
|
|
||||||
Tue Dec 3 20:45:17 2002 Jonathan Blandford <jrb@redhat.com>
|
Tue Dec 3 20:45:17 2002 Jonathan Blandford <jrb@redhat.com>
|
||||||
|
|
||||||
* gnome-theme-save.c: Add saving support. Almost to a working
|
* gnome-theme-save.c: Add saving support. Almost to a working
|
||||||
|
|
|
@ -502,7 +502,7 @@ gnome_theme_details_update_from_gconf (void)
|
||||||
gnome_window_manager_get_settings (window_manager, &wm_settings);
|
gnome_window_manager_get_settings (window_manager, &wm_settings);
|
||||||
update_list_something (tree_view, wm_settings.theme);
|
update_list_something (tree_view, wm_settings.theme);
|
||||||
|
|
||||||
tree_view = WID ("window_theme_treeview");
|
tree_view = WID ("icon_theme_treeview");
|
||||||
theme = gconf_client_get_string (client, ICON_THEME_KEY, NULL);
|
theme = gconf_client_get_string (client, ICON_THEME_KEY, NULL);
|
||||||
update_list_something (tree_view, theme);
|
update_list_something (tree_view, theme);
|
||||||
g_free (theme);
|
g_free (theme);
|
||||||
|
|
|
@ -288,13 +288,9 @@ meta_theme_setup_info (GnomeThemeMetaInfo *meta_theme_info,
|
||||||
GladeXML *dialog)
|
GladeXML *dialog)
|
||||||
{
|
{
|
||||||
GtkWidget *notebook;
|
GtkWidget *notebook;
|
||||||
GtkWidget *toggle;
|
|
||||||
|
|
||||||
notebook = WID ("meta_theme_notebook");
|
notebook = WID ("meta_theme_notebook");
|
||||||
|
|
||||||
/* Undo all signals */
|
|
||||||
toggle = WID ("meta_theme_font1_toggle");
|
|
||||||
|
|
||||||
if (meta_theme_info == NULL)
|
if (meta_theme_info == NULL)
|
||||||
{
|
{
|
||||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 0);
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 0);
|
||||||
|
@ -703,6 +699,7 @@ theme_changed_func (gpointer uri,
|
||||||
|
|
||||||
dialog = gnome_theme_manager_get_theme_dialog ();
|
dialog = gnome_theme_manager_get_theme_dialog ();
|
||||||
|
|
||||||
|
g_print ("theme_changed_func:\n");
|
||||||
update_themes_from_disk ((GladeXML *)user_data);
|
update_themes_from_disk ((GladeXML *)user_data);
|
||||||
gnome_theme_details_reread_themes_from_disk ();
|
gnome_theme_details_reread_themes_from_disk ();
|
||||||
gtk_widget_grab_focus (WID ("meta_theme_treeview"));
|
gtk_widget_grab_focus (WID ("meta_theme_treeview"));
|
||||||
|
|
9
capplets/theme-switcher/gnome-theme-save-data.c
Normal file
9
capplets/theme-switcher/gnome-theme-save-data.c
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
static const gchar *theme_header =
|
||||||
|
"[Desktop Entry]\n\
|
||||||
|
Name=%s\n\
|
||||||
|
Type=X-GNOME-Metatheme\n\
|
||||||
|
Comment=%s\n\
|
||||||
|
Encoding=UTF-8\n\
|
||||||
|
\n\
|
||||||
|
[X-GNOME-Metatheme]\n\
|
||||||
|
";
|
|
@ -2,7 +2,9 @@
|
||||||
#include "gnome-theme-save.h"
|
#include "gnome-theme-save.h"
|
||||||
#include "gnome-theme-manager.h"
|
#include "gnome-theme-manager.h"
|
||||||
#include "capplet-util.h"
|
#include "capplet-util.h"
|
||||||
|
#include <libgnomevfs/gnome-vfs-ops.h>
|
||||||
|
|
||||||
|
#include "gnome-theme-save-data.c"
|
||||||
|
|
||||||
static GQuark error_quark;
|
static GQuark error_quark;
|
||||||
enum
|
enum
|
||||||
|
@ -12,8 +14,7 @@ enum
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
save_theme_to_disk (GnomeThemeMetaInfo *meta_theme_info,
|
check_theme_name (const gchar *theme_name,
|
||||||
const gchar *theme_name,
|
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
if (theme_name == NULL)
|
if (theme_name == NULL)
|
||||||
|
@ -21,11 +22,101 @@ save_theme_to_disk (GnomeThemeMetaInfo *meta_theme_info,
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
error_quark,
|
error_quark,
|
||||||
INVALID_THEME_NAME,
|
INVALID_THEME_NAME,
|
||||||
"ff");
|
_("Theme name must be present"));
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
setup_directory_structure (const gchar *theme_name,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
gchar *dir;
|
||||||
|
GnomeVFSURI *uri;
|
||||||
|
|
||||||
|
dir = g_build_filename (g_get_home_dir (), ".themes", NULL);
|
||||||
|
uri = gnome_vfs_uri_new (dir);
|
||||||
|
if (!gnome_vfs_uri_exists (uri))
|
||||||
|
gnome_vfs_make_directory_for_uri (uri, 0775);
|
||||||
|
gnome_vfs_uri_unref (uri);
|
||||||
|
g_free (dir);
|
||||||
|
|
||||||
|
dir = g_build_filename (g_get_home_dir (), ".themes", theme_name, NULL);
|
||||||
|
uri = gnome_vfs_uri_new (dir);
|
||||||
|
if (!gnome_vfs_uri_exists (uri))
|
||||||
|
gnome_vfs_make_directory_for_uri (uri, 0775);
|
||||||
|
gnome_vfs_uri_unref (uri);
|
||||||
|
g_free (dir);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
write_theme_to_disk (GnomeThemeMetaInfo *meta_theme_info,
|
||||||
|
const gchar *theme_name,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
gchar *dir;
|
||||||
|
GnomeVFSURI *uri;
|
||||||
|
GnomeVFSURI *target_uri;
|
||||||
|
GnomeVFSHandle *handle = NULL;
|
||||||
|
GnomeVFSFileSize bytes_written;
|
||||||
|
gchar *str;
|
||||||
|
|
||||||
|
dir = g_build_filename (g_get_home_dir (), ".themes", theme_name, "index.theme~", NULL);
|
||||||
|
uri = gnome_vfs_uri_new (dir);
|
||||||
|
dir [strlen (dir) - 1] = '\000';
|
||||||
|
target_uri = gnome_vfs_uri_new (dir);
|
||||||
|
g_free (dir);
|
||||||
|
gnome_vfs_create_uri (&handle, uri, GNOME_VFS_OPEN_READ | GNOME_VFS_OPEN_WRITE, FALSE, 0644);
|
||||||
|
|
||||||
|
gnome_vfs_truncate_handle (handle, 0);
|
||||||
|
|
||||||
|
/* start making the theme file */
|
||||||
|
str = g_strdup_printf (theme_header, theme_name, theme_name);
|
||||||
|
gnome_vfs_write (handle, str, strlen (str), &bytes_written);
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
|
str = g_strdup_printf ("GtkTheme=%s\n", meta_theme_info->gtk_theme_name);
|
||||||
|
gnome_vfs_write (handle, str, strlen (str), &bytes_written);
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
|
str = g_strdup_printf ("MetacityTheme=%s\n", meta_theme_info->metacity_theme_name);
|
||||||
|
gnome_vfs_write (handle, str, strlen (str), &bytes_written);
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
|
str = g_strdup_printf ("IconTheme=%s\n", meta_theme_info->icon_theme_name);
|
||||||
|
gnome_vfs_write (handle, str, strlen (str), &bytes_written);
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
|
gnome_vfs_close (handle);
|
||||||
|
|
||||||
|
|
||||||
|
gnome_vfs_move_uri (uri, target_uri, TRUE);
|
||||||
|
gnome_vfs_uri_unref (uri);
|
||||||
|
gnome_vfs_uri_unref (target_uri);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
save_theme_to_disk (GnomeThemeMetaInfo *meta_theme_info,
|
||||||
|
const gchar *theme_name,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
if (! check_theme_name (theme_name, error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (! setup_directory_structure (theme_name, error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (! write_theme_to_disk (meta_theme_info, theme_name, error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
save_dialog_response (GtkWidget *save_dialog,
|
save_dialog_response (GtkWidget *save_dialog,
|
||||||
gint response_id,
|
gint response_id,
|
||||||
|
@ -44,7 +135,7 @@ save_dialog_response (GtkWidget *save_dialog,
|
||||||
entry = WID ("save_dialog_entry");
|
entry = WID ("save_dialog_entry");
|
||||||
|
|
||||||
theme_name = gtk_entry_get_text (GTK_ENTRY (entry));
|
theme_name = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||||
meta_theme_info = (GnomeThemeMetaInfo *) g_object_get_data (G_OBJECT (save_dialog), "meta_theme_info");
|
meta_theme_info = (GnomeThemeMetaInfo *) g_object_get_data (G_OBJECT (save_dialog), "meta-theme-info");
|
||||||
if (! save_theme_to_disk (meta_theme_info, theme_name, &error))
|
if (! save_theme_to_disk (meta_theme_info, theme_name, &error))
|
||||||
{
|
{
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
@ -114,7 +114,6 @@
|
||||||
<widget class="GtkButton" id="meta_theme_details_button">
|
<widget class="GtkButton" id="meta_theme_details_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label" translatable="yes">_Details...</property>
|
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
|
|
||||||
|
@ -160,7 +159,6 @@
|
||||||
<widget class="GtkButton" id="meta_theme_install_button">
|
<widget class="GtkButton" id="meta_theme_install_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label" translatable="yes">_Install theme...</property>
|
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
|
|
||||||
|
@ -201,7 +199,6 @@
|
||||||
<widget class="GtkButton" id="meta_theme_save_button">
|
<widget class="GtkButton" id="meta_theme_save_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label" translatable="yes">_Save theme</property>
|
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
|
|
||||||
|
@ -709,7 +706,6 @@ font and background</property>
|
||||||
<widget class="GtkButton" id="control_install_button">
|
<widget class="GtkButton" id="control_install_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label" translatable="yes">_Install theme...</property>
|
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
|
|
||||||
|
@ -740,7 +736,6 @@ font and background</property>
|
||||||
<widget class="GtkButton" id="control_manage_button">
|
<widget class="GtkButton" id="control_manage_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label" translatable="yes">_Go to theme folder</property>
|
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
|
|
||||||
|
@ -907,7 +902,6 @@ font and background</property>
|
||||||
<widget class="GtkButton" id="window_install_button">
|
<widget class="GtkButton" id="window_install_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label" translatable="yes">_Install theme...</property>
|
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
|
|
||||||
|
@ -938,7 +932,6 @@ font and background</property>
|
||||||
<widget class="GtkButton" id="window_manage_button">
|
<widget class="GtkButton" id="window_manage_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label" translatable="yes">_Go to theme folder</property>
|
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
|
|
||||||
|
@ -1105,7 +1098,6 @@ font and background</property>
|
||||||
<widget class="GtkButton" id="icon_install_button">
|
<widget class="GtkButton" id="icon_install_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label" translatable="yes">_Install theme...</property>
|
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
|
|
||||||
|
@ -1136,7 +1128,6 @@ font and background</property>
|
||||||
<widget class="GtkButton" id="icon_manage_button">
|
<widget class="GtkButton" id="icon_manage_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label" translatable="yes">_Go to theme folder</property>
|
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue