gswitchit_plugins r96 - in trunk: . custlbls
- From: svu svn gnome org
- To: svn-commits-list gnome org
- Subject: gswitchit_plugins r96 - in trunk: . custlbls
- Date: Wed, 19 Mar 2008 00:31:22 +0000 (GMT)
Author: svu
Date: Wed Mar 19 00:31:22 2008
New Revision: 96
URL: http://svn.gnome.org/viewvc/gswitchit_plugins?rev=96&view=rev
Log:
added custom labels plugin
Added:
trunk/custlbls/
trunk/custlbls/.indent.pro
trunk/custlbls/Makefile.am
trunk/custlbls/custlbls.c
trunk/custlbls/custlbls.glade
Modified:
trunk/ChangeLog
trunk/Makefile.am
trunk/configure.in
Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am (original)
+++ trunk/Makefile.am Wed Mar 19 00:31:22 2008
@@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in.
# SUBDIRS=po grp4app flags highlight sound test
-SUBDIRS=po anim flags highlight sound test
+SUBDIRS=po anim custlbls flags highlight sound test
schemasdir = @GCONF_SCHEMA_FILE_DIR@
schemas_in_files = gswitchit_plugins.schemas.in
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Wed Mar 19 00:31:22 2008
@@ -69,6 +69,7 @@
AC_OUTPUT([Makefile
po/Makefile.in
anim/Makefile
+custlbls/Makefile
flags/Makefile
highlight/Makefile
sound/Makefile
Added: trunk/custlbls/.indent.pro
==============================================================================
--- (empty file)
+++ trunk/custlbls/.indent.pro Wed Mar 19 00:31:22 2008
@@ -0,0 +1,2 @@
+-kr -i8 -pcs -lps -psl
+
Added: trunk/custlbls/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/custlbls/Makefile.am Wed Mar 19 00:31:22 2008
@@ -0,0 +1,16 @@
+plugin_cFLAGS = -I$(top_srcdir) \
+ $(LINKED_GNOME_CFLAGS) \
+ -DG_LOG_DOMAIN=\"GSwitchIt\" \
+ -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
+ -I../intl -I.. -I$(top_srcdir)/intl \
+ -DGLADE_DIR=\""$(gladedir)"\" \
+ $(OTHER_CFLAGS)
+
+plugin_DATA = custlbls.so
+
+gladedir = $(GLADE_DIR)
+glade_DATA = custlbls.glade
+
+EXTRA_DIST = custlbls.c ${glade_DATA}
+
+include ../plugins.make
Added: trunk/custlbls/custlbls.c
==============================================================================
--- (empty file)
+++ trunk/custlbls/custlbls.c Wed Mar 19 00:31:22 2008
@@ -0,0 +1,277 @@
+/*
+ * 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 Library 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.
+ */
+
+#include "config.h"
+
+#include <gmodule.h>
+#include <gnome.h>
+
+#include <glade/glade.h>
+
+#include "libgnomekbd/gkbd-indicator-plugin.h"
+
+#define PLUGIN_GCONF_DIR "/apps/" PACKAGE "/CustomLabels"
+
+#define LABEL_TEXT_CONFIG_KEY ( PLUGIN_GCONF_DIR "/LabelText" )
+
+static GkbdIndicatorPluginContainer *container;
+
+static GSList * labelText = NULL;
+
+static guint listener;
+
+static GladeXML *data;
+
+static void
+LoadConfig (void)
+{
+ GError *gerror = NULL;
+ labelText = gconf_client_get_list(container->conf_client, LABEL_TEXT_CONFIG_KEY, GCONF_VALUE_STRING, &gerror);
+ if (gerror != NULL) {
+ g_warning ("Error loading configuration: %s\n",
+ gerror->message);
+ g_error_free (gerror);
+ gerror = NULL;
+ }
+}
+
+static void
+SaveConfig (void)
+{
+ GConfChangeSet *cs;
+ GError *gerror = NULL;
+
+ cs = gconf_change_set_new ();
+
+ gconf_change_set_set_list (cs, LABEL_TEXT_CONFIG_KEY, GCONF_VALUE_STRING, labelText);
+
+ gconf_client_commit_change_set (container->conf_client, cs, TRUE,
+ &gerror);
+ if (gerror != NULL) {
+ g_warning ("Error saving configuration: %s\n",
+ gerror->message);
+ g_error_free (gerror);
+ gerror = NULL;
+ }
+ gconf_change_set_unref (cs);
+}
+
+static void
+ConfigChangedCallback (GConfClient * client,
+ guint cnxn_id, GConfEntry * entry)
+{
+ LoadConfig ();
+ gkbd_indicator_plugin_container_reinit_ui (container);
+}
+
+static void
+StartListening (void)
+{
+ GError *err = NULL;
+ listener = gconf_client_notify_add (container->conf_client,
+ PLUGIN_GCONF_DIR,
+ (GConfClientNotifyFunc)
+ ConfigChangedCallback, NULL,
+ NULL, &err);
+ if (0 == listener) {
+ g_warning ("Error listening for configuration: [%s]\n",
+ err->message);
+ g_error_free (err);
+ }
+}
+
+static void
+StopListening (void)
+{
+ gconf_client_notify_remove (container->conf_client, listener);
+}
+
+static gboolean
+PluginInit (GkbdIndicatorPluginContainer * pc)
+{
+ GError *gerror = NULL;
+ container = pc;
+
+ gconf_client_add_dir (container->conf_client,
+ PLUGIN_GCONF_DIR,
+ GCONF_CLIENT_PRELOAD_NONE, &gerror);
+ if (gerror != NULL) {
+ g_error ("err: %s\n", gerror->message);
+ g_error_free (gerror);
+ gerror = NULL;
+ return FALSE;
+ }
+ LoadConfig ();
+ StartListening ();
+ return TRUE;
+}
+
+static void
+PluginTerm (void)
+{
+ StopListening ();
+ container = NULL;
+}
+
+#if 0
+static void
+UpdateColorChooserButtons ()
+{
+ gtk_widget_modify_bg (glade_xml_get_widget (data, "btnFgColor"),
+ GTK_STATE_NORMAL, &fgColor);
+ gtk_widget_modify_bg (glade_xml_get_widget (data, "btnFgColor"),
+ GTK_STATE_ACTIVE, &fgColor);
+ gtk_widget_modify_bg (glade_xml_get_widget (data, "btnFgColor"),
+ GTK_STATE_PRELIGHT, &fgColor);
+ gtk_widget_modify_bg (glade_xml_get_widget (data, "btnFgColor"),
+ GTK_STATE_SELECTED, &fgColor);
+
+ gtk_widget_modify_bg (glade_xml_get_widget (data, "btnBgColor"),
+ GTK_STATE_NORMAL, &bgColor);
+ gtk_widget_modify_bg (glade_xml_get_widget (data, "btnBgColor"),
+ GTK_STATE_ACTIVE, &bgColor);
+ gtk_widget_modify_bg (glade_xml_get_widget (data, "btnBgColor"),
+ GTK_STATE_PRELIGHT, &bgColor);
+ gtk_widget_modify_bg (glade_xml_get_widget (data, "btnBgColor"),
+ GTK_STATE_SELECTED, &bgColor);
+}
+
+static void
+ChooseColor (GtkButton * btn, GdkColor * color)
+{
+ GtkWidget *dlgSelection;
+ gint dr;
+ dlgSelection =
+ gtk_color_selection_dialog_new (dgettext
+ (PACKAGE, "Choose the color"));
+ gtk_color_selection_set_current_color (GTK_COLOR_SELECTION
+ (GTK_COLOR_SELECTION_DIALOG
+ (dlgSelection)->colorsel),
+ color);
+ gtk_window_set_modal (GTK_WINDOW (dlgSelection), TRUE);
+ dr = gtk_dialog_run (GTK_DIALOG (dlgSelection));
+ if (GTK_RESPONSE_OK == dr) {
+ gtk_color_selection_get_current_color (GTK_COLOR_SELECTION
+ (GTK_COLOR_SELECTION_DIALOG
+ (dlgSelection)->
+ colorsel), color);
+ UpdateColorChooserButtons ();
+ SaveConfig ();
+ }
+ gtk_widget_destroy (dlgSelection);
+}
+
+static void
+ConfigurePlugin (GkbdIndicatorPluginContainer * pc, GtkWindow * parent)
+{
+ GtkWidget *dialog;
+
+ container = pc;
+
+ LoadConfig ();
+
+ data =
+ glade_xml_new (GLADE_DIR "/highlight.glade",
+ "highlight_dialog", PACKAGE);
+
+ dialog = glade_xml_get_widget (data, "highlight_dialog");
+ gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
+
+ glade_xml_signal_connect_data (data,
+ "on_btnFgColor_clicked",
+ GTK_SIGNAL_FUNC (ChooseColor),
+ &fgColor);
+
+ glade_xml_signal_connect_data (data,
+ "on_btnBgColor_clicked",
+ GTK_SIGNAL_FUNC (ChooseColor),
+ &bgColor);
+
+ UpdateColorChooserButtons ();
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ container = NULL;
+}
+
+static void
+ClearBGPixmaps (GtkWidget * widget, GtkRcStyle * rc_style)
+{
+ /* Just resetting the styles to the theme -
+ no funny transparent BG or anything */
+ gtk_widget_set_style (widget, NULL);
+ gtk_widget_modify_style (widget, rc_style);
+
+ /* go down */
+ if (GTK_IS_CONTAINER (widget)) {
+ GList *child =
+ gtk_container_get_children (GTK_CONTAINER (widget));
+ while (child != NULL) {
+ ClearBGPixmaps (GTK_WIDGET (child->data),
+ rc_style);
+ child = child->next;
+ }
+ }
+}
+#endif
+static GtkWidget *
+FindChildLabel (GtkWidget * widget)
+{
+ GtkWidget *child = widget;
+ /* go down till first non-bin widget */
+ while (GTK_IS_BIN (child)) {
+ child = GTK_BIN (child)->child;
+ }
+
+ return GTK_IS_LABEL (child) ? child : NULL;
+}
+
+static GtkWidget *
+ChangeLabel (GtkWidget * widget, const gint group, const char
+ *groupDescription, GkbdKeyboardConfig * config)
+{
+ GtkWidget *label = FindChildLabel (widget);
+
+ if (label != NULL) {
+ GSList * listItem = g_slist_nth(labelText, group);
+ gtk_label_set_text(GTK_LABEL(label), listItem == NULL ? g_strdup_printf("G%d",group) : listItem->data);
+ }
+
+ return widget;
+}
+
+G_MODULE_EXPORT const GkbdIndicatorPlugin *
+GetPlugin (void)
+{
+ static GkbdIndicatorPlugin gswitchitPlugin = { NULL };
+ if (gswitchitPlugin.name == NULL) {
+ bindtextdomain (PACKAGE, GNOMELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+ gswitchitPlugin.name = dgettext (PACKAGE, "Custom Labels");
+ gswitchitPlugin.description =
+ dgettext (PACKAGE,
+ "Sets custom labels on the indicator");
+ /* functions */
+ gswitchitPlugin.init_callback = PluginInit;
+ gswitchitPlugin.term_callback = PluginTerm;
+ gswitchitPlugin.decorate_widget_callback = ChangeLabel;
+ /*gswitchitPlugin.configure_properties_callback =
+ ConfigurePlugin;*/
+ }
+ return &gswitchitPlugin;
+}
Added: trunk/custlbls/custlbls.glade
==============================================================================
--- (empty file)
+++ trunk/custlbls/custlbls.glade Wed Mar 19 00:31:22 2008
@@ -0,0 +1,189 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+<requires lib="gnome"/>
+
+<widget class="GtkDialog" id="highlight_dialog">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Highlighter plugin properties</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="has_separator">True</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area2">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="btnCloseHighlightPluginSettings">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-close</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="response_id">-7</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox4">
+ <property name="border_width">6</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkLabel" id="label18">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Text color</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment14">
+ <property name="border_width">6</property>
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">1</property>
+ <property name="yscale">1</property>
+
+ <child>
+ <widget class="GtkButton" id="btnFgColor">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes"> </property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <signal name="clicked" handler="on_btnFgColor_clicked" last_modification_time="Mon, 08 Sep 2003 00:50:46 GMT"/>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkLabel" id="label19">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Background color</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment15">
+ <property name="border_width">6</property>
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">1</property>
+ <property name="yscale">1</property>
+
+ <child>
+ <widget class="GtkButton" id="btnBgColor">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes"> </property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <signal name="clicked" handler="on_btnBgColor_clicked" last_modification_time="Mon, 08 Sep 2003 00:50:59 GMT"/>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+</glade-interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]