tint2conf: Updates (work in progress)
git-svn-id: http://tint2.googlecode.com/svn/trunk@672 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
parent
d584d04691
commit
88e0e4fed8
10 changed files with 3698 additions and 1613 deletions
|
@ -8,6 +8,7 @@ pkg_check_modules( GOBJECT2 REQUIRED gobject-2.0 )
|
||||||
pkg_check_modules( IMLIB2 REQUIRED imlib2 )
|
pkg_check_modules( IMLIB2 REQUIRED imlib2 )
|
||||||
pkg_check_modules( GTHREAD2 REQUIRED gthread-2.0 )
|
pkg_check_modules( GTHREAD2 REQUIRED gthread-2.0 )
|
||||||
pkg_check_modules( GTK2 REQUIRED gtk+-x11-2.0 )
|
pkg_check_modules( GTK2 REQUIRED gtk+-x11-2.0 )
|
||||||
|
pkg_check_modules( RSVG librsvg-2.0>=2.36.0 )
|
||||||
|
|
||||||
include_directories( ../util
|
include_directories( ../util
|
||||||
${X11_T2C_INCLUDE_DIRS}
|
${X11_T2C_INCLUDE_DIRS}
|
||||||
|
@ -15,26 +16,44 @@ include_directories( ../util
|
||||||
${GOBJECT2_INCLUDE_DIRS}
|
${GOBJECT2_INCLUDE_DIRS}
|
||||||
${IMLIB2_INCLUDE_DIRS}
|
${IMLIB2_INCLUDE_DIRS}
|
||||||
${GTHREAD2_INCLUDE_DIRS}
|
${GTHREAD2_INCLUDE_DIRS}
|
||||||
${GTK2_INCLUDE_DIRS} )
|
${GTK2_INCLUDE_DIRS}
|
||||||
|
${RSVG_INCLUDE_DIRS} )
|
||||||
|
|
||||||
set(SOURCES ../util/common.c
|
set(SOURCES ../util/common.c
|
||||||
|
../config.c
|
||||||
|
../server.c
|
||||||
|
../launcher/apps-common.c
|
||||||
|
../launcher/icon-theme-common.c
|
||||||
main.c
|
main.c
|
||||||
properties.c
|
properties.c
|
||||||
properties_rw.c
|
properties_rw.c
|
||||||
theme_view.c )
|
theme_view.c )
|
||||||
|
|
||||||
|
add_definitions( -DTINT2CONF )
|
||||||
|
|
||||||
|
option( ENABLE_RSVG "Rsvg support (launcher only)" ON )
|
||||||
|
|
||||||
|
if( ENABLE_RSVG )
|
||||||
|
if( RSVG_FOUND )
|
||||||
|
add_definitions( -DHAVE_RSVG )
|
||||||
|
endif( RSVG_FOUND )
|
||||||
|
endif( ENABLE_RSVG )
|
||||||
|
|
||||||
link_directories( ${X11_T2C_LIBRARY_DIRS}
|
link_directories( ${X11_T2C_LIBRARY_DIRS}
|
||||||
${GLIB2_LIBRARY_DIRS}
|
${GLIB2_LIBRARY_DIRS}
|
||||||
${GOBJECT2_LIBRARY_DIRS}
|
${GOBJECT2_LIBRARY_DIRS}
|
||||||
${IMLIB2_LIBRARY_DIRS}
|
${IMLIB2_LIBRARY_DIRS}
|
||||||
${GTHREAD2_LIBRARY_DIRS}
|
${GTHREAD2_LIBRARY_DIRS}
|
||||||
${GTK2_LIBRARY_DIRS} )
|
${GTK2_LIBRARY_DIRS}
|
||||||
|
${RSVG_LIBRARY_DIRS} )
|
||||||
add_executable( tint2conf ${SOURCES} )
|
add_executable( tint2conf ${SOURCES} )
|
||||||
target_link_libraries( tint2conf ${X11_T2C_LIBRARIES}
|
target_link_libraries( tint2conf ${X11_T2C_LIBRARIES}
|
||||||
${GLIB2_LIBRARIES}
|
${GLIB2_LIBRARIES}
|
||||||
${GOBJECT2_LIBRARIES}
|
${GOBJECT2_LIBRARIES}
|
||||||
${IMLIB2_LIBRARIES}
|
${IMLIB2_LIBRARIES}
|
||||||
${GTHREAD2_LIBRARIES}
|
${GTHREAD2_LIBRARIES}
|
||||||
${GTK2_LIBRARIES} )
|
${GTK2_LIBRARIES}
|
||||||
|
${RSVG_LIBRARIES} )
|
||||||
|
|
||||||
if ( NOT DATADIR )
|
if ( NOT DATADIR )
|
||||||
set( DATADIR share )
|
set( DATADIR share )
|
||||||
|
|
|
@ -17,23 +17,22 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
#ifdef HAVE_VERSION_H
|
#ifdef HAVE_VERSION_H
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "theme_view.h"
|
#include "theme_view.h"
|
||||||
#include "properties.h"
|
#include "properties.h"
|
||||||
#include "properties_rw.h"
|
#include "properties_rw.h"
|
||||||
|
|
||||||
#define SNAPSHOT_TICK 190
|
// Default path to the tint2 config file
|
||||||
|
|
||||||
|
|
||||||
// default config file and directory
|
|
||||||
char *g_path_config = NULL;
|
char *g_path_config = NULL;
|
||||||
|
// Default path to the tint2 config directory
|
||||||
char *g_path_dir = NULL;
|
char *g_path_dir = NULL;
|
||||||
char *g_default_theme = NULL;
|
char *g_default_theme = NULL;
|
||||||
char *g_cmd_property = NULL;
|
|
||||||
int g_width, g_height;
|
int g_width, g_height;
|
||||||
|
|
||||||
GtkWidget *g_window;
|
GtkWidget *g_window;
|
||||||
|
@ -50,7 +49,7 @@ static void menuProperties();
|
||||||
static void menuQuit();
|
static void menuQuit();
|
||||||
static void menuRefresh();
|
static void menuRefresh();
|
||||||
static void menuRefreshAll();
|
static void menuRefreshAll();
|
||||||
static void menuApply();
|
void menuApply();
|
||||||
static void menuAbout();
|
static void menuAbout();
|
||||||
|
|
||||||
static gboolean view_onPopupMenu (GtkWidget *treeview, gpointer userdata);
|
static gboolean view_onPopupMenu (GtkWidget *treeview, gpointer userdata);
|
||||||
|
@ -86,7 +85,6 @@ static const char *global_ui =
|
||||||
" <menuitem action='EditRefresh'/>"
|
" <menuitem action='EditRefresh'/>"
|
||||||
" <menuitem action='EditRefreshAll'/>"
|
" <menuitem action='EditRefreshAll'/>"
|
||||||
" <separator/>"
|
" <separator/>"
|
||||||
" <menuitem action='EditPreferences'/>"
|
|
||||||
" </menu>"
|
" </menu>"
|
||||||
" <menu action='HelpMenu'>"
|
" <menu action='HelpMenu'>"
|
||||||
" <menuitem action='HelpAbout'/>"
|
" <menuitem action='HelpAbout'/>"
|
||||||
|
@ -209,12 +207,15 @@ static void menuAdd()
|
||||||
dialog = gtk_file_chooser_dialog_new(_("Add a theme"), GTK_WINDOW(g_window), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT, NULL);
|
dialog = gtk_file_chooser_dialog_new(_("Add a theme"), GTK_WINDOW(g_window), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT, NULL);
|
||||||
chooser = GTK_FILE_CHOOSER(dialog);
|
chooser = GTK_FILE_CHOOSER(dialog);
|
||||||
|
|
||||||
gtk_file_chooser_set_current_folder(chooser, g_get_home_dir());
|
gchar *config_dir;
|
||||||
|
config_dir = g_build_filename(g_get_home_dir(), ".config", "tint2", NULL);
|
||||||
|
gtk_file_chooser_set_current_folder(chooser, config_dir);
|
||||||
|
g_free(config_dir);
|
||||||
gtk_file_chooser_set_select_multiple(chooser, TRUE);
|
gtk_file_chooser_set_select_multiple(chooser, TRUE);
|
||||||
|
|
||||||
filter = gtk_file_filter_new();
|
filter = gtk_file_filter_new();
|
||||||
gtk_file_filter_set_name(filter, _("Tint2 theme files"));
|
gtk_file_filter_set_name(filter, _("Tint2 theme files"));
|
||||||
gtk_file_filter_add_pattern(filter, "*.tint2rc");
|
gtk_file_filter_add_pattern(filter, "*tint2rc");
|
||||||
gtk_file_chooser_add_filter(chooser, filter);
|
gtk_file_chooser_add_filter(chooser, filter);
|
||||||
|
|
||||||
if (gtk_dialog_run (GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) {
|
if (gtk_dialog_run (GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) {
|
||||||
|
@ -291,7 +292,10 @@ static void menuSaveAs ()
|
||||||
chooser = GTK_FILE_CHOOSER(dialog);
|
chooser = GTK_FILE_CHOOSER(dialog);
|
||||||
|
|
||||||
gtk_file_chooser_set_do_overwrite_confirmation(chooser, TRUE);
|
gtk_file_chooser_set_do_overwrite_confirmation(chooser, TRUE);
|
||||||
gtk_file_chooser_set_current_folder(chooser, g_get_home_dir());
|
gchar *config_dir;
|
||||||
|
config_dir = g_build_filename(g_get_home_dir(), ".config", "tint2", NULL);
|
||||||
|
gtk_file_chooser_set_current_folder(chooser, config_dir);
|
||||||
|
g_free(config_dir);
|
||||||
gtk_file_chooser_set_current_name(chooser, pt1);
|
gtk_file_chooser_set_current_name(chooser, pt1);
|
||||||
|
|
||||||
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
|
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
|
||||||
|
@ -325,6 +329,20 @@ static void menuDelete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *get_current_theme_file_name()
|
||||||
|
{
|
||||||
|
GtkTreeSelection *sel;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
GtkTreeModel *model;
|
||||||
|
char *file;
|
||||||
|
|
||||||
|
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view));
|
||||||
|
if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) {
|
||||||
|
gtk_tree_model_get(model, &iter, COL_THEME_FILE, &file, -1);
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void menuProperties()
|
static void menuProperties()
|
||||||
{
|
{
|
||||||
|
@ -336,21 +354,11 @@ static void menuProperties()
|
||||||
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view));
|
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view));
|
||||||
if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) {
|
if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) {
|
||||||
gtk_tree_model_get(model, &iter, COL_THEME_FILE, &file, -1);
|
gtk_tree_model_get(model, &iter, COL_THEME_FILE, &file, -1);
|
||||||
//*
|
|
||||||
GtkWidget *prop;
|
GtkWidget *prop;
|
||||||
prop = create_properties();
|
prop = create_properties();
|
||||||
config_read_file(file);
|
config_read_file(file);
|
||||||
gtk_window_present(GTK_WINDOW(prop));
|
gtk_window_present(GTK_WINDOW(prop));
|
||||||
//printf("menuProperties : fin\n");
|
|
||||||
//*/
|
|
||||||
/*
|
|
||||||
char *cmd = g_strdup_printf("%s \'%s\' &", g_cmd_property, file);
|
|
||||||
printf("cmd %s\n", cmd);
|
|
||||||
system(cmd);
|
|
||||||
g_free(cmd);
|
|
||||||
//*/
|
|
||||||
g_free(file);
|
g_free(file);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,8 +373,6 @@ static void menuQuit()
|
||||||
g_free(g_path_dir);
|
g_free(g_path_dir);
|
||||||
if (g_default_theme)
|
if (g_default_theme)
|
||||||
g_free(g_default_theme);
|
g_free(g_default_theme);
|
||||||
if (g_cmd_property)
|
|
||||||
g_free(g_cmd_property);
|
|
||||||
|
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
@ -404,7 +410,7 @@ static void menuRefreshAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void menuApply()
|
void menuApply()
|
||||||
{
|
{
|
||||||
GtkTreeSelection *sel;
|
GtkTreeSelection *sel;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
@ -417,15 +423,24 @@ static void menuApply()
|
||||||
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view));
|
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view));
|
||||||
if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) {
|
if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) {
|
||||||
gtk_tree_model_get(model, &iter, COL_THEME_FILE, &g_default_theme, -1);
|
gtk_tree_model_get(model, &iter, COL_THEME_FILE, &g_default_theme, -1);
|
||||||
// overwrite tint2rc
|
// Create backup if the config file has been edited manually
|
||||||
|
if (config_is_manual(g_path_config)) {
|
||||||
|
char timestamp[64];
|
||||||
|
sprintf(timestamp, "%ld", time(NULL));
|
||||||
|
gchar *backup_path = g_build_filename(g_get_user_config_dir(), "tint2", "tint2rc.backup.", timestamp, NULL);
|
||||||
|
copy_file(g_path_config, backup_path);
|
||||||
|
g_free(backup_path);
|
||||||
|
}
|
||||||
|
// Write config file
|
||||||
|
printf("Writing %s to %s\n", g_default_theme, g_path_config);
|
||||||
|
fflush(stdout);
|
||||||
copy_file(g_default_theme, g_path_config);
|
copy_file(g_default_theme, g_path_config);
|
||||||
|
// Restart panel
|
||||||
// restart panel
|
int unused = system("killall -SIGUSR1 tint2");
|
||||||
system("killall -SIGUSR1 tint2");
|
(void)unused;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void view_popup_menu(GtkWidget *treeview, GdkEventButton *event, gpointer userdata)
|
static void view_popup_menu(GtkWidget *treeview, GdkEventButton *event, gpointer userdata)
|
||||||
{
|
{
|
||||||
GtkWidget *w = gtk_ui_manager_get_widget(globalUIManager, "/ThemePopup");
|
GtkWidget *w = gtk_ui_manager_get_widget(globalUIManager, "/ThemePopup");
|
||||||
|
@ -433,7 +448,6 @@ static void view_popup_menu(GtkWidget *treeview, GdkEventButton *event, gpointer
|
||||||
gtk_menu_popup(GTK_MENU(w), NULL, NULL, NULL, NULL, (event != NULL) ? event->button : 0, gdk_event_get_time((GdkEvent*)event));
|
gtk_menu_popup(GTK_MENU(w), NULL, NULL, NULL, NULL, (event != NULL) ? event->button : 0, gdk_event_get_time((GdkEvent*)event));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean view_onButtonPressed (GtkWidget *treeview, GdkEventButton *event, gpointer userdata)
|
static gboolean view_onButtonPressed (GtkWidget *treeview, GdkEventButton *event, gpointer userdata)
|
||||||
{
|
{
|
||||||
// single click with the right mouse button?
|
// single click with the right mouse button?
|
||||||
|
@ -459,41 +473,38 @@ static gboolean view_onButtonPressed (GtkWidget *treeview, GdkEventButton *event
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean view_onPopupMenu (GtkWidget *treeview, gpointer userdata)
|
static gboolean view_onPopupMenu (GtkWidget *treeview, gpointer userdata)
|
||||||
{
|
{
|
||||||
view_popup_menu(treeview, NULL, userdata);
|
view_popup_menu(treeview, NULL, userdata);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void viewRowActivated(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
|
static void viewRowActivated(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
|
||||||
{
|
{
|
||||||
menuApply();
|
menuApply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void windowSizeAllocated()
|
static void windowSizeAllocated()
|
||||||
{
|
{
|
||||||
const gboolean isMaximized = g_window->window && (gdk_window_get_state(g_window->window) & GDK_WINDOW_STATE_MAXIMIZED);
|
const gboolean isMaximized = g_window->window &&
|
||||||
|
(gdk_window_get_state(g_window->window) & GDK_WINDOW_STATE_MAXIMIZED);
|
||||||
|
|
||||||
if(!isMaximized)
|
if(!isMaximized)
|
||||||
gtk_window_get_size(GTK_WINDOW(g_window), &g_width, &g_height);
|
gtk_window_get_size(GTK_WINDOW(g_window), &g_width, &g_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void load_theme(GtkWidget *list)
|
static void load_theme(GtkWidget *list)
|
||||||
{
|
{
|
||||||
GDir *dir;
|
GDir *dir;
|
||||||
gchar *pt1, *name;
|
gchar *name;
|
||||||
const gchar *file;
|
const gchar *file;
|
||||||
gboolean found_theme = FALSE;
|
gboolean found_theme = FALSE;
|
||||||
|
|
||||||
dir = g_dir_open(g_path_dir, 0, NULL);
|
dir = g_dir_open(g_path_dir, 0, NULL);
|
||||||
if (dir == NULL) return;
|
if (dir == NULL)
|
||||||
|
return;
|
||||||
while ((file = g_dir_read_name(dir))) {
|
while ((file = g_dir_read_name(dir))) {
|
||||||
pt1 = strstr(file, ".tint2rc");
|
if (g_str_has_suffix(file, ".tint2rc")) {
|
||||||
if (pt1) {
|
|
||||||
found_theme = TRUE;
|
found_theme = TRUE;
|
||||||
name = g_build_filename (g_path_dir, file, NULL);
|
name = g_build_filename (g_path_dir, file, NULL);
|
||||||
custom_list_append(name);
|
custom_list_append(name);
|
||||||
|
@ -507,7 +518,8 @@ static void load_theme(GtkWidget *list)
|
||||||
name = g_build_filename(g_get_user_config_dir(), "tint2", "default.tint2rc", NULL);
|
name = g_build_filename(g_get_user_config_dir(), "tint2", "default.tint2rc", NULL);
|
||||||
copy_file(g_path_config, name);
|
copy_file(g_path_config, name);
|
||||||
custom_list_append(name);
|
custom_list_append(name);
|
||||||
if (g_default_theme) g_free(g_default_theme);
|
if (g_default_theme)
|
||||||
|
g_free(g_default_theme);
|
||||||
g_default_theme = strdup(name);
|
g_default_theme = strdup(name);
|
||||||
g_free(name);
|
g_free(name);
|
||||||
}
|
}
|
||||||
|
@ -517,22 +529,22 @@ static void load_theme(GtkWidget *list)
|
||||||
g_timeout_add(SNAPSHOT_TICK, (GSourceFunc)update_snapshot, NULL);
|
g_timeout_add(SNAPSHOT_TICK, (GSourceFunc)update_snapshot, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void selectTheme(const gchar *name_theme)
|
void selectTheme(const gchar *name_theme)
|
||||||
{
|
{
|
||||||
gboolean have_iter, found_theme;
|
gboolean have_iter, found_theme;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
|
|
||||||
if (!name_theme) return;
|
if (!name_theme)
|
||||||
|
return;
|
||||||
|
|
||||||
model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view));
|
model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view));
|
||||||
found_theme = searchTheme(name_theme, model, &iter);
|
found_theme = searchTheme(name_theme, model, &iter);
|
||||||
|
|
||||||
GtkTreePath *path = NULL;
|
GtkTreePath *path = NULL;
|
||||||
if (found_theme)
|
if (found_theme) {
|
||||||
path = gtk_tree_model_get_path(model, &iter);
|
path = gtk_tree_model_get_path(model, &iter);
|
||||||
else {
|
} else {
|
||||||
have_iter = gtk_tree_model_get_iter_first(model, &iter);
|
have_iter = gtk_tree_model_get_iter_first(model, &iter);
|
||||||
if (have_iter)
|
if (have_iter)
|
||||||
path = gtk_tree_model_get_path(model, &iter);
|
path = gtk_tree_model_get_path(model, &iter);
|
||||||
|
@ -544,7 +556,6 @@ void selectTheme(const gchar *name_theme)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gboolean searchTheme(const gchar *name_theme, GtkTreeModel *model, GtkTreeIter *iter)
|
gboolean searchTheme(const gchar *name_theme, GtkTreeModel *model, GtkTreeIter *iter)
|
||||||
{
|
{
|
||||||
gchar *name;
|
gchar *name;
|
||||||
|
@ -562,7 +573,7 @@ gboolean searchTheme(const gchar *name_theme, GtkTreeModel *model, GtkTreeIter *
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initializes the paths to the tint2 config locations.
|
||||||
void initTheme()
|
void initTheme()
|
||||||
{
|
{
|
||||||
g_path_dir = g_build_filename (g_get_user_config_dir(), "tint2", NULL);
|
g_path_dir = g_build_filename (g_get_user_config_dir(), "tint2", NULL);
|
||||||
|
@ -572,7 +583,7 @@ void initTheme()
|
||||||
g_path_config = g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL);
|
g_path_config = g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reads the tint2conf config file.
|
||||||
void read_config()
|
void read_config()
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
|
@ -584,7 +595,6 @@ void read_config()
|
||||||
}
|
}
|
||||||
g_width = 500;
|
g_width = 500;
|
||||||
g_height = 350;
|
g_height = 350;
|
||||||
g_cmd_property = g_strconcat( "/usr/bin/env python ", INSTALL_PREFIX, "/bin/tintwizard.py", (void*)0 );
|
|
||||||
|
|
||||||
// load config
|
// load config
|
||||||
path = g_build_filename (g_get_user_config_dir(), "tint2", "tint2confrc", NULL);
|
path = g_build_filename (g_get_user_config_dir(), "tint2", "tint2confrc", NULL);
|
||||||
|
@ -597,10 +607,6 @@ void read_config()
|
||||||
if (parse_line(line, &key, &value)) {
|
if (parse_line(line, &key, &value)) {
|
||||||
if (strcmp (key, "default_theme") == 0)
|
if (strcmp (key, "default_theme") == 0)
|
||||||
g_default_theme = strdup(value);
|
g_default_theme = strdup(value);
|
||||||
else if (strcmp (key, "cmd_property") == 0) {
|
|
||||||
g_free(g_cmd_property);
|
|
||||||
g_cmd_property = strdup(value);
|
|
||||||
}
|
|
||||||
else if (strcmp (key, "width") == 0)
|
else if (strcmp (key, "width") == 0)
|
||||||
g_width = atoi(value);
|
g_width = atoi(value);
|
||||||
else if (strcmp (key, "height") == 0)
|
else if (strcmp (key, "height") == 0)
|
||||||
|
@ -615,7 +621,7 @@ void read_config()
|
||||||
g_free(path);
|
g_free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Writes the tint2conf config file.
|
||||||
void write_config()
|
void write_config()
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
|
@ -629,9 +635,6 @@ void write_config()
|
||||||
if (g_default_theme != NULL) {
|
if (g_default_theme != NULL) {
|
||||||
fprintf(fp, "default_theme = %s\n", g_default_theme);
|
fprintf(fp, "default_theme = %s\n", g_default_theme);
|
||||||
}
|
}
|
||||||
if (g_cmd_property != NULL) {
|
|
||||||
fprintf(fp, "cmd_property = %s\n", g_cmd_property);
|
|
||||||
}
|
|
||||||
fprintf(fp, "width = %d\n", g_width);
|
fprintf(fp, "width = %d\n", g_width);
|
||||||
fprintf(fp, "height = %d\n", g_height);
|
fprintf(fp, "height = %d\n", g_height);
|
||||||
fputs("\n", fp);
|
fputs("\n", fp);
|
||||||
|
@ -639,6 +642,3 @@ void write_config()
|
||||||
}
|
}
|
||||||
g_free(path);
|
g_free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -14,3 +13,6 @@
|
||||||
#define _(String) String
|
#define _(String) String
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SNAPSHOT_TICK 190
|
||||||
|
gboolean update_snapshot();
|
||||||
|
void menuApply();
|
File diff suppressed because it is too large
Load diff
|
@ -3,49 +3,152 @@
|
||||||
#define PROPERTIES
|
#define PROPERTIES
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include <gdk/gdk.h>
|
||||||
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||||
|
|
||||||
|
#include "../launcher/icon-theme-common.h"
|
||||||
|
|
||||||
|
|
||||||
// panel
|
// panel
|
||||||
GtkWidget *panel_width, *panel_height, *panel_margin_x, *panel_margin_y, *panel_padding_x, *panel_padding_y, *panel_spacing;
|
extern GtkWidget *panel_width, *panel_height, *panel_margin_x, *panel_margin_y, *panel_padding_x, *panel_padding_y, *panel_spacing;
|
||||||
GtkWidget *panel_wm_menu, *panel_dock, *panel_autohide, *panel_autohide_show_time, *panel_autohide_hide_time, *panel_autohide_size;
|
extern GtkWidget *panel_wm_menu, *panel_dock, *panel_autohide, *panel_autohide_show_time, *panel_autohide_hide_time, *panel_autohide_size;
|
||||||
GtkWidget *panel_combo_strut_policy, *panel_combo_layer, *panel_combo_width_type, *panel_combo_height_type, *panel_combo_monitor;
|
extern GtkWidget *panel_combo_strut_policy, *panel_combo_layer, *panel_combo_width_type, *panel_combo_height_type, *panel_combo_monitor;
|
||||||
GtkWidget *items_order;
|
|
||||||
|
enum {
|
||||||
|
itemsColName = 0,
|
||||||
|
itemsColValue,
|
||||||
|
itemsNumCols
|
||||||
|
};
|
||||||
|
extern GtkListStore *panel_items, *all_items;
|
||||||
|
extern GtkWidget *panel_items_view, *all_items_view;
|
||||||
|
char *get_panel_items();
|
||||||
|
void set_panel_items(const char *items);
|
||||||
|
|
||||||
|
extern GtkWidget *screen_position[12];
|
||||||
|
extern GSList *screen_position_group;
|
||||||
|
extern GtkWidget *panel_background;
|
||||||
|
|
||||||
|
#define POS_TLH 0
|
||||||
|
#define POS_TCH 1
|
||||||
|
#define POS_TRH 2
|
||||||
|
|
||||||
|
#define POS_TLV 3
|
||||||
|
#define POS_CLV 4
|
||||||
|
#define POS_BLV 5
|
||||||
|
|
||||||
|
#define POS_TRV 6
|
||||||
|
#define POS_CRV 7
|
||||||
|
#define POS_BRV 8
|
||||||
|
|
||||||
|
#define POS_BLH 9
|
||||||
|
#define POS_BCH 10
|
||||||
|
#define POS_BRH 11
|
||||||
|
|
||||||
// taskbar
|
// taskbar
|
||||||
GtkWidget *taskbar_show_desktop, *taskbar_show_name, *taskbar_padding_x, *taskbar_padding_y, *taskbar_spacing;
|
extern GtkWidget *taskbar_show_desktop, *taskbar_show_name, *taskbar_padding_x, *taskbar_padding_y, *taskbar_spacing;
|
||||||
GtkWidget *taskbar_name_padding_x, *taskbar_name_inactive_color, *taskbar_name_active_color, *taskbar_name_font;
|
extern GtkWidget *taskbar_name_padding_x, *taskbar_name_inactive_color, *taskbar_name_active_color, *taskbar_name_font;
|
||||||
|
extern GtkWidget *taskbar_active_background, *taskbar_inactive_background;
|
||||||
|
extern GtkWidget *taskbar_name_active_background, *taskbar_name_inactive_background;
|
||||||
|
|
||||||
// task
|
// task
|
||||||
GtkWidget *task_mouse_middle, *task_mouse_right, *task_mouse_scroll_up, *task_mouse_scroll_down;
|
extern GtkWidget *task_mouse_middle, *task_mouse_right, *task_mouse_scroll_up, *task_mouse_scroll_down;
|
||||||
GtkWidget *task_show_icon, *task_show_text, *task_align_center, *task_font_shadow;
|
extern GtkWidget *task_show_icon, *task_show_text, *task_align_center, *task_font_shadow;
|
||||||
GtkWidget *task_maximum_width, *task_maximum_height, *task_padding_x, *task_padding_y, *task_font;
|
extern GtkWidget *task_maximum_width, *task_maximum_height, *task_padding_x, *task_padding_y, *task_font;
|
||||||
|
extern GtkWidget *task_default_color, *task_default_color_set,
|
||||||
|
*task_default_icon_opacity, *task_default_icon_osb_set,
|
||||||
|
*task_default_icon_saturation,
|
||||||
|
*task_default_icon_brightness,
|
||||||
|
*task_default_background, *task_default_background_set;
|
||||||
|
extern GtkWidget *task_normal_color, *task_normal_color_set,
|
||||||
|
*task_normal_icon_opacity, *task_normal_icon_osb_set,
|
||||||
|
*task_normal_icon_saturation,
|
||||||
|
*task_normal_icon_brightness,
|
||||||
|
*task_normal_background, *task_normal_background_set;
|
||||||
|
extern GtkWidget *task_active_color, *task_active_color_set,
|
||||||
|
*task_active_icon_opacity, *task_active_icon_osb_set,
|
||||||
|
*task_active_icon_saturation,
|
||||||
|
*task_active_icon_brightness,
|
||||||
|
*task_active_background, *task_active_background_set;
|
||||||
|
extern GtkWidget *task_urgent_color, *task_urgent_color_set,
|
||||||
|
*task_urgent_icon_opacity, *task_urgent_icon_osb_set,
|
||||||
|
*task_urgent_icon_saturation,
|
||||||
|
*task_urgent_icon_brightness,
|
||||||
|
*task_urgent_background, *task_urgent_background_set;
|
||||||
|
extern GtkWidget *task_urgent_blinks;
|
||||||
|
extern GtkWidget *task_iconified_color, *task_iconified_color_set,
|
||||||
|
*task_iconified_icon_opacity, *task_iconified_icon_osb_set,
|
||||||
|
*task_iconified_icon_saturation,
|
||||||
|
*task_iconified_icon_brightness,
|
||||||
|
*task_iconified_background, *task_iconified_background_set;
|
||||||
|
|
||||||
// clock
|
// clock
|
||||||
GtkWidget *clock_format_line1, *clock_format_line2, *clock_tmz_line1, *clock_tmz_line2;
|
extern GtkWidget *clock_format_line1, *clock_format_line2, *clock_tmz_line1, *clock_tmz_line2;
|
||||||
GtkWidget *clock_left_command, *clock_right_command;
|
extern GtkWidget *clock_left_command, *clock_right_command;
|
||||||
GtkWidget *clock_padding_x, *clock_padding_y, *clock_font_line1, *clock_font_line2, *clock_font_color;
|
extern GtkWidget *clock_padding_x, *clock_padding_y, *clock_font_line1, *clock_font_line2, *clock_font_color;
|
||||||
|
extern GtkWidget *clock_background;
|
||||||
|
|
||||||
// battery
|
// battery
|
||||||
GtkWidget *battery_hide_if_higher, *battery_alert_if_lower, *battery_alert_cmd;
|
extern GtkWidget *battery_hide_if_higher, *battery_alert_if_lower, *battery_alert_cmd;
|
||||||
GtkWidget *battery_padding_x, *battery_padding_y, *battery_font_line1, *battery_font_line2, *battery_font_color;
|
extern GtkWidget *battery_padding_x, *battery_padding_y, *battery_font_line1, *battery_font_line2, *battery_font_color;
|
||||||
|
extern GtkWidget *battery_background;
|
||||||
|
|
||||||
// systray
|
// systray
|
||||||
GtkWidget *systray_icon_order, *systray_padding_x, *systray_padding_y, *systray_spacing;
|
extern GtkWidget *systray_icon_order, *systray_padding_x, *systray_padding_y, *systray_spacing;
|
||||||
GtkWidget *systray_icon_size, *systray_icon_opacity, *systray_icon_saturation, *systray_icon_brightness;
|
extern GtkWidget *systray_icon_size, *systray_icon_opacity, *systray_icon_saturation, *systray_icon_brightness;
|
||||||
|
extern GtkWidget *systray_background;
|
||||||
|
|
||||||
// tooltip
|
// tooltip
|
||||||
GtkWidget *tooltip_padding_x, *tooltip_padding_y, *tooltip_font, *tooltip_font_color;
|
extern GtkWidget *tooltip_padding_x, *tooltip_padding_y, *tooltip_font, *tooltip_font_color;
|
||||||
GtkWidget *tooltip_task_show, *tooltip_show_after, *tooltip_hide_after;
|
extern GtkWidget *tooltip_task_show, *tooltip_show_after, *tooltip_hide_after;
|
||||||
GtkWidget *clock_format_tooltip, *clock_tmz_tooltip;
|
extern GtkWidget *clock_format_tooltip, *clock_tmz_tooltip;
|
||||||
|
extern GtkWidget *tooltip_background;
|
||||||
|
|
||||||
// launcher
|
// launcher
|
||||||
GtkWidget *launcher_icon_size, *launcher_icon_theme, *launcher_padding_x, *launcher_padding_y, *launcher_spacing;
|
|
||||||
|
enum {
|
||||||
|
appsColIcon = 0,
|
||||||
|
appsColIconName,
|
||||||
|
appsColText,
|
||||||
|
appsColPath,
|
||||||
|
appsNumCols
|
||||||
|
};
|
||||||
|
|
||||||
|
extern GtkListStore *launcher_apps, *all_apps;
|
||||||
|
extern GtkWidget *launcher_apps_view, *all_apps_view;
|
||||||
|
|
||||||
|
extern GtkWidget *launcher_icon_size, *launcher_icon_theme, *launcher_padding_x, *launcher_padding_y, *launcher_spacing;
|
||||||
|
extern GtkWidget *margin_x, *margin_y;
|
||||||
|
extern GtkWidget *launcher_background;
|
||||||
|
|
||||||
|
extern IconThemeWrapper *icon_theme;
|
||||||
|
|
||||||
|
void load_desktop_file(const char *file, gboolean selected);
|
||||||
|
void set_current_icon_theme(const char *theme);
|
||||||
|
gchar *get_current_icon_theme();
|
||||||
|
|
||||||
// background
|
// background
|
||||||
GtkWidget *combo_background;
|
enum {
|
||||||
GtkWidget *margin_x, *margin_y;
|
bgColPixbuf = 0,
|
||||||
|
bgColFillColor,
|
||||||
|
bgColFillOpacity,
|
||||||
|
bgColBorderColor,
|
||||||
|
bgColBorderOpacity,
|
||||||
|
bgColBorderWidth,
|
||||||
|
bgColCornerRadius,
|
||||||
|
bgNumCols
|
||||||
|
};
|
||||||
|
|
||||||
|
extern GtkListStore *backgrounds;
|
||||||
|
extern GtkWidget *current_background,
|
||||||
|
*background_fill_color,
|
||||||
|
*background_border_color,
|
||||||
|
*background_border_width,
|
||||||
|
*background_corner_radius;
|
||||||
|
|
||||||
|
void background_create_new();
|
||||||
|
void background_force_update();
|
||||||
|
int background_index_safe(int index);
|
||||||
|
|
||||||
GtkWidget *create_properties();
|
GtkWidget *create_properties();
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,11 +1,11 @@
|
||||||
|
|
||||||
#ifndef PROPERTIES_RW
|
#ifndef PROPERTIES_RW
|
||||||
#define PROPERTIES_RW
|
#define PROPERTIES_RW
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
char *get_current_theme_file_name();
|
||||||
|
gboolean config_is_manual(const char *path);
|
||||||
void config_read_file (const char *path);
|
void config_read_file (const char *path);
|
||||||
void config_save_file(const char *path);
|
void config_save_file(const char *path);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,6 @@ GtkListStore *g_store;
|
||||||
int g_width_list, g_height_list;
|
int g_width_list, g_height_list;
|
||||||
GtkCellRenderer *g_renderer;
|
GtkCellRenderer *g_renderer;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GtkWidget *create_view()
|
GtkWidget *create_view()
|
||||||
{
|
{
|
||||||
GtkTreeViewColumn *col;
|
GtkTreeViewColumn *col;
|
||||||
|
@ -85,8 +83,6 @@ void custom_list_append(const gchar *name)
|
||||||
gchar *b, *n;
|
gchar *b, *n;
|
||||||
b = strrchr(name, '/');
|
b = strrchr(name, '/');
|
||||||
n = g_strdup(b+1);
|
n = g_strdup(b+1);
|
||||||
b = strrchr(n, '.');
|
|
||||||
*b = '\0';
|
|
||||||
gtk_list_store_set(g_store, &iter, COL_THEME_NAME, n, -1);
|
gtk_list_store_set(g_store, &iter, COL_THEME_NAME, n, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +92,9 @@ gboolean update_snapshot()
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
GdkPixbuf *icon;
|
GdkPixbuf *icon;
|
||||||
gboolean have_iter, found = FALSE;
|
gboolean have_iter;
|
||||||
|
|
||||||
|
gint pixWidth = 200, pixHeight = 30;
|
||||||
|
|
||||||
model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view));
|
model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view));
|
||||||
have_iter = gtk_tree_model_get_iter_first(model, &iter);
|
have_iter = gtk_tree_model_get_iter_first(model, &iter);
|
||||||
|
@ -104,54 +102,42 @@ gboolean update_snapshot()
|
||||||
gtk_tree_model_get(model, &iter, COL_SNAPSHOT, &icon, -1);
|
gtk_tree_model_get(model, &iter, COL_SNAPSHOT, &icon, -1);
|
||||||
if (icon != NULL) {
|
if (icon != NULL) {
|
||||||
g_object_unref(icon);
|
g_object_unref(icon);
|
||||||
have_iter = gtk_tree_model_iter_next(model, &iter);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
found = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
|
||||||
// build panel's snapshot
|
// build panel's snapshot
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf = NULL;
|
||||||
gchar *name, *snap, *cmd;
|
gchar *name, *snap, *cmd;
|
||||||
gint pixWidth, pixHeight;
|
|
||||||
gboolean changeSize = FALSE;
|
|
||||||
|
|
||||||
snap = g_build_filename (g_get_user_config_dir(), "tint2", "snap.jpg", NULL);
|
snap = g_build_filename(g_get_user_config_dir(), "tint2", "snap.jpg", NULL);
|
||||||
g_remove(snap);
|
g_remove(snap);
|
||||||
|
|
||||||
gtk_tree_model_get(model, &iter, COL_THEME_FILE, &name, -1);
|
gtk_tree_model_get(model, &iter, COL_THEME_FILE, &name, -1);
|
||||||
cmd = g_strdup_printf("tint2 -c \'%s\' -s \'%s\'", name, snap);
|
cmd = g_strdup_printf("tint2 -c \'%s\' -s \'%s\'", name, snap);
|
||||||
system(cmd);
|
if (system(cmd) == 0) {
|
||||||
|
|
||||||
// load
|
// load
|
||||||
pixbuf = gdk_pixbuf_new_from_file(snap, NULL);
|
pixbuf = gdk_pixbuf_new_from_file(snap, NULL);
|
||||||
if (pixbuf == NULL) {
|
if (pixbuf == NULL) {
|
||||||
printf("snapshot NULL : %s\n", cmd);
|
printf("snapshot NULL : %s\n", cmd);
|
||||||
found = FALSE;
|
}
|
||||||
}
|
}
|
||||||
g_free(snap);
|
g_free(snap);
|
||||||
g_free(cmd);
|
g_free(cmd);
|
||||||
g_free(name);
|
g_free(name);
|
||||||
|
|
||||||
pixWidth = gdk_pixbuf_get_width(pixbuf);
|
gint w, h;
|
||||||
pixHeight = gdk_pixbuf_get_height(pixbuf);
|
w = gdk_pixbuf_get_width(pixbuf);
|
||||||
if (g_width_list != pixWidth) {
|
h = gdk_pixbuf_get_height(pixbuf);
|
||||||
g_width_list = pixWidth;
|
pixWidth = w > pixWidth ? w : pixWidth;
|
||||||
changeSize = TRUE;
|
pixHeight = h > pixHeight ? h : pixHeight;
|
||||||
}
|
|
||||||
if (g_height_list != (pixHeight+30)) {
|
|
||||||
g_height_list = pixHeight+30;
|
|
||||||
changeSize = TRUE;
|
|
||||||
}
|
|
||||||
if (changeSize)
|
|
||||||
gtk_cell_renderer_set_fixed_size(g_renderer, g_width_list, g_height_list);
|
|
||||||
|
|
||||||
gtk_list_store_set(g_store, &iter, COL_SNAPSHOT, pixbuf, -1);
|
gtk_list_store_set(g_store, &iter, COL_SNAPSHOT, pixbuf, -1);
|
||||||
|
|
||||||
|
have_iter = gtk_tree_model_iter_next(model, &iter);
|
||||||
}
|
}
|
||||||
return found;
|
|
||||||
|
gtk_cell_renderer_set_fixed_size(g_renderer, pixWidth + 30, pixHeight + 30);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,6 @@ GtkWidget *create_view();
|
||||||
|
|
||||||
void custom_list_append(const gchar *name);
|
void custom_list_append(const gchar *name);
|
||||||
|
|
||||||
gboolean update_snapshot();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Type=Application
|
Type=Application
|
||||||
Encoding=UTF-8
|
|
||||||
Name=Panel tint2
|
Name=Panel tint2
|
||||||
Name[am]=ፓነል tint2
|
Name[am]=ፓነል tint2
|
||||||
Name[ar]=الشريط tint2
|
Name[ar]=الشريط tint2
|
||||||
|
|
Loading…
Reference in a new issue