gswitchit_plugins r97 - in trunk: . custlbls
- From: svu svn gnome org
- To: svn-commits-list gnome org
- Subject: gswitchit_plugins r97 - in trunk: . custlbls
- Date: Fri, 21 Mar 2008 22:45:19 +0000 (GMT)
Author: svu
Date: Fri Mar 21 22:45:18 2008
New Revision: 97
URL: http://svn.gnome.org/viewvc/gswitchit_plugins?rev=97&view=rev
Log:
custom labels are working now
Modified:
trunk/ChangeLog
trunk/custlbls/custlbls.c
trunk/custlbls/custlbls.glade
Modified: trunk/custlbls/custlbls.c
==============================================================================
--- trunk/custlbls/custlbls.c (original)
+++ trunk/custlbls/custlbls.c Fri Mar 21 22:45:18 2008
@@ -29,7 +29,8 @@
static GkbdIndicatorPluginContainer *container;
-static GSList * labelText = NULL;
+static GSList *layoutLabels = NULL;
+static GtkTreeModel *layoutLabelsModel = NULL;
static guint listener;
@@ -39,7 +40,16 @@
LoadConfig (void)
{
GError *gerror = NULL;
- labelText = gconf_client_get_list(container->conf_client, LABEL_TEXT_CONFIG_KEY, GCONF_VALUE_STRING, &gerror);
+ if (layoutLabels != NULL) {
+ g_slist_foreach (layoutLabels, (GFunc) g_free, NULL);
+ g_slist_free (layoutLabels);
+ layoutLabels = NULL;
+ }
+
+ layoutLabels =
+ 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);
@@ -56,7 +66,8 @@
cs = gconf_change_set_new ();
- gconf_change_set_set_list (cs, LABEL_TEXT_CONFIG_KEY, GCONF_VALUE_STRING, labelText);
+ gconf_change_set_set_list (cs, LABEL_TEXT_CONFIG_KEY,
+ GCONF_VALUE_STRING, layoutLabels);
gconf_client_commit_change_set (container->conf_client, cs, TRUE,
&gerror);
@@ -126,108 +137,141 @@
container = NULL;
}
-#if 0
static void
-UpdateColorChooserButtons ()
+AddLabelToList (gchar * labelText)
+{
+ GtkTreeIter iter;
+ gtk_list_store_append (GTK_LIST_STORE (layoutLabelsModel), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (layoutLabelsModel), &iter, 0,
+ labelText, -1);
+}
+
+static void
+UpdateList ()
+{
+ GtkWidget *list = glade_xml_get_widget (data, "lstLabels");
+ if (layoutLabelsModel == NULL) {
+ layoutLabelsModel =
+ GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_STRING));
+ gtk_tree_view_set_model (GTK_TREE_VIEW (list),
+ GTK_TREE_MODEL
+ (layoutLabelsModel));
+ } else {
+ gtk_list_store_clear (GTK_LIST_STORE (layoutLabelsModel));
+ }
+ g_slist_foreach (layoutLabels, (GFunc) AddLabelToList, NULL);
+
+}
+
+static void
+AddLabel (GtkButton * btn)
+{
+ GtkWidget *txtLabel = glade_xml_get_widget (data, "txtLabel");
+ layoutLabels =
+ g_slist_append (layoutLabels,
+ g_strdup (gtk_entry_get_text
+ (GTK_ENTRY (txtLabel))));
+ gtk_entry_set_text (GTK_ENTRY (txtLabel), "");
+ SaveConfig ();
+ UpdateList ();
+}
+
+static void
+DelLabel (GtkButton * btn)
{
- 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);
+ GtkWidget *list = glade_xml_get_widget (data, "lstLabels");
+ GtkTreeIter iter;
+
+ GtkTreeSelection *selection =
+ gtk_tree_view_get_selection (GTK_TREE_VIEW (list));
+
+ if (gtk_tree_selection_get_selected (selection, NULL, &iter)) {
+ GtkTreePath *path =
+ gtk_tree_model_get_path (layoutLabelsModel, &iter);
+ int idx = gtk_tree_path_get_indices (path)[0];
+ gtk_tree_path_free (path);
+ if (idx != -1) {
+ GSList *deletable =
+ g_slist_nth (layoutLabels, idx);
+ if (deletable != NULL) {
+ g_free (deletable->data);
+ layoutLabels =
+ g_slist_delete_link (layoutLabels,
+ deletable);
+ SaveConfig ();
+ UpdateList ();
+ }
+ }
+ }
}
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 ();
+ListSelectionChanged (GtkTreeSelection * selection)
+{
+ GtkWidget *list = glade_xml_get_widget (data, "lstLabels");
+ GtkWidget *btnDel = glade_xml_get_widget (data, "btnDelete");
+ GtkWidget *txtLabel = glade_xml_get_widget (data, "txtLabel");
+
+ GtkTreeIter selectedIter;
+ gboolean isAnythingSelected = FALSE;
+
+
+ if (gtk_tree_selection_get_selected
+ (selection, NULL, &selectedIter)) {
+ isAnythingSelected = TRUE;
}
- gtk_widget_destroy (dlgSelection);
+ gtk_widget_set_sensitive (btnDel, isAnythingSelected);
}
static void
ConfigurePlugin (GkbdIndicatorPluginContainer * pc, GtkWindow * parent)
{
GtkWidget *dialog;
+ GtkWidget *list;
+ GtkTreeSelection *selection;
+ GtkCellRenderer *renderer =
+ GTK_CELL_RENDERER (gtk_cell_renderer_text_new ());
+ GtkTreeViewColumn *column =
+ gtk_tree_view_column_new_with_attributes (NULL, renderer,
+ "text", 0,
+ NULL);
container = pc;
LoadConfig ();
data =
- glade_xml_new (GLADE_DIR "/highlight.glade",
- "highlight_dialog", PACKAGE);
+ glade_xml_new (GLADE_DIR "/custlbls.glade",
+ "custlbls_dialog", PACKAGE);
- dialog = glade_xml_get_widget (data, "highlight_dialog");
+ dialog = glade_xml_get_widget (data, "custlbls_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);
+ "on_btnAdd_clicked",
+ GTK_SIGNAL_FUNC (AddLabel), NULL);
glade_xml_signal_connect_data (data,
- "on_btnBgColor_clicked",
- GTK_SIGNAL_FUNC (ChooseColor),
- &bgColor);
+ "on_btnDelete_clicked",
+ GTK_SIGNAL_FUNC (DelLabel), NULL);
- UpdateColorChooserButtons ();
+ list = glade_xml_get_widget (data, "lstLabels");
+
+ gtk_tree_view_append_column (GTK_TREE_VIEW (list), column);
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+
+ g_signal_connect (G_OBJECT (selection), "changed",
+ G_CALLBACK (ListSelectionChanged), NULL);
+
+ UpdateList ();
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)
{
@@ -242,13 +286,17 @@
static GtkWidget *
ChangeLabel (GtkWidget * widget, const gint group, const char
- *groupDescription, GkbdKeyboardConfig * config)
+ *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);
+ GSList *listItem = g_slist_nth (layoutLabels, group);
+ gtk_label_set_text (GTK_LABEL (label),
+ listItem ==
+ NULL ? g_strdup_printf ("G%d",
+ group) :
+ listItem->data);
}
return widget;
@@ -270,8 +318,8 @@
gswitchitPlugin.init_callback = PluginInit;
gswitchitPlugin.term_callback = PluginTerm;
gswitchitPlugin.decorate_widget_callback = ChangeLabel;
- /*gswitchitPlugin.configure_properties_callback =
- ConfigurePlugin;*/
+ gswitchitPlugin.configure_properties_callback =
+ ConfigurePlugin;
}
return &gswitchitPlugin;
}
Modified: trunk/custlbls/custlbls.glade
==============================================================================
--- trunk/custlbls/custlbls.glade (original)
+++ trunk/custlbls/custlbls.glade Fri Mar 21 22:45:18 2008
@@ -1,189 +1,133 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
-
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
<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>
-
+ <widget class="GtkDialog" id="custlbls_dialog">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Custom Labels</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox2">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkVBox" id="vbox4">
+ <property name="visible">True</property>
+ <property name="border_width">6</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Label:</property>
+ <property name="use_underline">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="txtLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkTreeView" id="lstLabels">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="headers_clickable">True</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="spacing">3</property>
+ <child>
+ <widget class="GtkButton" id="btnAdd">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="label" translatable="yes">gtk-add</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ <signal name="clicked" handler="on_btnAdd_clicked"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="btnDelete">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="label" translatable="yes">gtk-remove</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ <signal name="clicked" handler="on_btnDelete_clicked"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">3</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <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="btnClose">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="label">gtk-close</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">-7</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
</glade-interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]