+
+static void
+menu_position_cb (GtkMenu *menu,
+ gint *x,
+ gint *y,
+ gboolean *push_in,
+ ModestShell *self)
+{
+ ModestShellPrivate *priv;
+ GtkAllocation *alloc;
+ GdkWindow *parent_window;
+ gint pos_x, pos_y;
+
+ priv = MODEST_SHELL_GET_PRIVATE (self);
+
+ alloc = &(GTK_WIDGET (priv->title_button)->allocation);
+ parent_window = gtk_widget_get_parent_window (GTK_WIDGET (priv->title_button));
+ gdk_window_get_position (parent_window, &pos_x, &pos_y);
+ *x = pos_x + alloc->x;
+ *y = pos_y + alloc->y + alloc->height;
+ *push_in = TRUE;
+
+}
+
+static void
+on_title_button_clicked (GtkToolButton *button, ModestShell *self)
+{
+ ModestShellPrivate *priv;
+ gint n_pages;
+ GtkWidget *child;
+ GtkWidget *menu;
+
+ priv = MODEST_SHELL_GET_PRIVATE (self);
+
+ n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
+ if (n_pages < 1)
+ return;
+
+ child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), -1);
+ menu = modest_shell_window_get_menu (MODEST_SHELL_WINDOW (child));
+
+ if (menu) {
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+ (GtkMenuPositionFunc) menu_position_cb, (gpointer) self,
+ 1, gtk_get_current_event_time ());
+ }
+}
+
+static void
+on_new_msg_button_clicked (GtkToolButton *button, ModestShell *self)
+{
+ ModestShellPrivate *priv;
+ gint n_pages;
+ GtkWidget *child;
+
+ priv = MODEST_SHELL_GET_PRIVATE (self);
+
+ n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
+ if (n_pages < 1)
+ return;
+
+ child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), -1);
+
+ modest_ui_actions_on_new_msg (NULL, MODEST_WINDOW (child));
+}
+
+static void
+on_style_set (GtkWidget *widget,
+ GtkStyle *old_style,
+ ModestShell *self)
+{
+ ModestShellPrivate *priv;
+ gint icon_w, icon_h;
+ GdkPixbuf *progress_pixbuf;
+ int n;
+
+ priv = MODEST_SHELL_GET_PRIVATE (self);
+
+ if (!gtk_icon_size_lookup (GTK_ICON_SIZE_LARGE_TOOLBAR, &icon_w, &icon_h))
+ return;
+ progress_pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), "process-working", icon_w, 0, NULL);
+
+ for (n = 0; n < 31; n++) {
+ if (priv->progress_frames[n] != NULL) {
+ g_object_unref (priv->progress_frames[n]);
+ }
+ priv->progress_frames[n] = NULL;
+ }
+
+ if (progress_pixbuf) {
+ gint max_x, max_y;
+ gint i, j;
+
+ icon_w = gdk_pixbuf_get_width (progress_pixbuf) / 8;
+
+ n = 0;
+ max_x = 8;
+ max_y = 4;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 8; j++) {
+ GdkPixbuf *frame;
+
+ if ((i == 0) && (j == 0))
+ continue;
+ frame = gdk_pixbuf_new_subpixbuf (progress_pixbuf,
+ j*icon_w, i*icon_w,
+ icon_w, icon_w);
+ priv->progress_frames[n] = frame;
+ n++;
+ }
+ }
+ g_object_unref (progress_pixbuf);
+ }
+
+}