[evolution-kolab] EPlugin: added new util function for label generation



commit dce919fd5c05999752e0d74e80c4ef68da76b594
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Wed Jun 6 16:44:16 2012 +0200

    EPlugin: added new util function for label generation
    
    * added function to generate GtkLabel instances
      with proper configuration

 src/eplugin/e-kolab-plugin-util.c |   63 +++++++++++++++++++++++++++++++-----
 src/eplugin/e-kolab-plugin-util.h |    7 +++-
 2 files changed, 60 insertions(+), 10 deletions(-)
---
diff --git a/src/eplugin/e-kolab-plugin-util.c b/src/eplugin/e-kolab-plugin-util.c
index 3c20988..1ef8bd5 100644
--- a/src/eplugin/e-kolab-plugin-util.c
+++ b/src/eplugin/e-kolab-plugin-util.c
@@ -48,27 +48,72 @@
 /* API functions (UI) */
 
 GtkWidget*
-e_kolab_plugin_util_ui_selected_folder_widget (const gchar *foldername)
+e_kolab_plugin_util_ui_label_new (const gchar *text,
+                                  gboolean add_bottom_space)
 {
 	GtkWidget *label = NULL;
+
+	if (text == NULL)
+		return NULL;
+
+	label = gtk_label_new (text);
+	gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
+
+	if (add_bottom_space)
+		gtk_widget_set_margin_bottom (label, 5);
+
+	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0);
+
+	return label;
+}
+
+GtkWidget*
+e_kolab_plugin_util_ui_selected_folder_widget (const gchar *foldername,
+                                               const gchar *sourcename)
+{
+	GtkGrid *grid = NULL;
+	GtkWidget *label = NULL;
 	gchar *labeltext = NULL;
+	gint row = 0;
 
 	g_assert (foldername != NULL);
+	/* sourcname may be NULL */
+
+	grid = GTK_GRID (gtk_grid_new ());
+	gtk_grid_set_row_homogeneous (grid, FALSE);
+	gtk_grid_set_row_spacing (grid, 6);
+	gtk_grid_set_column_homogeneous (grid, FALSE);
+	gtk_grid_set_column_spacing (grid, 16);
+	gtk_container_set_border_width (GTK_CONTAINER (grid), 8);
+
+	if (sourcename != NULL) {
+		labeltext = g_strconcat ("<b>",
+		                         C_("Kolab Folder Properties",
+		                            "Selected Resource:"),
+		                         "</b>",
+		                         NULL);
+		label = e_kolab_plugin_util_ui_label_new (labeltext, FALSE);
+		g_free (labeltext);
+		gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+		gtk_grid_attach (grid, label, 0, row, 1, 1);
+		label = e_kolab_plugin_util_ui_label_new (sourcename, FALSE);
+		gtk_grid_attach (grid, label, 1, row, 1, 1);
+		row++;
+	}
 
-	label = gtk_label_new (NULL);
 	labeltext = g_strconcat ("<b>",
 	                         C_("Kolab Folder Properties",
 	                            "Selected Folder:"),
-	                         " </b>",
-	                         foldername,
+	                         "</b>",
 	                         NULL);
-	gtk_label_set_markup (GTK_LABEL (label), labeltext);
+	label = e_kolab_plugin_util_ui_label_new (labeltext, FALSE);
 	g_free (labeltext);
-	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
-	gtk_widget_set_margin_top (GTK_WIDGET (label), 4);
-	gtk_widget_set_margin_bottom (GTK_WIDGET (label), 4);
+	gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+	gtk_grid_attach (grid, label, 0, row, 1, 1);
+	label = e_kolab_plugin_util_ui_label_new (foldername, FALSE);
+	gtk_grid_attach (grid, label, 1, row, 1, 1);
 
-	return label;
+	return GTK_WIDGET (grid);
 }
 
 /*----------------------------------------------------------------------------*/
diff --git a/src/eplugin/e-kolab-plugin-util.h b/src/eplugin/e-kolab-plugin-util.h
index ecb16cb..6679162 100644
--- a/src/eplugin/e-kolab-plugin-util.h
+++ b/src/eplugin/e-kolab-plugin-util.h
@@ -37,7 +37,12 @@
 /*----------------------------------------------------------------------------*/
 
 GtkWidget*
-e_kolab_plugin_util_ui_selected_folder_widget (const gchar *foldername);
+e_kolab_plugin_util_ui_label_new (const gchar *text,
+                                  gboolean add_bottom_space);
+
+GtkWidget*
+e_kolab_plugin_util_ui_selected_folder_widget (const gchar *foldername,
+                                               const gchar *sourcename);
 
 /*----------------------------------------------------------------------------*/
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]