summaryrefslogtreecommitdiff
path: root/endless
diff options
context:
space:
mode:
authorWill Greenberg <ifnspifn@gmail.com>2014-01-17 17:32:02 -0800
committerWill Greenberg <ifnspifn@gmail.com>2014-01-17 17:32:02 -0800
commit565f5bba52d63b970518f538838ee6c4e6e45ac4 (patch)
treebc627579facc128dcb7c145871b90da689a2a3fe /endless
parent724cd57ef275d33339486b91d51bb565ac9b3fff (diff)
parentc317a0c874c33872ca3c8d916393658ebefc390a (diff)
Merge pull request #486 from endlessm/issues/477
Added a maximize button to eos-topbar
Diffstat (limited to 'endless')
-rw-r--r--endless/eostopbar.c44
-rw-r--r--endless/eoswindow.c42
2 files changed, 77 insertions, 9 deletions
diff --git a/endless/eostopbar.c b/endless/eostopbar.c
index 6975e39..6d98090 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 f141c68..8b91919 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;
@@ -702,19 +704,39 @@ eos_window_class_init (EosWindowClass *klass)
}
static void
-on_minimize_clicked_cb (GtkWidget* top_bar)
+on_minimize_clicked_cb (GtkWidget *top_bar,
+ EosWindow *self)
+{
+ gtk_window_iconify (GTK_WINDOW (self));
+}
+
+static void
+on_maximize_clicked_cb (GtkWidget *top_bar,
+ EosWindow *self)
{
- GtkWidget *window = gtk_widget_get_toplevel (top_bar);
+ 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,
+ EosWindow *self)
{
- GtkWidget *window = gtk_widget_get_toplevel (top_bar);
+ gtk_window_close (GTK_WINDOW (self));
+}
- gtk_window_close (GTK_WINDOW (window));
+static void
+on_window_state_event_cb (GtkWidget *widget,
+ GdkEventWindowState *event)
+{
+ EosWindow *self = EOS_WINDOW (widget);
+ EosWindowPrivate *priv = eos_window_get_instance_private (self);
+ GdkWindowState window_state = event->new_window_state;
+ priv->maximized = window_state & GDK_WINDOW_STATE_MAXIMIZED;
}
/* Make sure that the edge finishing does not catch input events */
@@ -819,9 +841,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 ()));