[gnome-photos/wip/rishi/collection: 16/25] Add PhotosModelButton
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/collection: 16/25] Add PhotosModelButton
- Date: Thu, 18 Jan 2018 08:59:31 +0000 (UTC)
commit 745b025366e30a7f1958cc0554c4df3f7674beca
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Jan 16 12:05:17 2018 +0100
Add PhotosModelButton
This like a GtkModelButton, but with a custom child inside, which isn't
currently possible with GtkModelButton.
https://bugzilla.gnome.org/show_bug.cgi?id=751212
src/Makefile.am | 2 ++
src/photos-model-button.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++
src/photos-model-button.h | 35 +++++++++++++++++++++++
3 files changed, 110 insertions(+)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index a65c2725..b0a902a4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -137,6 +137,8 @@ gnome_photos_SOURCES = \
photos-main-window.h \
photos-media-server-item.c \
photos-media-server-item.h \
+ photos-model-button.c \
+ photos-model-button.h \
photos-notification-manager.c \
photos-notification-manager.h \
photos-offset-collection-view-controller.c \
diff --git a/src/photos-model-button.c b/src/photos-model-button.c
new file mode 100644
index 00000000..b8adb843
--- /dev/null
+++ b/src/photos-model-button.c
@@ -0,0 +1,73 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2018 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+
+#include "config.h"
+
+#include "photos-model-button.h"
+
+
+struct _PhotosModelButton
+{
+ GtkButton parent_instance;
+};
+
+
+G_DEFINE_TYPE (PhotosModelButton, photos_model_button, GTK_TYPE_BUTTON);
+
+
+static void
+photos_model_button_clicked (GtkButton *button)
+{
+ GtkWidget *popover;
+
+ popover = gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_POPOVER);
+ if (popover != NULL)
+ gtk_popover_popdown (GTK_POPOVER (popover));
+
+ if (GTK_BUTTON_CLASS (photos_model_button_parent_class)->clicked != NULL)
+ GTK_BUTTON_CLASS (photos_model_button_parent_class)->clicked (button);
+}
+
+
+static void
+photos_model_button_init (PhotosModelButton *self)
+{
+ gtk_button_set_relief (GTK_BUTTON (self), GTK_RELIEF_NONE);
+}
+
+
+static void
+photos_model_button_class_init (PhotosModelButtonClass *class)
+{
+ GtkButtonClass *button_class = GTK_BUTTON_CLASS (class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+
+ button_class->clicked = photos_model_button_clicked;
+
+ gtk_widget_class_set_css_name (widget_class, "modelbutton");
+}
+
+
+GtkWidget *
+photos_model_button_new (void)
+{
+ return g_object_new (PHOTOS_TYPE_MODEL_BUTTON, NULL);
+}
diff --git a/src/photos-model-button.h b/src/photos-model-button.h
new file mode 100644
index 00000000..a365b8c4
--- /dev/null
+++ b/src/photos-model-button.h
@@ -0,0 +1,35 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2018 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef PHOTOS_MODEL_BUTTON_H
+#define PHOTOS_MODEL_BUTTON_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_MODEL_BUTTON (photos_model_button_get_type ())
+G_DECLARE_FINAL_TYPE (PhotosModelButton, photos_model_button, PHOTOS, MODEL_BUTTON, GtkButton);
+
+GtkWidget *photos_model_button_new (void);
+
+G_END_DECLS
+
+#endif /* PHOTOS_MODEL_BUTTON_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]