[eog-plugins] Add new plugin: Hide Titlebar



commit 42acca2c8daf8dafb1427ce44ac1d3a9d7101237
Author: Felix Riemann <friemann gnome org>
Date:   Sun Aug 12 15:11:04 2012 +0200

    Add new plugin: Hide Titlebar
    
    This hides eog's titlebar when the window is maximized.
    The function is more or less parked in this plugin for now as it's unclear
    whether this would be a good default for eog.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=668652

 configure.ac                                       |    7 +-
 plugins/hide-titlebar/Makefile.am                  |   34 +++++
 plugins/hide-titlebar/eog-hide-titlebar-plugin.c   |  148 ++++++++++++++++++++
 plugins/hide-titlebar/eog-hide-titlebar-plugin.h   |   81 +++++++++++
 .../hide-titlebar/hide-titlebar.plugin.desktop.in  |    9 ++
 po/POTFILES.in                                     |    1 +
 6 files changed, 277 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d2b1e6c..7d33296 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,9 +61,9 @@ EOG_HAS_PYTHON=1
 
 AC_MSG_CHECKING([which plugins to build])
 
-ALL_PLUGINS="postr map fit-to-width exif-display send-by-mail postasa"
-USEFUL_PLUGINS="postr map fit-to-width exif-display send-by-mail postasa"
-DEFAULT_PLUGINS="postr map fit-to-width exif-display send-by-mail postasa"
+ALL_PLUGINS="postr map fit-to-width exif-display send-by-mail postasa hide-titlebar"
+USEFUL_PLUGINS="postr map fit-to-width exif-display send-by-mail postasa hide-titlebar"
+DEFAULT_PLUGINS="postr map fit-to-width exif-display send-by-mail postasa hide-titlebar"
 
 PYTHON_ALL_PLUGINS="slideshowshuffle pythonconsole fullscreenbg"
 PYTHON_USEFUL_PLUGINS="slideshowshuffle pythonconsole fullscreenbg"
@@ -340,6 +340,7 @@ plugins/exif-display/Makefile
 plugins/exif-display/org.gnome.eog.plugins.exif-display.gschema.xml.in
 plugins/fullscreenbg/Makefile
 plugins/fullscreenbg/org.gnome.eog.plugins.fullscreenbg.gschema.xml.in
+plugins/hide-titlebar/Makefile
 plugins/send-by-mail/Makefile
 plugins/slideshowshuffle/Makefile
 plugins/postr/Makefile
diff --git a/plugins/hide-titlebar/Makefile.am b/plugins/hide-titlebar/Makefile.am
new file mode 100644
index 0000000..8d550b0
--- /dev/null
+++ b/plugins/hide-titlebar/Makefile.am
@@ -0,0 +1,34 @@
+# HideTitlebar plugin
+plugindir = $(libdir)/eog/plugins
+
+INCLUDES = \
+	-I$(top_srcdir)/src 				\
+	$(EOG_CFLAGS) 					\
+	$(WARN_CFLAGS)					\
+	-DEOG_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
+
+plugin_LTLIBRARIES = libhide-titlebar.la
+
+libhide_titlebar_la_SOURCES = \
+	eog-hide-titlebar-plugin.h			\
+	eog-hide-titlebar-plugin.c
+
+libhide_titlebar_la_LDFLAGS = \
+	-avoid-version -module
+
+libhide_titlebar_la_LIBADD = $(EOG_LIBS)
+
+# Plugin Info
+
+plugin_in_files = hide-titlebar.plugin.desktop.in
+
+%.plugin: %.plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(AM_V_GEN)$(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
+
+EXTRA_DIST = $(plugin_in_files)
+
+CLEANFILES = $(plugin_DATA)
+DISTCLEANFILES = $(plugin_DATA)
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/hide-titlebar/eog-hide-titlebar-plugin.c b/plugins/hide-titlebar/eog-hide-titlebar-plugin.c
new file mode 100644
index 0000000..d7cf7c8
--- /dev/null
+++ b/plugins/hide-titlebar/eog-hide-titlebar-plugin.c
@@ -0,0 +1,148 @@
+/* HideTitlebar  -- Hide EogWindow's titlebar when maximized
+ *
+ * Copyright (C) 2012 The Free Software Foundation
+ *
+ * Author: Felix Riemann    <friemann gnome org>
+ *         Claudio Saavedra <csaavedra igalia com>
+ *
+ * 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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+#include <eog/eog-window.h>
+#include <eog/eog-window-activatable.h>
+
+#include "eog-hide-titlebar-plugin.h"
+
+
+static void
+eog_window_activatable_iface_init (EogWindowActivatableInterface *iface);
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (EogHideTitlebarPlugin, eog_hide_titlebar_plugin,
+                                PEAS_TYPE_EXTENSION_BASE, 0,
+                     G_IMPLEMENT_INTERFACE_DYNAMIC (EOG_TYPE_WINDOW_ACTIVATABLE,
+                                             eog_window_activatable_iface_init))
+
+enum {
+	PROP_0,
+	PROP_WINDOW
+};
+
+
+static void
+eog_hide_titlebar_plugin_init (EogHideTitlebarPlugin *plugin)
+{
+}
+
+static void
+impl_activate (EogWindowActivatable *activatable)
+{
+	EogHideTitlebarPlugin *plugin = EOG_HIDE_TITLEBAR_PLUGIN (activatable);
+	GtkWindow *window = GTK_WINDOW (plugin->window);
+
+	plugin->previous_state = 
+		gtk_window_get_hide_titlebar_when_maximized (window);
+
+	if (!plugin->previous_state)
+		gtk_window_set_hide_titlebar_when_maximized (window, TRUE);
+}
+
+static void
+impl_deactivate	(EogWindowActivatable *activatable)
+{
+	EogHideTitlebarPlugin *plugin = EOG_HIDE_TITLEBAR_PLUGIN (activatable);
+	GtkWindow *window = GTK_WINDOW (plugin->window);
+
+	gtk_window_set_hide_titlebar_when_maximized (window,
+	                                             plugin->previous_state);
+}
+
+static void
+eog_hide_titlebar_plugin_get_property (GObject    *object,
+                                       guint       prop_id,
+                                       GValue     *value,
+                                       GParamSpec *pspec)
+{
+	EogHideTitlebarPlugin *plugin = EOG_HIDE_TITLEBAR_PLUGIN (object);
+
+	switch (prop_id)
+	{
+	case PROP_WINDOW:
+		g_value_set_object (value, plugin->window);
+		break;
+
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+		break;
+	}
+}
+
+static void
+eog_hide_titlebar_plugin_set_property (GObject      *object,
+                                       guint         prop_id,
+                                       const GValue *value,
+                                       GParamSpec   *pspec)
+{
+	EogHideTitlebarPlugin *plugin = EOG_HIDE_TITLEBAR_PLUGIN (object);
+
+	switch (prop_id)
+	{
+	case PROP_WINDOW:
+		plugin->window = EOG_WINDOW (g_value_dup_object (value));
+		break;
+
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+		break;
+	}
+}
+
+static void
+eog_hide_titlebar_plugin_class_init (EogHideTitlebarPluginClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+	object_class->set_property = eog_hide_titlebar_plugin_set_property;
+	object_class->get_property = eog_hide_titlebar_plugin_get_property;
+
+	g_object_class_override_property (object_class, PROP_WINDOW, "window");
+}
+
+static void
+eog_hide_titlebar_plugin_class_finalize (EogHideTitlebarPluginClass *klass)
+{
+	/* Dummy needed for G_DEFINE_DYNAMIC_TYPE_EXTENDED */
+}
+
+static void
+eog_window_activatable_iface_init (EogWindowActivatableInterface *iface)
+{
+	iface->activate = impl_activate;
+	iface->deactivate = impl_deactivate;
+}
+
+G_MODULE_EXPORT void
+peas_register_types (PeasObjectModule *module)
+{
+	eog_hide_titlebar_plugin_register_type (G_TYPE_MODULE (module));
+	peas_object_module_register_extension_type (module,
+	                                       EOG_TYPE_WINDOW_ACTIVATABLE,
+	                                       EOG_TYPE_HIDE_TITLEBAR_PLUGIN);
+}
diff --git a/plugins/hide-titlebar/eog-hide-titlebar-plugin.h b/plugins/hide-titlebar/eog-hide-titlebar-plugin.h
new file mode 100644
index 0000000..664bd6d
--- /dev/null
+++ b/plugins/hide-titlebar/eog-hide-titlebar-plugin.h
@@ -0,0 +1,81 @@
+/* HideTitlebar  -- Hide EogWindow's titlebar when maximized
+ *
+ * Copyright (C) 2012 The Free Software Foundation
+ *
+ * Author: Felix Riemann    <friemann gnome org>
+ *         Claudio Saavedra <csaavedra igalia com>
+ *
+ * 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 __EOG_HIDE_TITLEBAR_PLUGIN_H__
+#define __EOG_HIDE_TITLEBAR_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include <eog/eog-window.h>
+#include <libpeas/peas-extension-base.h>
+#include <libpeas/peas-object-module.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define EOG_TYPE_HIDE_TITLEBAR_PLUGIN		(eog_hide_titlebar_plugin_get_type ())
+#define EOG_HIDE_TITLEBAR_PLUGIN(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), EOG_TYPE_HIDE_TITLEBAR_PLUGIN, EogHideTitlebarPlugin))
+#define EOG_HIDE_TITLEBAR_PLUGIN_CLASS(k)	G_TYPE_CHECK_CLASS_CAST((k),      EOG_TYPE_HIDE_TITLEBAR_PLUGIN, EogHideTitlebarPluginClass))
+#define EOG_IS_HIDE_TITLEBAR_PLUGIN(o)	        (G_TYPE_CHECK_INSTANCE_TYPE ((o), EOG_TYPE_HIDE_TITLEBAR_PLUGIN))
+#define EOG_IS_HIDE_TITLEBAR_PLUGIN_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k),    EOG_TYPE_HIDE_TITLEBAR_PLUGIN))
+#define EOG_HIDE_TITLEBAR_PLUGIN_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o),  EOG_TYPE_HIDE_TITLEBAR_PLUGIN, EogHideTitlebarPluginClass))
+
+/* Private structure type */
+typedef struct _EogHideTitlebarPluginPrivate	EogHideTitlebarPluginPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _EogHideTitlebarPlugin		EogHideTitlebarPlugin;
+
+struct _EogHideTitlebarPlugin
+{
+	PeasExtensionBase parent_instance;
+
+	EogWindow *window;
+	gboolean   previous_state;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _EogHideTitlebarPluginClass	EogHideTitlebarPluginClass;
+
+struct _EogHideTitlebarPluginClass
+{
+	PeasExtensionBaseClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType	eog_hide_titlebar_plugin_get_type		(void) G_GNUC_CONST;
+
+/* All the plugins must implement this function */
+G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
+
+G_END_DECLS
+
+#endif /* __EOG_HIDE_TITLEBAR_PLUGIN_H__ */
diff --git a/plugins/hide-titlebar/hide-titlebar.plugin.desktop.in b/plugins/hide-titlebar/hide-titlebar.plugin.desktop.in
new file mode 100644
index 0000000..2c8c4e4
--- /dev/null
+++ b/plugins/hide-titlebar/hide-titlebar.plugin.desktop.in
@@ -0,0 +1,9 @@
+[Plugin]
+Module=hide-titlebar
+IAge=2
+_Name=Hide Titlebar
+Icon=eog-plugin
+_Description=Hides the titlebar of maximized Eye of GNOME windows
+Authors=Claudio Saavedra <csaavedra igalia com>, Felix Riemann <friemann gnome org>
+Copyright=Copyright  2012 The Free Software Foundation
+Website=http://www.gnome.org/projects/eog
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c3ab65e..a2f83ef 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -7,6 +7,7 @@ plugins/fit-to-width/fit-to-width.plugin.desktop.in
 plugins/fullscreenbg/fullscreenbg.plugin.desktop.in
 plugins/fullscreenbg/org.gnome.eog.plugins.fullscreenbg.gschema.xml.in.in
 [type: gettext/glade]plugins/fullscreenbg/preferences_dialog.ui
+plugins/hide-titlebar/hide-titlebar.plugin.desktop.in
 plugins/map/eog-map-plugin.c
 plugins/map/map.plugin.desktop.in
 plugins/postasa/eog-postasa-plugin.c



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