Add some code for a new appearance capplet
2007-04-30 Thomas Wood <thos@gnome.org> * capplets/appearance/Makefile.am: * capplets/appearance/appearance-main.c: * capplets/appearance/appearance-themes.c: * capplets/appearance/appearance-themes.h: * capplets/appearance/appearance.glade: * capplets/appearance/appearance.h: Add some code for a new appearance capplet svn path=/trunk/; revision=7518
This commit is contained in:
parent
a8006b9315
commit
b98e469088
7 changed files with 1822 additions and 0 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2007-04-30 Thomas Wood <thos@gnome.org>
|
||||
|
||||
* capplets/appearance/Makefile.am:
|
||||
* capplets/appearance/appearance-main.c:
|
||||
* capplets/appearance/appearance-themes.c:
|
||||
* capplets/appearance/appearance-themes.h:
|
||||
* capplets/appearance/appearance.glade:
|
||||
* capplets/appearance/appearance.h:
|
||||
|
||||
Add some code for a new appearance capplet
|
||||
|
||||
2007-04-25 Jens Granseuer <jensgr@gmx.net>
|
||||
|
||||
* configure.in:
|
||||
|
|
26
capplets/appearance/Makefile.am
Normal file
26
capplets/appearance/Makefile.am
Normal file
|
@ -0,0 +1,26 @@
|
|||
bin_PROGRAMS=gnome-appearance-properties
|
||||
|
||||
gnome_appearance_properties_SOURCES= \
|
||||
appearance.h \
|
||||
appearance-main.c \
|
||||
appearance-themes.c \
|
||||
appearance-themes.h
|
||||
|
||||
gnome_appearance_properties_LDADD = \
|
||||
$(GNOMECC_CAPPLETS_LIBS) \
|
||||
$(METACITY_LIBS) \
|
||||
$(top_builddir)/libwindow-settings/libgnome-window-settings.la \
|
||||
$(top_builddir)/capplets/common/libcommon.la
|
||||
|
||||
gladedir = $(pkgdatadir)/glade
|
||||
glade_DATA = appearance.glade
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
$(METACITY_CFLAGS) \
|
||||
$(GNOMECC_CAPPLETS_CFLAGS) \
|
||||
-DGLADEDIR=\""$(gladedir)"\" \
|
||||
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
|
||||
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\""
|
||||
|
||||
EXTRA_DIST = $(glade_DATA)
|
57
capplets/appearance/appearance-main.c
Normal file
57
capplets/appearance/appearance-main.c
Normal file
|
@ -0,0 +1,57 @@
|
|||
#include "appearance.h"
|
||||
#include "appearance-themes.h"
|
||||
#include "theme-thumbnail.h"
|
||||
#include "activate-settings-daemon.h"
|
||||
|
||||
/* required for gnome_program_init(): */
|
||||
#include <libgnome/libgnome.h>
|
||||
#include <libgnomeui/gnome-ui-init.h>
|
||||
/* ---------------------------------- */
|
||||
|
||||
#define VERSION "0.0"
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
AppearanceData *data;
|
||||
GtkWidget *w;
|
||||
GnomeProgram *program;
|
||||
|
||||
/* init */
|
||||
theme_thumbnail_factory_init (argc, argv);
|
||||
gtk_init (&argc, &argv);
|
||||
gnome_vfs_init ();
|
||||
activate_settings_daemon ();
|
||||
|
||||
/* set up the data */
|
||||
data = g_new0 (AppearanceData, 1);
|
||||
data->xml = glade_xml_new (GLADEDIR "appearance.glade", NULL, NULL);
|
||||
data->argc = argc;
|
||||
data->argv = argv;
|
||||
|
||||
/* this appears to be required for gnome_wm_manager_init (), which is called
|
||||
* inside gnome_meta_theme_set ();
|
||||
* TODO: try to remove if possible
|
||||
*/
|
||||
program = gnome_program_init ("appearance", VERSION,
|
||||
LIBGNOMEUI_MODULE, argc, argv,
|
||||
GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
|
||||
NULL);
|
||||
|
||||
/* init tabs */
|
||||
themes_init (data);
|
||||
|
||||
w = WID ("appearance_window");
|
||||
gtk_widget_show_all (w);
|
||||
g_signal_connect (G_OBJECT (w), "delete-event", (GCallback) gtk_main_quit, NULL);
|
||||
|
||||
|
||||
gtk_main ();
|
||||
|
||||
|
||||
|
||||
/* free stuff */
|
||||
g_free (data);
|
||||
|
||||
return 0;
|
||||
}
|
112
capplets/appearance/appearance-themes.c
Normal file
112
capplets/appearance/appearance-themes.c
Normal file
|
@ -0,0 +1,112 @@
|
|||
#include "appearance.h"
|
||||
#include "gnome-theme-info.h"
|
||||
#include "theme-thumbnail.h"
|
||||
#include "gnome-theme-apply.h"
|
||||
#include <libwindow-settings/gnome-wm-manager.h>
|
||||
|
||||
enum {
|
||||
THEME_NAME_COLUMN,
|
||||
THEME_PIXBUF_COLUMN,
|
||||
};
|
||||
|
||||
/* Theme functions */
|
||||
void theme_changed_func (gpointer uri, AppearanceData *data);
|
||||
|
||||
/* GUI Callbacks */
|
||||
void theme_save_cb (GtkWidget *button, AppearanceData *data);
|
||||
void theme_open_cb (GtkWidget *button, AppearanceData *data);
|
||||
void theme_delete_cb (GtkWidget *button, AppearanceData *data);
|
||||
void theme_activated_cb (GtkWidget *icon_view, GtkTreePath *path, AppearanceData *data);
|
||||
|
||||
void
|
||||
themes_init (AppearanceData *data)
|
||||
{
|
||||
GtkWidget *w;
|
||||
GList *theme_list, *l;
|
||||
GtkListStore *theme_store;
|
||||
|
||||
/* initialise some stuff */
|
||||
gnome_theme_init (NULL);
|
||||
gnome_wm_manager_init ();
|
||||
|
||||
/* connect button signals */
|
||||
g_signal_connect (G_OBJECT (WID ("theme_save")), "clicked", (GCallback) theme_save_cb, data);
|
||||
g_signal_connect (G_OBJECT (WID ("theme_open")), "clicked", (GCallback) theme_open_cb, data);
|
||||
g_signal_connect (G_OBJECT (WID ("theme_delete")), "clicked", (GCallback) theme_delete_cb, data);
|
||||
|
||||
/* connect theme list signals */
|
||||
g_signal_connect (G_OBJECT (WID ("theme_list")), "item-activated", (GCallback) theme_activated_cb, data);
|
||||
|
||||
/* set up theme list */
|
||||
theme_store = gtk_list_store_new (2, G_TYPE_STRING, GDK_TYPE_PIXBUF);
|
||||
|
||||
/* Temporary measure to fill the themes list.
|
||||
* This should be replace with asynchronous calls.
|
||||
*/
|
||||
theme_list = gnome_theme_meta_info_find_all ();
|
||||
gnome_theme_info_register_theme_change ((GFunc)theme_changed_func, data);
|
||||
for (l = theme_list; l; l = g_list_next (l))
|
||||
{
|
||||
gchar *name = ((GnomeThemeMetaInfo *)l->data)->name;
|
||||
if (name)
|
||||
{
|
||||
GdkPixbuf *pixbuf = generate_theme_thumbnail (l->data, TRUE);
|
||||
gtk_list_store_insert_with_values (theme_store, NULL, 0,
|
||||
THEME_NAME_COLUMN, name,
|
||||
THEME_PIXBUF_COLUMN, pixbuf,
|
||||
-1);
|
||||
}
|
||||
}
|
||||
|
||||
w = WID ("theme_list");
|
||||
gtk_icon_view_set_model (GTK_ICON_VIEW (w), GTK_TREE_MODEL (theme_store));
|
||||
|
||||
}
|
||||
|
||||
/** Theme Callbacks **/
|
||||
|
||||
void
|
||||
theme_changed_func (gpointer uri, AppearanceData *data)
|
||||
{
|
||||
/* TODO: add/change/remove themes from the model as appropriate */
|
||||
}
|
||||
|
||||
|
||||
/** GUI Callbacks **/
|
||||
|
||||
void
|
||||
theme_activated_cb (GtkWidget *icon_view, GtkTreePath *path, AppearanceData *data)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
GnomeThemeMetaInfo *theme = NULL;
|
||||
gchar *name;
|
||||
|
||||
model = gtk_icon_view_get_model (GTK_ICON_VIEW (icon_view));
|
||||
gtk_tree_model_get_iter (model, &iter, path);
|
||||
gtk_tree_model_get (model, &iter, THEME_NAME_COLUMN, &name, -1);
|
||||
|
||||
theme = gnome_theme_meta_info_find (name);
|
||||
if (theme)
|
||||
gnome_meta_theme_set (theme);
|
||||
g_free (theme);
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
void
|
||||
theme_save_cb (GtkWidget *button, AppearanceData *data)
|
||||
{
|
||||
/* TODO: Save the current settings as a new theme */
|
||||
}
|
||||
|
||||
void
|
||||
theme_open_cb (GtkWidget *button, AppearanceData *data)
|
||||
{
|
||||
/* TODO: Install a new theme */
|
||||
}
|
||||
|
||||
void
|
||||
theme_delete_cb (GtkWidget *button, AppearanceData *data)
|
||||
{
|
||||
/* TODO: Delete the selected theme */
|
||||
}
|
2
capplets/appearance/appearance-themes.h
Normal file
2
capplets/appearance/appearance-themes.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
void themes_init (AppearanceData *data);
|
||||
|
1603
capplets/appearance/appearance.glade
Normal file
1603
capplets/appearance/appearance.glade
Normal file
File diff suppressed because it is too large
Load diff
11
capplets/appearance/appearance.h
Normal file
11
capplets/appearance/appearance.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <glade/glade.h>
|
||||
#include <libgnomevfs/gnome-vfs.h>
|
||||
|
||||
#define WID(x) (glade_xml_get_widget (data->xml, x))
|
||||
|
||||
typedef struct {
|
||||
int argc;
|
||||
char **argv;
|
||||
GladeXML *xml;
|
||||
} AppearanceData;
|
Loading…
Add table
Reference in a new issue