summaryrefslogtreecommitdiff
path: root/endless
diff options
context:
space:
mode:
authorMatt Watson <mattdangerw@gmail.com>2014-01-16 11:54:18 -0800
committerMatt Watson <mattdangerw@gmail.com>2014-01-16 11:59:05 -0800
commitadd9956bde3185af9c9125278664c1006b884046 (patch)
tree6363b4d3bbf4004fa86118ca74adfc253ee4b92f /endless
parent47a8558f3672acd9c793815cfc11012c61daf263 (diff)
Added a maximize button to eos-topbar
Which toggles the application between a maximized and unmaximized state. All applications will still start maximized by default. [endlessm/eos-sdk#477]
Diffstat (limited to 'endless')
-rw-r--r--endless/eostopbar.c44
-rw-r--r--endless/eoswindow.c47
2 files changed, 82 insertions, 9 deletions
diff --git a/endless/eostopbar.c b/endless/eostopbar.c
index 6975e39..8da01e6 100644
--- a/endless/eostopbar.c
+++ b/endless/eostopbar.c
@@ -15,7 +15,7 @@
* The #EosTopBar has three different areas that can be managed through this
* class: a left widget, center widget, and action buttons area.
*
- * The action buttons area contain "minimize" and "close" buttons.
+ * The action buttons area contain "minimize", "maximize" and "close" buttons.
*/
#define _EOS_STYLE_CLASS_TOP_BAR "top-bar"
#define _EOS_TOP_BAR_HEIGHT_PX 36
@@ -25,6 +25,7 @@
#define _EOS_TOP_BAR_BUTTON_SEPARATION_PX 8
#define _EOS_TOP_BAR_VERTICAL_BUTTON_MARGIN_PX 6
#define _EOS_TOP_BAR_MINIMIZE_ICON_NAME "window-minimize-symbolic"
+#define _EOS_TOP_BAR_MAXIMIZE_ICON_NAME "face-monkey"
#define _EOS_TOP_BAR_CLOSE_ICON_NAME "window-close-symbolic"
typedef struct {
@@ -37,6 +38,8 @@ typedef struct {
GtkWidget *minimize_button;
GtkWidget *minimize_icon;
+ GtkWidget *maximize_button;
+ GtkWidget *maximize_icon;
GtkWidget *close_button;
GtkWidget *close_icon;
} EosTopBarPrivate;
@@ -46,6 +49,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (EosTopBar, eos_top_bar, GTK_TYPE_EVENT_BOX)
enum {
CLOSE_CLICKED,
MINIMIZE_CLICKED,
+ MAXIMIZE_CLICKED,
LAST_SIGNAL
};
@@ -107,6 +111,17 @@ eos_top_bar_class_init (EosTopBarClass *klass)
G_TYPE_NONE, 0);
/*
+ * Emitted when the maximize button has been activated.
+ */
+ top_bar_signals[MAXIMIZE_CLICKED] =
+ g_signal_new ("maximize-clicked",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+
+ /*
* Emitted when the close button has been activated.
*/
top_bar_signals[CLOSE_CLICKED] =
@@ -127,6 +142,14 @@ on_minimize_clicked_cb (GtkButton *button,
}
static void
+on_maximize_clicked_cb (GtkButton *button,
+ gpointer user_data)
+{
+ EosTopBar *self = EOS_TOP_BAR (user_data);
+ g_signal_emit (self, top_bar_signals[MAXIMIZE_CLICKED], 0);
+}
+
+static void
on_close_clicked_cb (GtkButton *button,
gpointer user_data)
{
@@ -179,6 +202,21 @@ eos_top_bar_init (EosTopBar *self)
gtk_container_add (GTK_CONTAINER (priv->minimize_button),
priv->minimize_icon);
+ priv->maximize_button =
+ g_object_new (GTK_TYPE_BUTTON,
+ "halign", GTK_ALIGN_END,
+ "valign", GTK_ALIGN_CENTER,
+ NULL);
+ priv->maximize_icon =
+ gtk_image_new_from_icon_name (_EOS_TOP_BAR_MAXIMIZE_ICON_NAME,
+ GTK_ICON_SIZE_SMALL_TOOLBAR);
+ g_object_set(priv->maximize_icon,
+ "pixel-size", _EOS_TOP_BAR_ICON_SIZE_PX,
+ "margin", _EOS_TOP_BAR_BUTTON_PADDING_PX,
+ NULL);
+ gtk_container_add (GTK_CONTAINER (priv->maximize_button),
+ priv->maximize_icon);
+
priv->close_button =
g_object_new (GTK_TYPE_BUTTON,
"halign", GTK_ALIGN_END,
@@ -201,6 +239,8 @@ eos_top_bar_init (EosTopBar *self)
gtk_container_add (GTK_CONTAINER (priv->actions_grid),
priv->minimize_button);
gtk_container_add (GTK_CONTAINER (priv->actions_grid),
+ priv->maximize_button);
+ gtk_container_add (GTK_CONTAINER (priv->actions_grid),
priv->close_button);
gtk_container_add (GTK_CONTAINER (self), priv->actions_grid);
@@ -210,6 +250,8 @@ eos_top_bar_init (EosTopBar *self)
g_signal_connect (priv->minimize_button, "clicked",
G_CALLBACK (on_minimize_clicked_cb), self);
+ g_signal_connect (priv->maximize_button, "clicked",
+ G_CALLBACK (on_maximize_clicked_cb), self);
g_signal_connect (priv->close_button, "clicked",
G_CALLBACK (on_close_clicked_cb), self);
}
diff --git a/endless/eoswindow.c b/endless/eoswindow.c
index 42b3cae..361c6b9 100644
--- a/endless/eoswindow.c
+++ b/endless/eoswindow.c
@@ -95,6 +95,8 @@ typedef struct {
EosPageManager *page_manager;
+ gboolean maximized;
+
/* For scaling base font-size */
GtkCssProvider *font_size_provider;
gboolean font_scaling_active;
@@ -701,19 +703,44 @@ eos_window_class_init (EosWindowClass *klass)
}
static void
-on_minimize_clicked_cb (GtkWidget* top_bar)
+on_minimize_clicked_cb (GtkWidget* top_bar,
+ gpointer data)
+{
+ EosWindow *self = (EosWindow *)data;
+
+ gtk_window_iconify (GTK_WINDOW (self));
+}
+
+static void
+on_maximize_clicked_cb (GtkWidget* top_bar,
+ gpointer data)
{
- GtkWidget *window = gtk_widget_get_toplevel (top_bar);
+ EosWindow *self = (EosWindow *)data;
+ EosWindowPrivate *priv = eos_window_get_instance_private (self);
- gtk_window_iconify (GTK_WINDOW (window));
+ if (priv->maximized)
+ gtk_window_unmaximize (GTK_WINDOW (self));
+ else
+ gtk_window_maximize (GTK_WINDOW (self));
}
static void
-on_close_clicked_cb (GtkWidget* top_bar)
+on_close_clicked_cb (GtkWidget* top_bar,
+ gpointer data)
{
- GtkWidget *window = gtk_widget_get_toplevel (top_bar);
+ EosWindow *self = (EosWindow *)data;
+
+ gtk_window_close (GTK_WINDOW (self));
+}
- gtk_window_close (GTK_WINDOW (window));
+static void
+on_window_state_event_cb (GtkWidget* widget,
+ GdkEvent* event)
+{
+ EosWindow *self = EOS_WINDOW (widget);
+ EosWindowPrivate *priv = eos_window_get_instance_private (self);
+ GdkWindowState window_state = ((GdkEventWindowState *)event)->new_window_state;
+ priv->maximized = window_state & GDK_WINDOW_STATE_MAXIMIZED;
}
/* Make sure that the edge finishing does not catch input events */
@@ -818,9 +845,13 @@ eos_window_init (EosWindow *self)
gtk_window_set_default_size (GTK_WINDOW (self), DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT);
g_signal_connect (priv->top_bar, "minimize-clicked",
- G_CALLBACK (on_minimize_clicked_cb), NULL);
+ G_CALLBACK (on_minimize_clicked_cb), self);
+ g_signal_connect (priv->top_bar, "maximize-clicked",
+ G_CALLBACK (on_maximize_clicked_cb), self);
g_signal_connect (priv->top_bar, "close-clicked",
- G_CALLBACK (on_close_clicked_cb), NULL);
+ G_CALLBACK (on_close_clicked_cb), self);
+ g_signal_connect (self, "window-state-event",
+ G_CALLBACK (on_window_state_event_cb), NULL);
eos_window_set_page_manager (self,
EOS_PAGE_MANAGER (eos_page_manager_new ()));