Blame plugins/gtk+/glade-gtk-text-view.c

Packit 1e8aac
/*
Packit 1e8aac
 * glade-gtk-text-view.c - GladeWidgetAdaptor for GtkTextView
Packit 1e8aac
 *
Packit 1e8aac
 * Copyright (C) 2013 Tristan Van Berkom
Packit 1e8aac
 *
Packit 1e8aac
 * Authors:
Packit 1e8aac
 *      Tristan Van Berkom <tristan.van.berkom@gmail.com>
Packit 1e8aac
 *
Packit 1e8aac
 * This library is free software; you can redistribute it and/or modify it
Packit 1e8aac
 * under the terms of the GNU Lesser General Public License as
Packit 1e8aac
 * published by the Free Software Foundation; either version 2.1 of
Packit 1e8aac
 * the License, or (at your option) any later version.
Packit 1e8aac
 *
Packit 1e8aac
 * This library is distributed in the hope that it will be useful, but
Packit 1e8aac
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 1e8aac
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 1e8aac
 * Lesser General Public License for more details.
Packit 1e8aac
 *
Packit 1e8aac
 * You should have received a copy of the GNU Lesser General Public 
Packit 1e8aac
 * License along with this program; if not, write to the Free Software
Packit 1e8aac
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Packit 1e8aac
 */
Packit 1e8aac
Packit 1e8aac
#include <config.h>
Packit 1e8aac
#include <glib/gi18n-lib.h>
Packit 1e8aac
#include <gladeui/glade.h>
Packit 1e8aac
Packit 1e8aac
#include "glade-text-view-editor.h"
Packit 1e8aac
Packit 1e8aac
GladeEditable *
Packit 1e8aac
glade_gtk_text_view_create_editable (GladeWidgetAdaptor * adaptor,
Packit 1e8aac
				     GladeEditorPageType type)
Packit 1e8aac
{
Packit 1e8aac
  if (type == GLADE_PAGE_GENERAL)
Packit 1e8aac
    {
Packit 1e8aac
      return (GladeEditable *)glade_text_view_editor_new ();
Packit 1e8aac
    }
Packit 1e8aac
Packit 1e8aac
  return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type);
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
static gboolean
Packit 1e8aac
glade_gtk_text_view_stop_double_click (GtkWidget * widget,
Packit 1e8aac
                                       GdkEventButton * event,
Packit 1e8aac
                                       gpointer user_data)
Packit 1e8aac
{
Packit 1e8aac
  /* Return True if the event is double or triple click */
Packit 1e8aac
  return (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS);
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
void
Packit 1e8aac
glade_gtk_text_view_post_create (GladeWidgetAdaptor * adaptor,
Packit 1e8aac
                                 GObject * object, GladeCreateReason reason)
Packit 1e8aac
{
Packit 1e8aac
  /* This makes gtk_text_view_set_buffer() stop complaing */
Packit 1e8aac
  gtk_drag_dest_set (GTK_WIDGET (object), 0, NULL, 0, 0);
Packit 1e8aac
Packit 1e8aac
  /* Glade hangs when a TextView gets a double click. So we stop them */
Packit 1e8aac
  g_signal_connect (object, "button-press-event",
Packit 1e8aac
                    G_CALLBACK (glade_gtk_text_view_stop_double_click), NULL);
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
void
Packit 1e8aac
glade_gtk_text_view_set_property (GladeWidgetAdaptor * adaptor,
Packit 1e8aac
                                  GObject * object,
Packit 1e8aac
                                  const gchar * property_name,
Packit 1e8aac
                                  const GValue * value)
Packit 1e8aac
{
Packit 1e8aac
  if (strcmp (property_name, "buffer") == 0)
Packit 1e8aac
    {
Packit 1e8aac
      if (!g_value_get_object (value))
Packit 1e8aac
        return;
Packit 1e8aac
    }
Packit 1e8aac
Packit 1e8aac
  GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor,
Packit 1e8aac
                                                    object,
Packit 1e8aac
                                                    property_name, value);
Packit 1e8aac
}