[nautilus-actions] Define a new NA_IPREFS_DESKTOP_ENVIRONMENT user preference
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Define a new NA_IPREFS_DESKTOP_ENVIRONMENT user preference
- Date: Fri, 25 Feb 2011 01:07:31 +0000 (UTC)
commit 2029b4908ca84c2a5435d33c45f9902964dc193c
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Feb 25 02:04:36 2011 +0100
Define a new NA_IPREFS_DESKTOP_ENVIRONMENT user preference
This let the user choose himself which is his currently running desktop environment,
instead of relying on a runtime detection.
ChangeLog | 19 +++++
po/POTFILES.in | 3 +-
src/core/Makefile.am | 2 +
src/core/na-desktop-environment.c | 130 ++++++++++++++++++++++++++++++++++
src/core/na-desktop-environment.h | 77 ++++++++++++++++++++
src/core/na-icontext.c | 80 +---------------------
src/core/na-settings.c | 20 +++++-
src/core/na-settings.h | 1 +
src/nact/nact-ienvironment-tab.c | 26 ++-----
src/nact/nact-preferences-editor.c | 135 ++++++++++++++++++++++++++++++++++--
src/nact/nact-preferences.ui | 82 +++++++++++++++++++++-
11 files changed, 469 insertions(+), 106 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f427701..2829e02 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
2011-02-25 Pierre Wieser <pwieser trychlos org>
+ Current desktop environment can be a user preference
+
+ * src/core/na-desktop-environment.c:
+ * src/core/na-desktop-environment.h: New files.
+
+ * po/POTFILES.in:
+ * src/core/Makefile.am:
+ * src/core/na-icontext.c (is_candidate_for_show_in):
+ * nact/nact-ienvironment-tab.c
+ (nact_ienvironment_tab_runtime_init_toplevel): Updated accordingly.
+
+ * src/core/na-settings.c:
+ * src/core/na-settings.h:
+ Define new NA_IPREFS_DESKTOP_ENVIRONMENT user preference.
+ (set_key_value): Setting a NULL string actually removes the key.
+
+ * src/nact/nact-preferences-editor.c:
+ * src/nact/nact-preferences.ui: Let the user choose his desktop.
+
* src/core/na-iabout.c: Renamed as src/core/na-about.c.
* src/core/na-iabout.h: Renamed as src/core/na-about.h.
NAIAbout is no more an interface, but just a set of functions.
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f423017..b2321dc 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,6 +1,7 @@
data/gconf-schemas/nautilus-actions-prefs.schemas.in
src/core/na-exporter.c
-src/core/na-iabout.c
+src/core/na-about.c
+src/core/na-desktop-environment.c
src/core/na-icontext-factory.c
src/core/na-iimporter.c
src/core/na-importer-ask.c
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index c8122b5..9894106 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -53,6 +53,8 @@ libna_core_la_SOURCES = \
na-data-boxed.c \
na-data-def.c \
na-data-types.c \
+ na-desktop-environment.c \
+ na-desktop-environment.h \
na-exporter.c \
na-exporter.h \
na-export-format.c \
diff --git a/src/core/na-desktop-environment.c b/src/core/na-desktop-environment.c
new file mode 100644
index 0000000..16d640b
--- /dev/null
+++ b/src/core/na-desktop-environment.c
@@ -0,0 +1,130 @@
+/*
+ * Nautilus-Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009, 2010, 2011 Pierre Wieser and others (see AUTHORS)
+ *
+ * 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 Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib/gi18n.h>
+
+#include "na-desktop-environment.h"
+
+static const NADesktopEnv st_desktops[] = {
+ { DESKTOP_GNOME, N_( "GNOME desktop" ) },
+ { DESKTOP_KDE, N_( "KDE desktop" ) },
+ { DESKTOP_LXDE, N_( "LXDE desktop" ) },
+ { DESKTOP_ROX, N_( "ROX desktop" ) },
+ { DESKTOP_XFCE, N_( "XFCE desktop" ) },
+ { DESKTOP_OLD, N_( "Legacy systems" ) },
+ { NULL }
+};
+
+/*
+ * na_desktop_environment_get_known_list:
+ *
+ * Returns the list of known desktop environments as defined by the
+ * corresponding XDG specification.
+ */
+const NADesktopEnv *
+na_desktop_environment_get_known_list( void )
+{
+ return(( const NADesktopEnv * ) st_desktops );
+}
+
+
+/*
+ * Have asked on xdg-list how to identify the currently running desktop environment
+ * (see http://standards.freedesktop.org/menu-spec/latest/apb.html)
+ * For now, just reproduce the xdg-open algorythm from xdg-utils 1.0
+ */
+
+const gchar *
+na_desktop_environment_detect_running_desktop( void )
+{
+ static const gchar *thisfn = "na_desktop_environment_detect_running_desktop";
+ const gchar *value;
+ gchar *output_str, *error_str;
+ gint exit_status;
+ GError *error;
+ gboolean ok;
+
+ value = g_getenv( "KDE_FULL_SESSION" );
+ if( value && !strcmp( value, "true" )){
+ return( DESKTOP_KDE );
+ }
+
+ value = g_getenv( "GNOME_DESKTOP_SESSION_ID" );
+ if( value && strlen( value )){
+ return( DESKTOP_GNOME );
+ }
+
+ output_str = NULL;
+ error_str = NULL;
+ error = NULL;
+ if( g_spawn_command_line_sync(
+ "dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager",
+ &output_str, &error_str, &exit_status, &error )){
+ ok = ( exit_status == 0 && output_str && strlen( output_str ) && ( !error_str || !strlen( error_str )));
+ g_free( output_str );
+ g_free( error_str );
+ if( ok ){
+ return( DESKTOP_GNOME );
+ }
+ }
+ if( error ){
+ g_warning( "%s: dbus-send: %s", thisfn, error->message );
+ g_error_free( error );
+ }
+
+ output_str = NULL;
+ error_str = NULL;
+ error = NULL;
+ if( g_spawn_command_line_sync(
+ "xprop -root _DT_SAVE_MODE", &output_str, &error_str, &exit_status, &error )){
+ ok = ( exit_status == 0 && output_str && strlen( output_str ) && ( !error_str || !strlen( error_str )));
+ if( ok ){
+ ok = ( g_strstr_len( output_str, -1, "xfce" ) != NULL );
+ }
+ g_free( output_str );
+ g_free( error_str );
+ if( ok ){
+ return( DESKTOP_XFCE );
+ }
+ }
+ if( error ){
+ g_warning( "%s: xprop: %s", thisfn, error->message );
+ g_error_free( error );
+ }
+
+ /* do not know how to identify ROX or LXDE (Hong Jen Yee <pcman.tw (at) gmail.com>)
+ * environments; so other desktops are just identified as 'Old' (legacy systems)
+ */
+ return( DESKTOP_OLD );
+}
diff --git a/src/core/na-desktop-environment.h b/src/core/na-desktop-environment.h
new file mode 100644
index 0000000..80c82c5
--- /dev/null
+++ b/src/core/na-desktop-environment.h
@@ -0,0 +1,77 @@
+/*
+ * Nautilus-Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009, 2010, 2011 Pierre Wieser and others (see AUTHORS)
+ *
+ * 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 Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifndef __CORE_API_NA_DESKTOP_ENVIRONMENT_H__
+#define __CORE_API_NA_DESKTOP_ENVIRONMENT_H__
+
+/* @title: Desktop Environment
+ * @short_description: Desktop Environment Utilities.
+ * @include: core/na-desktop-environment.h
+ *
+ * The desktop environment is used with OnlyShowIn and NotShowIn keys of
+ * our desktop files. Unfortunately, there is no consensus between desktops
+ * on how to determine the currently running desktop.
+ * See http://lists.freedesktop.org/archives/xdg/2009-August/010940.html
+ * and http://lists.freedesktop.org/archives/xdg/2011-February/011818.html
+ *
+ * Waiting for such a consensus (!), we have to determine this ourself.
+ * Two methods:
+ * - letting the user select himself which is the currenly running desktop
+ * as a user preference
+ * - try to determine it automatically.
+ *
+ * Known desktop environments are defined at
+ * http://standards.freedesktop.org/menu-spec/latest/apb.html.
+ */
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define DESKTOP_GNOME "GNOME"
+#define DESKTOP_KDE "KDE"
+#define DESKTOP_LXDE "LXDE"
+#define DESKTOP_ROX "ROX"
+#define DESKTOP_XFCE "XFCE"
+#define DESKTOP_OLD "Old"
+
+typedef struct {
+ const gchar *id;
+ const gchar *label;
+}
+ NADesktopEnv;
+
+const NADesktopEnv *na_desktop_environment_get_known_list( void );
+
+const gchar *na_desktop_environment_detect_running_desktop( void );
+
+G_END_DECLS
+
+#endif /* __CORE_API_NA_DESKTOP_ENVIRONMENT_H__ */
diff --git a/src/core/na-icontext.c b/src/core/na-icontext.c
index 0a355fa..cbaa0dc 100644
--- a/src/core/na-icontext.c
+++ b/src/core/na-icontext.c
@@ -45,6 +45,7 @@
#include <api/na-core-utils.h>
#include <api/na-object-api.h>
+#include "na-desktop-environment.h"
#include "na-gnome-vfs-uri.h"
#include "na-selected-info.h"
@@ -65,7 +66,6 @@ static gboolean v_is_candidate( NAIContext *object, guint target, GList *sel
static gboolean is_candidate_for_target( const NAIContext *object, guint target, GList *files );
static gboolean is_candidate_for_show_in( const NAIContext *object, guint target, GList *files );
-static const gchar *get_running_environment( void );
static gboolean is_candidate_for_try_exec( const NAIContext *object, guint target, GList *files );
static gboolean is_candidate_for_show_if_registered( const NAIContext *object, guint target, GList *files );
static gboolean is_candidate_for_show_if_true( const NAIContext *object, guint target, GList *files );
@@ -518,7 +518,7 @@ is_candidate_for_show_in( const NAIContext *object, guint target, GList *files )
static const gchar *environment = NULL;
if( !environment ){
- environment = get_running_environment();
+ environment = na_desktop_environment_detect_running_desktop();
g_debug( "%s: found %s desktop", thisfn, environment );
}
@@ -543,82 +543,6 @@ is_candidate_for_show_in( const NAIContext *object, guint target, GList *files )
}
/*
- * Have asked on xdg-list how to identify the currently running desktop environment
- * (see http://standards.freedesktop.org/menu-spec/latest/apb.html)
- * For now, just reproduce the xdg-open algorythm from xdg-utils 1.0
- */
-#define DESKTOP_GNOME "GNOME"
-#define DESKTOP_KDE "KDE"
-#define DESKTOP_LXDE "LXDE"
-#define DESKTOP_ROX "ROX"
-#define DESKTOP_XFCE "XFCE"
-#define DESKTOP_OLD "Old"
-
-static const gchar *
-get_running_environment( void )
-{
- static const gchar *thisfn = "na_icontext_get_running_environment";
- const gchar *value;
- gchar *output_str, *error_str;
- gint exit_status;
- GError *error;
- gboolean ok;
-
- value = g_getenv( "KDE_FULL_SESSION" );
- if( value && !strcmp( value, "true" )){
- return( DESKTOP_KDE );
- }
-
- value = g_getenv( "GNOME_DESKTOP_SESSION_ID" );
- if( value && strlen( value )){
- return( DESKTOP_GNOME );
- }
-
- output_str = NULL;
- error_str = NULL;
- error = NULL;
- if( g_spawn_command_line_sync(
- "dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager",
- &output_str, &error_str, &exit_status, &error )){
- ok = ( exit_status == 0 && output_str && strlen( output_str ) && ( !error_str || !strlen( error_str )));
- g_free( output_str );
- g_free( error_str );
- if( ok ){
- return( DESKTOP_GNOME );
- }
- }
- if( error ){
- g_warning( "%s: dbus-send: %s", thisfn, error->message );
- g_error_free( error );
- }
-
- output_str = NULL;
- error_str = NULL;
- error = NULL;
- if( g_spawn_command_line_sync(
- "xprop -root _DT_SAVE_MODE", &output_str, &error_str, &exit_status, &error )){
- ok = ( exit_status == 0 && output_str && strlen( output_str ) && ( !error_str || !strlen( error_str )));
- if( ok ){
- ok = ( g_strstr_len( output_str, -1, "xfce" ) != NULL );
- }
- g_free( output_str );
- g_free( error_str );
- if( ok ){
- return( DESKTOP_XFCE );
- }
- }
- if( error ){
- g_warning( "%s: xprop: %s", thisfn, error->message );
- g_error_free( error );
- }
-
- /* do not know how to identify ROX or LXDE (Hong Jen Yee <pcman.tw (at) gmail.com>)
- * environments; so other desktops are just identified as 'Old' (legacy systems)
- */
- return( DESKTOP_OLD );
-}
-
-/*
* if the data is set, it should be the path of an executable file
*/
static gboolean
diff --git a/src/core/na-settings.c b/src/core/na-settings.c
index a72da98..0be96a8 100644
--- a/src/core/na-settings.c
+++ b/src/core/na-settings.c
@@ -114,6 +114,7 @@ static const KeyDef st_def_keys[] = {
{ NA_IPREFS_COMMAND_CHOOSER_URI, GROUP_NACT, NA_DATA_TYPE_STRING, "file:///bin" },
{ NA_IPREFS_COMMAND_LEGEND_WSP, GROUP_NACT, NA_DATA_TYPE_UINT_LIST, "" },
{ NA_IPREFS_CONFIRM_LOGOUT_WSP, GROUP_NACT, NA_DATA_TYPE_UINT_LIST, "" },
+ { NA_IPREFS_DESKTOP_ENVIRONMENT, GROUP_RUNTIME, NA_DATA_TYPE_STRING, "" },
{ NA_IPREFS_WORKING_DIR_WSP, GROUP_NACT, NA_DATA_TYPE_UINT_LIST, "" },
{ NA_IPREFS_WORKING_DIR_URI, GROUP_NACT, NA_DATA_TYPE_STRING, "file:///" },
{ NA_IPREFS_SHOW_IF_RUNNING_WSP, GROUP_NACT, NA_DATA_TYPE_UINT_LIST, "" },
@@ -1335,9 +1336,11 @@ release_key_value( KeyValue *value )
static gboolean
set_key_value( NASettings *settings, const gchar *group, const gchar *key, const gchar *string )
{
+ static const gchar *thisfn = "na_settings_set_key_value";
KeyDef *key_def;
const gchar *wgroup;
gboolean ok;
+ GError *error;
g_return_val_if_fail( NA_IS_SETTINGS( settings ), FALSE );
@@ -1353,8 +1356,21 @@ set_key_value( NASettings *settings, const gchar *group, const gchar *key, const
}
}
if( wgroup ){
- g_key_file_set_string( settings->private->user->key_file, wgroup, key, string );
- ok = write_user_key_file( settings );
+ ok = TRUE;
+
+ if( string ){
+ g_key_file_set_string( settings->private->user->key_file, wgroup, key, string );
+
+ } else {
+ error = NULL;
+ ok = g_key_file_remove_key( settings->private->user->key_file, wgroup, key, &error );
+ if( error ){
+ g_warning( "%s: g_key_file_remove_key: %s", thisfn, error->message );
+ g_error_free( error );
+ }
+ }
+
+ ok &= write_user_key_file( settings );
}
}
diff --git a/src/core/na-settings.h b/src/core/na-settings.h
index 76cc79b..e6a0253 100644
--- a/src/core/na-settings.h
+++ b/src/core/na-settings.h
@@ -103,6 +103,7 @@ GType na_settings_get_type( void );
#define NA_IPREFS_COMMAND_CHOOSER_WSP "command-command-chooser-wsp"
#define NA_IPREFS_COMMAND_CHOOSER_URI "command-command-chooser-lfu"
#define NA_IPREFS_COMMAND_LEGEND_WSP "command-legend-wsp"
+#define NA_IPREFS_DESKTOP_ENVIRONMENT "desktop-environment"
#define NA_IPREFS_CONFIRM_LOGOUT_WSP "confirm-logout-wsp"
#define NA_IPREFS_WORKING_DIR_WSP "command-working-dir-chooser-wsp"
#define NA_IPREFS_WORKING_DIR_URI "command-working-dir-chooser-lfu"
diff --git a/src/nact/nact-ienvironment-tab.c b/src/nact/nact-ienvironment-tab.c
index 7147331..51bc736 100644
--- a/src/nact/nact-ienvironment-tab.c
+++ b/src/nact/nact-ienvironment-tab.c
@@ -40,6 +40,7 @@
#include <api/na-core-utils.h>
#include <api/na-object-api.h>
+#include <core/na-desktop-environment.h>
#include <core/na-settings.h>
#include "base-gtk-utils.h"
@@ -83,22 +84,6 @@ enum {
N_COLUMN
};
-typedef struct {
- gchar *keyword;
- gchar *label;
-}
- EnvStruct;
-
-static EnvStruct st_envs[] = {
- { "GNOME", N_( "GNOME desktop" ) },
- { "KDE", N_( "KDE desktop" ) },
- { "LXDE", N_( "LXDE desktop" ) },
- { "ROX", N_( "ROX desktop" ) },
- { "XFCE", N_( "XFCE desktop" ) },
- { "Old", N_( "Legacy systems" ) },
- { NULL }
-};
-
static gboolean st_initialized = FALSE;
static gboolean st_finalized = FALSE;
static gboolean st_on_selection_change = FALSE;
@@ -240,6 +225,7 @@ nact_ienvironment_tab_runtime_init_toplevel( NactIEnvironmentTab *instance )
GtkTreeViewColumn *column;
GList *renderers;
guint i;
+ const NADesktopEnv *desktops;
g_return_if_fail( NACT_IS_IENVIRONMENT_TAB( instance ));
@@ -267,14 +253,16 @@ nact_ienvironment_tab_runtime_init_toplevel( NactIEnvironmentTab *instance )
listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( instance ), "EnvironmentsDesktopTreeView" ));
model = gtk_tree_view_get_model( listview );
- for( i = 0 ; st_envs[i].keyword ; ++i ){
+ desktops = na_desktop_environment_get_known_list();
+
+ for( i = 0 ; desktops[i].id ; ++i ){
gtk_list_store_append( GTK_LIST_STORE( model ), &iter );
gtk_list_store_set(
GTK_LIST_STORE( model ),
&iter,
ENV_BOOL_COLUMN, FALSE,
- ENV_LABEL_COLUMN, gettext( st_envs[i].label ),
- ENV_KEYWORD_COLUMN, st_envs[i].keyword,
+ ENV_LABEL_COLUMN, gettext( desktops[i].label ),
+ ENV_KEYWORD_COLUMN, desktops[i].id,
-1 );
}
diff --git a/src/nact/nact-preferences-editor.c b/src/nact/nact-preferences-editor.c
index 543a4bd..12d0b6a 100644
--- a/src/nact/nact-preferences-editor.c
+++ b/src/nact/nact-preferences-editor.c
@@ -33,9 +33,11 @@
#endif
#include <glib/gi18n.h>
+#include <libintl.h>
#include <api/na-iimporter.h>
+#include <core/na-desktop-environment.h>
#include <core/na-iprefs.h>
#include <core/na-tokens.h>
@@ -69,6 +71,8 @@ struct _NactPreferencesEditorPrivate {
/* second tab: runtime execution */
gchar *terminal_prefix;
gboolean terminal_prefix_mandatory;
+ gchar *desktop;
+ gboolean desktop_mandatory;
/* third tab: ui preferences */
gboolean relabel_menu;
@@ -97,12 +101,24 @@ struct _NactPreferencesEditorPrivate {
/* seventh tab: i/o providers */
};
-static const gchar *st_xmlui_filename = PKGDATADIR "/nact-preferences.ui";
-static const gchar *st_toplevel_name = "PreferencesDialog";
-static const gchar *st_wsp_name = NA_IPREFS_PREFERENCES_WSP;
+/* column ordering in the desktop environment combobox
+ */
+enum {
+ DESKTOP_ID_COLUMN = 0,
+ DESKTOP_LABEL_COLUMN = 0,
+ DESKTOP_N_COLUMN
+};
+
+/* i18n: the user is not willing to identify his current desktop environment,
+ * and prefers rely onthe runtime detection */
+static const NADesktopEnv st_no_desktop = { "None", N_( "Rely on runtime detection" ) };
-static GObjectClass *st_parent_class = NULL;
-static guint st_last_tab = 0;
+static const gchar *st_xmlui_filename = PKGDATADIR "/nact-preferences.ui";
+static const gchar *st_toplevel_name = "PreferencesDialog";
+static const gchar *st_wsp_name = NA_IPREFS_PREFERENCES_WSP;
+
+static GObjectClass *st_parent_class = NULL;
+static guint st_last_tab = 0;
static GType register_type( void );
static void class_init( NactPreferencesEditorClass *klass );
@@ -124,6 +140,9 @@ static void about_item_setup( NactPreferencesEditor *editor, NASettings *set
static void about_item_on_toggled( GtkToggleButton *button, NactPreferencesEditor *editor );
static void terminal_prefix_setup( NactPreferencesEditor *editor, NASettings *settings );
static void terminal_prefix_on_changed( GtkEntry *entry, NactPreferencesEditor *editor );
+static void desktop_create_model( NactPreferencesEditor *editor );
+static void desktop_setup( NactPreferencesEditor *editor, NASettings *settings );
+static void desktop_on_changed( GtkComboBox *combo, NactPreferencesEditor *editor );
static void relabel_menu_setup( NactPreferencesEditor *editor, NASettings *settings );
static void relabel_menu_on_toggled( GtkToggleButton *button, NactPreferencesEditor *editor );
static void relabel_action_setup( NactPreferencesEditor *editor, NASettings *settings );
@@ -339,6 +358,8 @@ on_base_initialize_gtk_toplevel( NactPreferencesEditor *editor, GtkDialog *tople
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
updater = nact_application_get_updater( application );
+ desktop_create_model( editor );
+
container = base_window_get_widget( BASE_WINDOW( editor ), "PreferencesExportFormatVBox" );
nact_export_format_init_display(
container, NA_PIVOT( updater ),
@@ -382,6 +403,7 @@ on_base_initialize_base_window( NactPreferencesEditor *editor )
/* second tab: runtime execution
*/
terminal_prefix_setup( editor, settings );
+ desktop_setup( editor, settings );
/* third tab: ui preferences
*/
@@ -593,6 +615,7 @@ about_item_on_toggled( GtkToggleButton *button, NactPreferencesEditor *editor )
/*
* terminal prefix
+ * the prefix to add to the command when execution mode is 'Terminal'
*/
static void
terminal_prefix_setup( NactPreferencesEditor *editor, NASettings *settings )
@@ -643,6 +666,105 @@ terminal_prefix_on_changed( GtkEntry *entry, NactPreferencesEditor *editor )
}
/*
+ * desktop environment
+ * for OnlyShowIn and NotshowIn contexts
+ */
+static void
+desktop_create_model( NactPreferencesEditor *editor )
+{
+ GtkWidget *combo;
+ GtkListStore *model;
+ GtkCellRenderer *text_cell;
+ const NADesktopEnv *desktops;
+ guint i;
+ GtkTreeIter row;
+
+ combo = base_window_get_widget( BASE_WINDOW( editor ), "DesktopComboBox" );
+ model = gtk_list_store_new( DESKTOP_N_COLUMN, G_TYPE_STRING, G_TYPE_STRING );
+ gtk_combo_box_set_model( GTK_COMBO_BOX( combo ), GTK_TREE_MODEL( model ));
+ g_object_unref( model );
+
+ /* id */
+ text_cell = gtk_cell_renderer_text_new();
+ gtk_cell_layout_pack_start( GTK_CELL_LAYOUT( combo ), text_cell, FALSE );
+ gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT( combo ), text_cell, "text", 0, NULL );
+ gtk_cell_renderer_set_visible( GTK_CELL_RENDERER( text_cell ), FALSE );
+
+ /* label */
+ text_cell = gtk_cell_renderer_text_new();
+ gtk_cell_layout_pack_start( GTK_CELL_LAYOUT( combo ), text_cell, TRUE );
+ gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT( combo ), text_cell, "text", 0, NULL );
+ gtk_cell_renderer_set_visible( GTK_CELL_RENDERER( text_cell ), TRUE );
+
+ gtk_list_store_append( model, &row );
+ gtk_list_store_set( model, &row,
+ DESKTOP_ID_COLUMN, st_no_desktop.id,
+ DESKTOP_LABEL_COLUMN, gettext( st_no_desktop.label ),
+ -1 );
+
+ desktops = na_desktop_environment_get_known_list();
+
+ for( i = 0 ; desktops[i].id ; ++i ){
+ gtk_list_store_append( model, &row );
+ gtk_list_store_set( model, &row,
+ DESKTOP_ID_COLUMN, desktops[i].id,
+ DESKTOP_LABEL_COLUMN, gettext( desktops[i].label ),
+ -1 );
+ }
+}
+
+static void
+desktop_setup( NactPreferencesEditor *editor, NASettings *settings )
+{
+ gboolean editable;
+ GtkWidget *combo;
+ const NADesktopEnv *desktops;
+ guint i;
+ gint found;
+
+ editor->private->desktop = na_settings_get_string( settings, NA_IPREFS_DESKTOP_ENVIRONMENT, NULL, &editor->private->desktop_mandatory );
+ editable = !editor->private->preferences_locked && !editor->private->desktop_mandatory;
+
+ combo = base_window_get_widget( BASE_WINDOW( editor ), "DesktopComboBox" );
+ found = -1;
+
+ if( editor->private->desktop && strlen( editor->private->desktop )){
+ desktops = na_desktop_environment_get_known_list();
+ for( i = 0 ; desktops[i].id && found == -1 ; ++i ){
+ if( !strcmp( desktops[i].id, editor->private->desktop )){
+ found = 1+i;
+ }
+ }
+ }
+
+ gtk_combo_box_set_active( GTK_COMBO_BOX( combo ), found );
+
+ base_window_signal_connect( BASE_WINDOW( editor ),
+ G_OBJECT( combo ), "changed", G_CALLBACK( desktop_on_changed ));
+}
+
+static void
+desktop_on_changed( GtkComboBox *combo, NactPreferencesEditor *editor )
+{
+ gboolean editable;
+ gint active;
+ const NADesktopEnv *desktops;
+
+ editable = !editor->private->preferences_locked && !editor->private->desktop_mandatory;
+
+ if( editable ){
+ g_free( editor->private->desktop );
+ editor->private->desktop = NULL;
+
+ active = gtk_combo_box_get_active( combo );
+ if( active > 0 ){
+ desktops = na_desktop_environment_get_known_list();
+ editor->private->desktop = g_strdup( desktops[active-1].id );
+ }
+ }
+}
+
+/*
* relabel copied/paster menu ?
*/
static void
@@ -1010,6 +1132,9 @@ on_dialog_ok( BaseDialog *dialog )
if( !editor->private->terminal_prefix_mandatory ){
na_settings_set_string( settings, NA_IPREFS_TERMINAL_PREFIX, editor->private->terminal_prefix );
}
+ if( !editor->private->desktop_mandatory ){
+ na_settings_set_string( settings, NA_IPREFS_DESKTOP_ENVIRONMENT, editor->private->desktop );
+ }
/* third tab: ui preferences
*/
diff --git a/src/nact/nact-preferences.ui b/src/nact/nact-preferences.ui
index f1cc0d1..1d004a2 100644
--- a/src/nact/nact-preferences.ui
+++ b/src/nact/nact-preferences.ui
@@ -278,6 +278,80 @@ This prefix should be so that the terminal is kept opened after the execution.</
</packing>
</child>
<child>
+ <object class="GtkFrame" id="frame720">
+ <property name="visible">True</property>
+ <property name="border_width">6</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkAlignment" id="alignment720">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkVBox" id="vbox721">
+ <property name="visible">True</property>
+ <property name="border_width">6</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkTable" id="table721">
+ <property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">4</property>
+ <property name="row_spacing">4</property>
+ <child>
+ <object class="GtkLabel" id="label721">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Running _desktop environment :</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="DesktopComboBox">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label720">
+ <property name="visible">True</property>
+ <property name="xpad">5</property>
+ <property name="label" translatable="yes"><b>Desktop environment</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<placeholder/>
</child>
</object>
@@ -289,7 +363,7 @@ This prefix should be so that the terminal is kept opened after the execution.</
<object class="GtkLabel" id="label700">
<property name="visible">True</property>
<property name="tooltip_text" translatable="yes">This tab lets you specify parameters needed for. some execution modes.</property>
- <property name="label" translatable="yes">E_xecution</property>
+ <property name="label" translatable="yes">Runtime E_xecution</property>
<property name="use_underline">True</property>
</object>
<packing>
@@ -1078,4 +1152,10 @@ You can add a new scheme by clicking on the '+' button.</property>
<action-widget response="0">OKButton</action-widget>
</action-widgets>
</object>
+ <object class="GtkSizeGroup" id="RuntimeExecutionLabel">
+ <widgets>
+ <widget name="label711"/>
+ <widget name="label721"/>
+ </widgets>
+ </object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]