[Xfce4-commits] <xfce4-notes-plugin:master> Change tab option against a tabs position combobox

Mike Massonnet noreply at xfce.org
Sat Sep 19 03:44:04 CEST 2009


Updating branch refs/heads/master
         to 6e17529c8a357d278f53c66162ba765e8b6a6aa2 (commit)
       from 5df04cff0ad65126c99c59da6f5ea994f520d7c1 (commit)

commit 6e17529c8a357d278f53c66162ba765e8b6a6aa2
Author: Mike Massonnet <mike at debian.(none)>
Date:   Sat Sep 19 03:33:31 2009 +0200

    Change tab option against a tabs position combobox

 ChangeLog                           |   12 +++++++
 panel-plugin/application.vala       |   17 ++++++-----
 panel-plugin/defines.h              |    1 +
 panel-plugin/window.vala            |   55 ++++++++++++++++++++++++++++++++++-
 panel-plugin/xfce4-notes-settings.c |   47 +++++++++++++++++++++++++----
 5 files changed, 116 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4d0213a..49206de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2009-09-19  Mike Massonnet <mmassonnet at xfce.org>
+
+Change tab option against a tabs position combobox
+	* panel-plugin/application.vala:
+	  - Connect global xfconf bindings after loading the notes.
+	* panel-plugin/window.vala:
+	  - New property tabs-position with a function to update the angle of
+	  the labels in the tabs.
+	  - Set the border within the tabs to 4 and always show the border.
+	* panel-plugin/xfce4-notes-settings.c:
+	  - Drop the checkbox and add a combobox.
+
 2009-09-13  Mike Massonnet <mmassonnet at xfce.org>
 
 Set default font bigger
diff --git a/panel-plugin/application.vala b/panel-plugin/application.vala
index 8a254ed..dad4b0d 100644
--- a/panel-plugin/application.vala
+++ b/panel-plugin/application.vala
@@ -39,6 +39,7 @@ namespace Xnp {
 
 			string color = xfconf_channel.get_string ("/global/background-color", "#F2F1EF");
 			Xnp.Color.set_background (color);
+
 			xfconf_channel.property_changed += (channel, prop, val) => {
 				if (prop == "/global/background-color") {
 					Xnp.Color.set_background (val.get_string ());
@@ -81,14 +82,6 @@ namespace Xnp {
 		public Xnp.Window create_window (string? name = null) {
 			var window = new Xnp.Window ();
 
-			/* Global settings */
-			Xfconf.Property.bind (xfconf_channel, "/global/skip-taskbar-hint",
-				typeof (bool), window, "skip-taskbar-hint");
-			Xfconf.Property.bind (xfconf_channel, "/global/show-tabs",
-				typeof (bool), window, "show-tabs");
-			Xfconf.Property.bind (xfconf_channel, "/global/show-navbar",
-				typeof (bool), window, "show-navbar");
-
 			/* Default settings */
 			if (name == null) {
 				window.above = xfconf_channel.get_bool ("/new-window/always-on-top", false);
@@ -143,6 +136,14 @@ namespace Xnp {
 				this.load_window_data (window);
 			}
 
+			/* Global settings */
+			Xfconf.Property.bind (xfconf_channel, "/global/skip-taskbar-hint",
+				typeof (bool), window, "skip-taskbar-hint");
+			Xfconf.Property.bind (xfconf_channel, "/global/show-navbar",
+				typeof (bool), window, "show-navbar");
+			Xfconf.Property.bind (xfconf_channel, "/global/tabs-position",
+				typeof (int), window, "tabs-position");
+
 			/* Connect signals */
 			window.action += (win, action) => {
 				if (action == "rename") {
diff --git a/panel-plugin/defines.h b/panel-plugin/defines.h
index 70f5265..493d417 100644
--- a/panel-plugin/defines.h
+++ b/panel-plugin/defines.h
@@ -29,6 +29,7 @@
 #define GENERAL_HIDE_FROM_TASKBAR       TRUE
 #define GENERAL_SHOW_TABS               FALSE
 #define GENERAL_SHOW_NAVBAR             TRUE
+#define GENERAL_TABS_POSITION           0
 #define GENERAL_HIDE_ARROW_BUTTON       FALSE
 #define GENERAL_BACKGROUND_COLOR        BACKGROUND_YELLOW
 #define NEW_WINDOW_ABOVE                FALSE
diff --git a/panel-plugin/window.vala b/panel-plugin/window.vala
index 03eee94..0feaab6 100644
--- a/panel-plugin/window.vala
+++ b/panel-plugin/window.vala
@@ -103,6 +103,34 @@ namespace Xnp {
 			}
 		}
 
+		private int _tabs_position;
+		public int tabs_position {
+			get {
+				return this._tabs_position;
+			}
+			set {
+				this._tabs_position = value;
+				if (this._tabs_position == 0)
+					show_tabs = false;
+				else {
+					show_tabs = true;
+					_notebook_update_tabs_angle ();
+					if (this._tabs_position == 1)
+						this.notebook.tab_pos = Gtk.PositionType.TOP;
+					else if (this._tabs_position == 2)
+						this.notebook.tab_pos = Gtk.PositionType.RIGHT;
+					else if (this._tabs_position == 3)
+						this.notebook.tab_pos = Gtk.PositionType.BOTTOM;
+					else if (this._tabs_position == 4)
+						this.notebook.tab_pos = Gtk.PositionType.LEFT;
+					else {
+						this.show_tabs = false;
+						warning ("Bad value for tabs-position");
+					}
+				}
+			}
+		}
+
 		private bool _above;
 		public bool above {
 			get {
@@ -216,8 +244,10 @@ namespace Xnp {
 
 			/* Build Notebook */
 			this.notebook = new Gtk.Notebook ();
-			this.notebook.show_border = false;
+			this.notebook.show_border = true;
 			this.notebook.show_tabs = false;
+			this.notebook.tab_pos = Gtk.PositionType.TOP;
+			this.notebook.tab_border = 4;
 			this.notebook.scrollable = true;
 			this.notebook.show ();
 			this.content_box.pack_start (this.notebook, true, true, 0);
@@ -951,6 +981,7 @@ namespace Xnp {
 			this.notebook.insert_page (note, null, page);
 			note.name = note.name; //note.notify ("name");
 			this.note_inserted (note);
+			_notebook_update_tabs_angle ();
 			return note;
 		}
 
@@ -1119,6 +1150,28 @@ namespace Xnp {
 			}
 		}
 
+		/**
+		 * _notebook_update_tabs_angle:
+		 *
+		 * Set the angle of each label in the tab.
+		 */
+		private void _notebook_update_tabs_angle () {
+			int angle = 0;
+			if (_tabs_position == 2)
+				angle = 270;
+			else if (_tabs_position == 4)
+				angle = 90;
+
+			int pages = this.notebook.get_n_pages ();
+			for (int i = 0; i < pages; i++) {
+				var widget = this.notebook.get_nth_page (i);
+				var label = this.notebook.get_tab_label (widget) as Gtk.Label;
+				if (label is Gtk.Label) {
+					label.angle = angle;
+				}
+			}
+		}
+
 /*
 		static int main (string[] args) {
 			Gtk.init (ref args);
diff --git a/panel-plugin/xfce4-notes-settings.c b/panel-plugin/xfce4-notes-settings.c
index 625195f..f625da5 100644
--- a/panel-plugin/xfce4-notes-settings.c
+++ b/panel-plugin/xfce4-notes-settings.c
@@ -31,6 +31,17 @@
 
 enum
 {
+  COMBOBOX_TABS_NONE,
+  COMBOBOX_TABS_TOP,
+  COMBOBOX_TABS_RIGHT,
+  COMBOBOX_TABS_BOTTOM,
+  COMBOBOX_TABS_LEFT,
+};
+
+static GtkWidget *tabs_combo_box_new ();
+
+enum
+{
   COMBOBOX_SIZE_SMALL,
   COMBOBOX_SIZE_NORMAL,
   COMBOBOX_SIZE_LARGE,
@@ -111,13 +122,6 @@ prop_dialog_new ()
                           G_TYPE_BOOLEAN, G_OBJECT (button), "active");
   gtk_box_pack_start (GTK_BOX (box), button, TRUE, FALSE, 0);
 
-  /* Show tabs */
-  button = gtk_check_button_new_with_label (_("Show tabs in the notes"));
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), GENERAL_SHOW_TABS);
-  xfconf_g_property_bind (xfconf_channel, "/global/show-tabs",
-                          G_TYPE_BOOLEAN, G_OBJECT (button), "active");
-  gtk_box_pack_start (GTK_BOX (box), button, TRUE, FALSE, 0);
-
   /* Show navigation bar */
   button = gtk_check_button_new_with_label (_("Show the automatic navigation bar"));
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), GENERAL_SHOW_NAVBAR);
@@ -125,6 +129,16 @@ prop_dialog_new ()
                           G_TYPE_BOOLEAN, G_OBJECT (button), "active");
   gtk_box_pack_start (GTK_BOX (box), button, TRUE, FALSE, 0);
 
+  /* Tabs position */
+  hbox = gtk_hbox_new (FALSE, BORDER);
+  gtk_box_pack_start (GTK_BOX (box), hbox, TRUE, FALSE, 0);
+
+  label = gtk_label_new (_("Tabs position:"));
+  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+  button = tabs_combo_box_new ();
+  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+
   /* Background color */
   hbox = gtk_hbox_new (FALSE, BORDER);
   gtk_box_pack_start (GTK_BOX (box), hbox, TRUE, FALSE, 0);
@@ -187,6 +201,25 @@ prop_dialog_new ()
 }
 
 static GtkWidget *
+tabs_combo_box_new ()
+{
+  GtkWidget *combobox;
+
+  combobox = gtk_combo_box_new_text ();
+  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("None"));
+  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Top"));
+  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Right"));
+  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Bottom"));
+  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Left"));
+  gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);
+
+  xfconf_g_property_bind (xfconf_channel, "/global/tabs-position",
+                          G_TYPE_INT, G_OBJECT (combobox), "active");
+
+  return combobox;
+}
+
+static GtkWidget *
 size_combo_box_new ()
 {
   GtkWidget *combobox;



More information about the Xfce4-commits mailing list