[anjal] Fix Anjal's toolbar. Make it a proper GtkToolbar to be themable.



commit cbf9a4d7aed66f8e2526cc05994896780aaf6375
Author: Srinivasa Ragavan <sragavan novell com>
Date:   Fri Jun 12 12:19:42 2009 +0530

    Fix Anjal's toolbar. Make it a proper GtkToolbar to be themable.

 src/mail-shell.c |  124 ++++++++++++++++++++++++++----------------------------
 1 files changed, 60 insertions(+), 64 deletions(-)
---
diff --git a/src/mail-shell.c b/src/mail-shell.c
index 4fc5614..9e48369 100644
--- a/src/mail-shell.c
+++ b/src/mail-shell.c
@@ -280,13 +280,16 @@ ms_show_post_druid (MailViewChild *mfv, MailShell *shell)
 	mail_view_add_page ((MailView *)shell->mail_component->mail_view, MAIL_VIEW_SETTINGS, NULL);
 }
 
+#define PACK_IN_TOOL(wid,icon)	{ GtkWidget *tbox; tbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start ((GtkBox *)tbox, gtk_image_new_from_icon_name(icon, GTK_ICON_SIZE_DND), FALSE, FALSE, 0); wid = (GtkWidget *)gtk_tool_button_new (tbox, NULL); }
+
 void
 mail_shell_construct (MailShell *shell)
 {
 	MailShellPrivate *priv = shell->priv;
 	GtkWidget *tmp, *img, *box, *ar1, *ar2;
 	GtkStyle *style = gtk_widget_get_default_style ();
-	
+	int window_width = 1024;
+
 	mail_decoration_new ((GtkWindow *)shell);
 	ms_init_style (style);
 	g_signal_connect ((GObject *)shell, "delete-event", G_CALLBACK (ms_delete_event), NULL);
@@ -294,100 +297,100 @@ mail_shell_construct (MailShell *shell)
 	gtk_container_set_border_width (GTK_CONTAINER (shell), 1);
 	if (g_getenv("ANJAL_NO_MAX") == NULL && !windowed) {
 		 GdkScreen *scr = gtk_widget_get_screen ((GtkWidget *)shell);
+		 window_width = gdk_screen_get_width(scr);
 		 gtk_window_set_default_size ((GtkWindow *)shell, gdk_screen_get_width(scr), gdk_screen_get_height (scr));
 	} else
 		gtk_window_set_default_size ((GtkWindow *)shell, 1024, 500);/* We officiall should support 800x600 */
 	
 
 
-	priv->box = (GtkWidget *) gtk_vbox_new (FALSE, 1);
+	priv->box = (GtkWidget *) gtk_vbox_new (FALSE, 0);
 	gtk_widget_show ((GtkWidget *)priv->box);
 	
-	priv->top_bar = (GtkWidget *) gtk_hbox_new (FALSE, 6);
-	g_signal_connect (priv->top_bar, "expose-event",
-					  G_CALLBACK (color_expose),
-						  shell);
-	gtk_box_pack_start ((GtkBox *)priv->box, priv->top_bar, FALSE, FALSE, 4);
+	/* Toolbar */
+	priv->top_bar = gtk_toolbar_new ();
+	gtk_box_pack_start ((GtkBox *)priv->box, priv->top_bar, FALSE, FALSE, 0);
 	gtk_widget_show (priv->top_bar);
+	gtk_widget_set_size_request (priv->top_bar, -1, 48);	
 
-	
-	priv->action_bar = (GtkWidget *) gtk_hbox_new (FALSE, 6);
-	gtk_box_pack_start ((GtkBox *)priv->top_bar, priv->action_bar, FALSE, FALSE, 0);
-	gtk_widget_show (priv->action_bar);
-
-	/* priv->new_mail = gtk_button_new_with_mnemonic (_("New email")); */
-	priv->new_mail = gtk_button_new_with_mnemonic (NULL);
-	gtk_button_set_relief ((GtkButton *)priv->new_mail, GTK_RELIEF_NONE);
+	/* New mail tool button */
+	PACK_IN_TOOL(priv->new_mail, "mail-message-new");
+	gtk_widget_show_all (priv->new_mail);
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)priv->new_mail, 0);
 
-	gtk_button_set_image ((GtkButton *)priv->new_mail, gtk_image_new_from_icon_name("mail-message-new", GTK_ICON_SIZE_BUTTON));
-	gtk_box_pack_start ((GtkBox *)priv->top_bar, priv->new_mail, FALSE, FALSE, 0);
-	gtk_widget_show (priv->new_mail);
-	
-	priv->check_mail = gtk_button_new ();
-	gtk_button_set_relief ((GtkButton *)priv->check_mail, GTK_RELIEF_NONE);
+	/* Check mail button and the spinner */
+	priv->check_mail = (GtkWidget *)gtk_tool_button_new (NULL, NULL);
 	box = gtk_hbox_new (FALSE, 0);
 	tmp = e_spinner_new_spinning_small_shown();
 	gtk_widget_hide(tmp);
 	g_object_set_data ((GObject *)priv->check_mail, "spinner", tmp);
 	gtk_box_pack_start ((GtkBox *)box, tmp, FALSE, FALSE, 0);
-	tmp = gtk_image_new_from_icon_name("mail-send-receive", GTK_ICON_SIZE_BUTTON);
+	tmp = gtk_image_new_from_icon_name("mail-send-receive", GTK_ICON_SIZE_DND);
 	gtk_widget_show(tmp);
 	g_object_set_data ((GObject *)priv->check_mail, "icon", tmp);
 	gtk_box_pack_start ((GtkBox *)box, tmp, FALSE, FALSE, 0);
-	/* tmp = gtk_label_new_with_mnemonic (_("Check _email"));
-	gtk_widget_show(tmp);
-	gtk_box_pack_start ((GtkBox *)box, tmp, FALSE, FALSE, 2);*/
-	gtk_container_add ((GtkContainer *)priv->check_mail, box);
 	gtk_widget_show(box);
-	gtk_box_pack_start ((GtkBox *)priv->top_bar, priv->check_mail, FALSE, FALSE, 0);
+	gtk_tool_button_set_icon_widget ((GtkToolButton *)priv->check_mail, box);
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)priv->check_mail, 1);
 	gtk_widget_show (priv->check_mail);
 	g_signal_connect (priv->check_mail, "clicked", G_CALLBACK(ms_check_mail), shell);
-		 
-	priv->search_bar = (GtkWidget *) gtk_hbox_new (FALSE, 6);
-	gtk_box_pack_start ((GtkBox *)priv->top_bar, priv->search_bar, TRUE, TRUE, 0);
+
+	/* Separator before Search */
+	tmp = (GtkWidget *)gtk_separator_tool_item_new ();
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)tmp, 2);
+	gtk_separator_tool_item_set_draw  ((GtkSeparatorToolItem *)tmp, FALSE);
+	gtk_widget_set_size_request (tmp, 20, -1);
+	gtk_widget_show (tmp);
+
+	/* Search bar */
+	priv->search_bar = (GtkWidget *)gtk_tool_item_new ();
+	gtk_tool_item_set_expand ((GtkToolItem *)priv->search_bar, TRUE);
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)priv->search_bar, 3);
 	gtk_widget_show (priv->search_bar);
+	tmp = gtk_vbox_new (FALSE, 0);
+	gtk_widget_show (tmp);
 	priv->search_entry = (GtkWidget *)mail_search_new ();
 	((MailSearch *)priv->search_entry)->shell = shell;
 	gtk_widget_show (priv->search_entry);
-	gtk_box_pack_start ((GtkBox *)priv->search_bar, priv->search_entry, TRUE, TRUE, 24);
-	
-	priv->option_bar =(GtkWidget *) gtk_hbox_new (FALSE, 0);
-	gtk_widget_modify_bg (priv->option_bar, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
-	gtk_box_pack_end ((GtkBox *)priv->top_bar, priv->option_bar, FALSE, FALSE, 0);
-	
-	gtk_widget_show (priv->option_bar);
+	gtk_box_pack_start ((GtkBox *)tmp, priv->search_entry, TRUE, FALSE, 0);
+	gtk_container_add ((GtkContainer *)priv->search_bar, tmp);
+
+	/* Post search separator */
+	tmp = (GtkWidget *)gtk_separator_tool_item_new ();
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)tmp, 4);
+	gtk_separator_tool_item_set_draw  ((GtkSeparatorToolItem *)tmp, FALSE);
+	gtk_widget_set_size_request (tmp, 20, -1);
+	gtk_widget_show (tmp);
+
+	/* Sort combo */
 	tmp = gtk_hbox_new (FALSE, 0);
-	priv->sort = gtk_button_new  ();
 	gtk_box_pack_start ((GtkBox *)tmp, gtk_label_new (_("Sort By")), FALSE, FALSE, 6);
 	gtk_box_pack_start ((GtkBox *)tmp, gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE), FALSE, FALSE, 0);
-	gtk_container_add ((GtkContainer *)priv->sort, tmp);
 	gtk_widget_show_all (tmp);
-	gtk_box_pack_start ((GtkBox *)priv->option_bar, priv->sort, FALSE, FALSE, 0);
-	gtk_widget_show (priv->sort);
+	priv->sort = (GtkWidget *)gtk_tool_button_new  (tmp, NULL);
+	gtk_widget_show_all (priv->sort);
 	g_signal_connect (priv->sort, "clicked", G_CALLBACK(popup_sort), shell);
-	
-//	priv->settings = gtk_button_new_with_mnemonic (_("Settings"));
-	priv->settings = gtk_button_new_with_mnemonic (NULL);	
-	gtk_button_set_relief ((GtkButton *)priv->settings, GTK_RELIEF_NONE);
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)priv->sort, 5);
 
-	gtk_button_set_image ((GtkButton *)priv->settings, gtk_image_new_from_icon_name("preferences-system", GTK_ICON_SIZE_BUTTON));
-	gtk_box_pack_start ((GtkBox *)priv->option_bar, priv->settings, FALSE, FALSE, 6);
-	gtk_widget_show (priv->settings);
+	/* Settings button */
+	PACK_IN_TOOL(priv->settings, "preferences-system");
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)priv->settings, 6);
+	gtk_widget_show_all (priv->settings);
 	g_signal_connect (priv->settings, "clicked", G_CALLBACK (settings_btn_clicked), shell);
 
-	priv->quit = gtk_button_new ();	
-	tmp = gtk_image_new_from_icon_name("gtk-close", GTK_ICON_SIZE_BUTTON);
+	/* Post Settings separator */
+	tmp = (GtkWidget *)gtk_separator_tool_item_new ();
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)tmp, 7);
+	gtk_separator_tool_item_set_draw  ((GtkSeparatorToolItem *)tmp, FALSE);
 	gtk_widget_show (tmp);
-	gtk_container_add ((GtkContainer *)priv->quit, tmp);
-	gtk_button_set_relief ((GtkButton *)priv->quit, GTK_RELIEF_NONE);
-
-//	gtk_tool_button_set_icon_widget ((GtkButton *)priv->quit, gtk_image_new_from_icon_name("gtk-close", GTK_ICON_SIZE_BUTTON));
-	gtk_box_pack_start ((GtkBox *)priv->option_bar, priv->quit, FALSE, FALSE, 0);
-	gtk_widget_show (priv->quit);
+	
+	/* Close button */
+	PACK_IN_TOOL(priv->quit, "gtk-close");
+	gtk_toolbar_insert ((GtkToolbar *)priv->top_bar, (GtkToolItem *)priv->quit, 8);
+	gtk_widget_show_all (priv->quit);
 	g_signal_connect (priv->quit, "clicked", G_CALLBACK(mail_shell_quit_cb), shell);
 	
 	gtk_container_add ((GtkContainer *)shell, priv->box);
-	
 
 	shell->mail_component = mail_component_create ((GtkWidget *)shell, FALSE);
 	priv->side_pane = gtk_hpaned_new ();
@@ -397,7 +400,6 @@ mail_shell_construct (MailShell *shell)
 	mail_view_init_search ((MailView *)shell->mail_component->mail_view, priv->search_entry);
 
 	shell->priv->folder_pane = tmp;
-//	gtk_box_pack_start (priv->side_pane, tmp, FALSE, FALSE, 0);
 	gtk_paned_add1 ((GtkPaned *)priv->side_pane, tmp);
 	gtk_widget_show (priv->side_pane);
 	gtk_widget_show (tmp);
@@ -413,9 +415,6 @@ mail_shell_construct (MailShell *shell)
 	mail_view_set_folder_tree ((MailView *)shell->mail_component->mail_view, shell->mail_component->folder_tree);
 	gtk_widget_show (shell->mail_component->folder_tree);
 
-	//gtk_button_set_image ((GtkButton *)tmp, gtk_image_new_from_icon_name("stock_right", GTK_ICON_SIZE_BUTTON));	
-	//img = gtk_image_new_from_icon_name("stock_right", GTK_ICON_SIZE_BUTTON);	
-	//gtk_button_set_image ((GtkButton *)tmp, gtk_image_new_from_file(ANJAL_IMAGEDIR "arrow-right.png"));
 	tmp = gtk_button_new ();
 	box = gtk_hbox_new (FALSE, 0);
 	ar1 = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_NONE);
@@ -427,8 +426,6 @@ mail_shell_construct (MailShell *shell)
 	gtk_widget_hide (tmp);
 	gtk_widget_hide (ar1);
 	gtk_widget_hide (ar2);
-//	gtk_box_pack_start (priv->side_pane, tmp, FALSE, FALSE, 0);
-	//gtk_widget_set_size_request (tmp, 16, -1);
 	box = gtk_hbox_new (FALSE, 0);
 	gtk_box_pack_start ((GtkBox *)box, tmp, FALSE, FALSE, 0);
 	priv->slider = tmp;
@@ -440,7 +437,6 @@ mail_shell_construct (MailShell *shell)
 	gtk_paned_add2 ((GtkPaned *)priv->side_pane, box);
 	gtk_box_pack_start ((GtkBox *)priv->box, priv->side_pane, TRUE, TRUE, 6);
 
-//	mail_view_add_page (shell->mail_component->mail_view, MAIL_VIEW_FOLDER);
 	g_signal_connect (priv->new_mail, "clicked", G_CALLBACK (new_email_btn_clicked), 
 					  shell);
 	mail_view_set_slider ((MailView *)shell->mail_component->mail_view, priv->slider);



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