Commit 9caf0ca9 authored by Paolo Borelli's avatar Paolo Borelli

tab: use G_DECLARE macros

parent 075b0642
......@@ -129,6 +129,7 @@ gedit_NOINST_H_FILES = \
gedit/gedit-settings.h \
gedit/gedit-small-button.h \
gedit/gedit-status-menu-button.h \
gedit/gedit-tab-private.h \
gedit/gedit-tab-label.h \
gedit/gedit-view-frame.h \
gedit/gedit-view-holder.h \
......
......@@ -49,6 +49,7 @@
#include "gedit-commands.h"
#include "gedit-preferences-dialog.h"
#include "gedit-tab.h"
#include "gedit-tab-private.h"
#ifndef ENABLE_GVFS_METADATA
#include "gedit-metadata-manager.h"
......
......@@ -25,6 +25,7 @@
#include "gedit-window.h"
#include "gedit-tab.h"
#include "gedit-tab-private.h"
#include "gedit-debug.h"
void
......
......@@ -35,6 +35,8 @@
#include "gedit-debug.h"
#include "gedit-document.h"
#include "gedit-document-private.h"
#include "gedit-tab.h"
#include "gedit-tab-private.h"
#include "gedit-window.h"
#include "gedit-window-private.h"
#include "gedit-notebook.h"
......
......@@ -34,6 +34,8 @@
#include "gedit-debug.h"
#include "gedit-statusbar.h"
#include "gedit-tab.h"
#include "gedit-tab-private.h"
#include "gedit-view-frame.h"
#include "gedit-window.h"
#include "gedit-window-private.h"
......
......@@ -32,6 +32,8 @@
#include "gedit-notebook.h"
#include "gedit-notebook-popup-menu.h"
#include "gedit-small-button.h"
#include "gedit-tab.h"
#include "gedit-tab-private.h"
#include "gedit-utils.h"
#include "gedit-commands-private.h"
......
......@@ -25,6 +25,8 @@
#include "gedit-enum-types.h"
#include "gedit-marshal.h"
#include "gedit-settings.h"
#include "gedit-tab-private.h"
#include "gedit-tab.h"
struct _GeditMultiNotebookPrivate
{
......
......@@ -28,6 +28,8 @@
#include <gtk/gtk.h>
#include "gedit-small-button.h"
#include "gedit-tab.h"
#include "gedit-tab-private.h"
/* Signals */
enum
......@@ -42,8 +44,10 @@ enum
PROP_TAB
};
struct _GeditTabLabelPrivate
struct _GeditTabLabel
{
GtkBox parent_instance;
GeditTab *tab;
GtkWidget *close_button;
......@@ -56,7 +60,7 @@ struct _GeditTabLabelPrivate
static guint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE_WITH_PRIVATE (GeditTabLabel, gedit_tab_label, GTK_TYPE_BOX)
G_DEFINE_TYPE (GeditTabLabel, gedit_tab_label, GTK_TYPE_BOX)
static void
gedit_tab_label_finalize (GObject *object)
......@@ -75,7 +79,7 @@ gedit_tab_label_set_property (GObject *object,
switch (prop_id)
{
case PROP_TAB:
tab_label->priv->tab = GEDIT_TAB (g_value_get_object (value));
tab_label->tab = GEDIT_TAB (g_value_get_object (value));
break;
default:
......@@ -95,7 +99,7 @@ gedit_tab_label_get_property (GObject *object,
switch (prop_id)
{
case PROP_TAB:
g_value_set_object (value, tab_label->priv->tab);
g_value_set_object (value, tab_label->tab);
break;
default:
......@@ -131,12 +135,12 @@ sync_name (GeditTab *tab,
{
gchar *str;
g_return_if_fail (tab == tab_label->priv->tab);
g_return_if_fail (tab == tab_label->tab);
str = _gedit_tab_get_name (tab);
g_return_if_fail (str != NULL);
gtk_label_set_text (GTK_LABEL (tab_label->priv->label), str);
gtk_label_set_text (GTK_LABEL (tab_label->label), str);
g_free (str);
sync_tip (tab, tab_label);
......@@ -145,10 +149,10 @@ sync_name (GeditTab *tab,
static void
update_close_button_sensitivity (GeditTabLabel *tab_label)
{
GeditTabState state = gedit_tab_get_state (tab_label->priv->tab);
GeditTabState state = gedit_tab_get_state (tab_label->tab);
gtk_widget_set_sensitive (tab_label->priv->close_button,
tab_label->priv->close_button_sensitive &&
gtk_widget_set_sensitive (tab_label->close_button,
tab_label->close_button_sensitive &&
(state != GEDIT_TAB_STATE_CLOSING) &&
(state != GEDIT_TAB_STATE_SAVING) &&
(state != GEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW) &&
......@@ -164,7 +168,7 @@ sync_state (GeditTab *tab,
{
GeditTabState state;
g_return_if_fail (tab == tab_label->priv->tab);
g_return_if_fail (tab == tab_label->tab);
update_close_button_sensitivity (tab_label);
......@@ -174,10 +178,10 @@ sync_state (GeditTab *tab,
(state == GEDIT_TAB_STATE_SAVING) ||
(state == GEDIT_TAB_STATE_REVERTING))
{
gtk_widget_hide (tab_label->priv->icon);
gtk_widget_hide (tab_label->icon);
gtk_widget_show (tab_label->priv->spinner);
gtk_spinner_start (GTK_SPINNER (tab_label->priv->spinner));
gtk_widget_show (tab_label->spinner);
gtk_spinner_start (GTK_SPINNER (tab_label->spinner));
}
else
{
......@@ -187,20 +191,20 @@ sync_state (GeditTab *tab,
if (pixbuf != NULL)
{
gtk_image_set_from_pixbuf (GTK_IMAGE (tab_label->priv->icon),
gtk_image_set_from_pixbuf (GTK_IMAGE (tab_label->icon),
pixbuf);
g_clear_object (&pixbuf);
gtk_widget_show (tab_label->priv->icon);
gtk_widget_show (tab_label->icon);
}
else
{
gtk_widget_hide (tab_label->priv->icon);
gtk_widget_hide (tab_label->icon);
}
gtk_spinner_stop (GTK_SPINNER (tab_label->priv->spinner));
gtk_widget_hide (tab_label->priv->spinner);
gtk_spinner_stop (GTK_SPINNER (tab_label->spinner));
gtk_widget_hide (tab_label->spinner);
}
/* sync tip since encoding is known only after load/save end */
......@@ -212,22 +216,22 @@ gedit_tab_label_constructed (GObject *object)
{
GeditTabLabel *tab_label = GEDIT_TAB_LABEL (object);
if (!tab_label->priv->tab)
if (!tab_label->tab)
{
g_critical ("The tab label was not properly constructed");
return;
}
sync_name (tab_label->priv->tab, NULL, tab_label);
sync_state (tab_label->priv->tab, NULL, tab_label);
sync_name (tab_label->tab, NULL, tab_label);
sync_state (tab_label->tab, NULL, tab_label);
g_signal_connect_object (tab_label->priv->tab,
g_signal_connect_object (tab_label->tab,
"notify::name",
G_CALLBACK (sync_name),
tab_label,
0);
g_signal_connect_object (tab_label->priv->tab,
g_signal_connect_object (tab_label->tab,
"notify::state",
G_CALLBACK (sync_state),
tab_label,
......@@ -236,6 +240,11 @@ gedit_tab_label_constructed (GObject *object)
G_OBJECT_CLASS (gedit_tab_label_parent_class)->constructed (object);
}
static void
gedit_tab_label_close_clicked (GeditTabLabel *tab_label)
{
}
static void
gedit_tab_label_class_init (GeditTabLabelClass *klass)
{
......@@ -248,14 +257,13 @@ gedit_tab_label_class_init (GeditTabLabelClass *klass)
object_class->constructed = gedit_tab_label_constructed;
signals[CLOSE_CLICKED] =
g_signal_new ("close-clicked",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GeditTabLabelClass, close_clicked),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
g_signal_new_class_handler ("close-clicked",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_CALLBACK (gedit_tab_label_close_clicked),
NULL, NULL, NULL,
G_TYPE_NONE,
0);
g_object_class_install_property (object_class,
PROP_TAB,
......@@ -269,22 +277,20 @@ gedit_tab_label_class_init (GeditTabLabelClass *klass)
/* Bind class to template */
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/gedit/ui/gedit-tab-label.ui");
gtk_widget_class_bind_template_child_private (widget_class, GeditTabLabel, spinner);
gtk_widget_class_bind_template_child_private (widget_class, GeditTabLabel, close_button);
gtk_widget_class_bind_template_child_private (widget_class, GeditTabLabel, icon);
gtk_widget_class_bind_template_child_private (widget_class, GeditTabLabel, label);
gtk_widget_class_bind_template_child (widget_class, GeditTabLabel, spinner);
gtk_widget_class_bind_template_child (widget_class, GeditTabLabel, close_button);
gtk_widget_class_bind_template_child (widget_class, GeditTabLabel, icon);
gtk_widget_class_bind_template_child (widget_class, GeditTabLabel, label);
}
static void
gedit_tab_label_init (GeditTabLabel *tab_label)
{
tab_label->priv = gedit_tab_label_get_instance_private (tab_label);
tab_label->priv->close_button_sensitive = TRUE;
tab_label->close_button_sensitive = TRUE;
gtk_widget_init_template (GTK_WIDGET (tab_label));
g_signal_connect (tab_label->priv->close_button,
g_signal_connect (tab_label->close_button,
"clicked",
G_CALLBACK (close_button_clicked_cb),
tab_label);
......@@ -298,9 +304,9 @@ gedit_tab_label_set_close_button_sensitive (GeditTabLabel *tab_label,
sensitive = (sensitive != FALSE);
if (tab_label->priv->close_button_sensitive != sensitive)
if (tab_label->close_button_sensitive != sensitive)
{
tab_label->priv->close_button_sensitive = sensitive;
tab_label->close_button_sensitive = sensitive;
update_close_button_sensitivity (tab_label);
}
}
......@@ -310,7 +316,7 @@ gedit_tab_label_get_tab (GeditTabLabel *tab_label)
{
g_return_val_if_fail (GEDIT_IS_TAB_LABEL (tab_label), NULL);
return tab_label->priv->tab;
return tab_label->tab;
}
GtkWidget *
......
......@@ -26,33 +26,9 @@
G_BEGIN_DECLS
#define GEDIT_TYPE_TAB_LABEL (gedit_tab_label_get_type ())
#define GEDIT_TAB_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_TAB_LABEL, GeditTabLabel))
#define GEDIT_TAB_LABEL_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_TAB_LABEL, GeditTabLabel const))
#define GEDIT_TAB_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_TAB_LABEL, GeditTabLabelClass))
#define GEDIT_IS_TAB_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_TAB_LABEL))
#define GEDIT_IS_TAB_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_TAB_LABEL))
#define GEDIT_TAB_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_TAB_LABEL, GeditTabLabelClass))
#define GEDIT_TYPE_TAB_LABEL (gedit_tab_label_get_type ())
typedef struct _GeditTabLabel GeditTabLabel;
typedef struct _GeditTabLabelClass GeditTabLabelClass;
typedef struct _GeditTabLabelPrivate GeditTabLabelPrivate;
struct _GeditTabLabel
{
GtkBox parent;
GeditTabLabelPrivate *priv;
};
struct _GeditTabLabelClass
{
GtkBoxClass parent_class;
void (* close_clicked) (GeditTabLabel *tab_label);
};
GType gedit_tab_label_get_type (void) G_GNUC_CONST;
G_DECLARE_FINAL_TYPE (GeditTabLabel, gedit_tab_label, GEDIT, TAB_LABEL, GtkBox)
GtkWidget *gedit_tab_label_new (GeditTab *tab);
......
/*
* gedit-tab.h
* This file is part of gedit
*
* Copyright (C) 2005 - Paolo Maggi
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GEDIT_TAB_PRIVATE_H__
#define __GEDIT_TAB_PRIVATE_H__
#include <gedit/gedit-tab.h>
G_BEGIN_DECLS
GtkWidget *_gedit_tab_new (void);
/* Whether create is TRUE, creates a new empty document if location does
* not refer to an existing location
*/
GtkWidget *_gedit_tab_new_from_location (GFile *location,
const GtkSourceEncoding *encoding,
gint line_pos,
gint column_pos,
gboolean create);
GtkWidget *_gedit_tab_new_from_stream (GInputStream *stream,
const GtkSourceEncoding *encoding,
gint line_pos,
gint column_pos);
gchar *_gedit_tab_get_name (GeditTab *tab);
gchar *_gedit_tab_get_tooltip (GeditTab *tab);
GdkPixbuf *_gedit_tab_get_icon (GeditTab *tab);
void _gedit_tab_load (GeditTab *tab,
GFile *location,
const GtkSourceEncoding *encoding,
gint line_pos,
gint column_pos,
gboolean create);
void _gedit_tab_load_stream (GeditTab *tab,
GInputStream *location,
const GtkSourceEncoding *encoding,
gint line_pos,
gint column_pos);
void _gedit_tab_revert (GeditTab *tab);
void _gedit_tab_save_async (GeditTab *tab,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean _gedit_tab_save_finish (GeditTab *tab,
GAsyncResult *result);
void _gedit_tab_save_as_async (GeditTab *tab,
GFile *location,
const GtkSourceEncoding *encoding,
GtkSourceNewlineType newline_type,
GtkSourceCompressionType compression_type,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
void _gedit_tab_print (GeditTab *tab);
void _gedit_tab_mark_for_closing (GeditTab *tab);
gboolean _gedit_tab_get_can_close (GeditTab *tab);
GtkWidget *_gedit_tab_get_view_frame (GeditTab *tab);
void _gedit_tab_set_network_available (GeditTab *tab,
gboolean enable);
G_END_DECLS
#endif /* __GEDIT_TAB_PRIVATE_H__ */
/* ex:set ts=8 noet: */
This diff is collapsed.
......@@ -46,124 +46,31 @@ typedef enum
GEDIT_TAB_NUM_OF_STATES /* This is not a valid state */
} GeditTabState;
#define GEDIT_TYPE_TAB (gedit_tab_get_type())
#define GEDIT_TAB(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GEDIT_TYPE_TAB, GeditTab))
#define GEDIT_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GEDIT_TYPE_TAB, GeditTabClass))
#define GEDIT_IS_TAB(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GEDIT_TYPE_TAB))
#define GEDIT_IS_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_TAB))
#define GEDIT_TAB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GEDIT_TYPE_TAB, GeditTabClass))
typedef struct _GeditTab GeditTab;
typedef struct _GeditTabClass GeditTabClass;
typedef struct _GeditTabPrivate GeditTabPrivate;
struct _GeditTab
{
GtkBox vbox;
/*< private >*/
GeditTabPrivate *priv;
};
struct _GeditTabClass
{
GtkBoxClass parent_class;
#define GEDIT_TYPE_TAB (gedit_tab_get_type())
void (* drop_uris) (GeditView *view,
gchar **uri_list);
};
G_DECLARE_FINAL_TYPE (GeditTab, gedit_tab, GEDIT, TAB, GtkBox)
GType gedit_tab_get_type (void) G_GNUC_CONST;
GeditView *gedit_tab_get_view (GeditTab *tab);
GeditView *gedit_tab_get_view (GeditTab *tab);
/* This is only an helper function */
GeditDocument *gedit_tab_get_document (GeditTab *tab);
GeditDocument *gedit_tab_get_document (GeditTab *tab);
GeditTab *gedit_tab_get_from_document (GeditDocument *doc);
GeditTab *gedit_tab_get_from_document (GeditDocument *doc);
GeditTabState gedit_tab_get_state (GeditTab *tab);
GeditTabState gedit_tab_get_state (GeditTab *tab);
gboolean gedit_tab_get_auto_save_enabled
(GeditTab *tab);
gboolean gedit_tab_get_auto_save_enabled (GeditTab *tab);
void gedit_tab_set_auto_save_enabled
(GeditTab *tab,
gboolean enable);
void gedit_tab_set_auto_save_enabled (GeditTab *tab,
gboolean enable);
gint gedit_tab_get_auto_save_interval
(GeditTab *tab);
gint gedit_tab_get_auto_save_interval (GeditTab *tab);
void gedit_tab_set_auto_save_interval
(GeditTab *tab,
gint interval);
void gedit_tab_set_auto_save_interval (GeditTab *tab,
gint interval);
void gedit_tab_set_info_bar (GeditTab *tab,
GtkWidget *info_bar);
/*
* Non exported methods
*/
GtkWidget *_gedit_tab_new (void);
/* Whether create is TRUE, creates a new empty document if location does
not refer to an existing location */
GtkWidget *_gedit_tab_new_from_location (GFile *location,
const GtkSourceEncoding *encoding,
gint line_pos,
gint column_pos,
gboolean create);
GtkWidget *_gedit_tab_new_from_stream (GInputStream *stream,
const GtkSourceEncoding *encoding,
gint line_pos,
gint column_pos);
gchar *_gedit_tab_get_name (GeditTab *tab);
gchar *_gedit_tab_get_tooltip (GeditTab *tab);
GdkPixbuf *_gedit_tab_get_icon (GeditTab *tab);
void _gedit_tab_load (GeditTab *tab,
GFile *location,
const GtkSourceEncoding *encoding,
gint line_pos,
gint column_pos,
gboolean create);
void _gedit_tab_load_stream (GeditTab *tab,
GInputStream *location,
const GtkSourceEncoding *encoding,
gint line_pos,
gint column_pos);
void _gedit_tab_revert (GeditTab *tab);
void _gedit_tab_save_async (GeditTab *tab,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean _gedit_tab_save_finish (GeditTab *tab,
GAsyncResult *result);
void _gedit_tab_save_as_async (GeditTab *tab,
GFile *location,
const GtkSourceEncoding *encoding,
GtkSourceNewlineType newline_type,
GtkSourceCompressionType compression_type,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
void _gedit_tab_print (GeditTab *tab);
void _gedit_tab_mark_for_closing (GeditTab *tab);
gboolean _gedit_tab_get_can_close (GeditTab *tab);
GtkWidget *_gedit_tab_get_view_frame (GeditTab *tab);
void _gedit_tab_set_network_available
(GeditTab *tab,
gboolean enable);
void gedit_tab_set_info_bar (GeditTab *tab,
GtkWidget *info_bar);
G_END_DECLS
......
......@@ -38,6 +38,8 @@
#include "gedit-notebook-popup-menu.h"
#include "gedit-multi-notebook.h"
#include "gedit-statusbar.h"
#include "gedit-tab.h"
#include "gedit-tab-private.h"
#include "gedit-utils.h"
#include "gedit-commands.h"
#include "gedit-commands-private.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment