Added MooPaned and MooFileView from junk
This commit is contained in:
parent
58b370cbe6
commit
9a2a4c5ee0
32
moo.kdevelop
32
moo.kdevelop
@ -24,7 +24,7 @@
|
||||
</ignoreparts>
|
||||
<projectdirectory>.</projectdirectory>
|
||||
<absoluteprojectpath>false</absoluteprojectpath>
|
||||
<description/>
|
||||
<description></description>
|
||||
<secondaryLanguages>
|
||||
<language>C</language>
|
||||
</secondaryLanguages>
|
||||
@ -36,17 +36,17 @@
|
||||
<useconfiguration>debug</useconfiguration>
|
||||
</general>
|
||||
<run>
|
||||
<mainprogram>tests/editor</mainprogram>
|
||||
<mainprogram>tests/testfileview</mainprogram>
|
||||
<directoryradio>executable</directoryradio>
|
||||
<customdirectory>/</customdirectory>
|
||||
<programargs/>
|
||||
<programargs></programargs>
|
||||
<terminal>false</terminal>
|
||||
<autocompile>false</autocompile>
|
||||
<envvars/>
|
||||
</run>
|
||||
<configurations>
|
||||
<debug>
|
||||
<configargs>--enable-debug=full --enable-all-gcc-warnings=fatal --enable-developer-mode --disable-moo-module</configargs>
|
||||
<configargs>--enable-debug=full --enable-all-gcc-warnings=fatal --enable-developer-mode --disable-moo-module --without-mooui --without-mooapp --without-mooterm --without-mooedit --without-python</configargs>
|
||||
<builddir>build/debug</builddir>
|
||||
<ccompiler>kdevgccoptions</ccompiler>
|
||||
<cxxcompiler>kdevgppoptions</cxxcompiler>
|
||||
@ -54,13 +54,13 @@
|
||||
<cflags>-O0 -g3 -pg</cflags>
|
||||
<cxxflags>-O0 -g3 -pg</cxxflags>
|
||||
<envvars/>
|
||||
<topsourcedir/>
|
||||
<cppflags/>
|
||||
<ldflags/>
|
||||
<ccompilerbinary/>
|
||||
<cxxcompilerbinary/>
|
||||
<f77compilerbinary/>
|
||||
<f77flags/>
|
||||
<topsourcedir></topsourcedir>
|
||||
<cppflags></cppflags>
|
||||
<ldflags></ldflags>
|
||||
<ccompilerbinary></ccompilerbinary>
|
||||
<cxxcompilerbinary></cxxcompilerbinary>
|
||||
<f77compilerbinary></f77compilerbinary>
|
||||
<f77flags></f77flags>
|
||||
</debug>
|
||||
<optimized>
|
||||
<configargs>--enable-all-gcc-warnings=fatal --enable-developer-mode</configargs>
|
||||
@ -166,10 +166,10 @@
|
||||
<general>
|
||||
<dbgshell>libtool</dbgshell>
|
||||
<programargs>--g-fatal-warnings --sync</programargs>
|
||||
<gdbpath/>
|
||||
<configGdbScript/>
|
||||
<runShellScript/>
|
||||
<runGdbScript/>
|
||||
<gdbpath></gdbpath>
|
||||
<configGdbScript></configGdbScript>
|
||||
<runShellScript></runShellScript>
|
||||
<runGdbScript></runGdbScript>
|
||||
<breakonloadinglibs>true</breakonloadinglibs>
|
||||
<separatetty>false</separatetty>
|
||||
<floatingtoolbar>true</floatingtoolbar>
|
||||
@ -270,7 +270,7 @@
|
||||
</codecompletion>
|
||||
<references/>
|
||||
<creategettersetter>
|
||||
<prefixGet/>
|
||||
<prefixGet></prefixGet>
|
||||
<prefixSet>set</prefixSet>
|
||||
<prefixVariable>m_,_</prefixVariable>
|
||||
<parameterName>theValue</parameterName>
|
||||
|
@ -56,11 +56,11 @@ int _moo_edit_extend_selection (MooEdit *edit,
|
||||
/* Preferences
|
||||
/*/
|
||||
void _moo_edit_set_default_settings (void);
|
||||
void _moo_edit_apply_settings (MooEdit *edit);
|
||||
void _moo_edit_apply_style_settings (MooEdit *edit);
|
||||
void _moo_edit_settings_changed (const char *key,
|
||||
const char *newval,
|
||||
MooEdit *edit);
|
||||
void _moo_edit_apply_settings (MooEdit *edit);
|
||||
void _moo_edit_apply_style_settings (MooEdit *edit);
|
||||
void _moo_edit_settings_changed (const char *key,
|
||||
const GValue *newval,
|
||||
MooEdit *edit);
|
||||
|
||||
/***********************************************************************/
|
||||
/* File operations
|
||||
|
@ -162,7 +162,7 @@ void _moo_edit_apply_style_settings (MooEdit *edit)
|
||||
|
||||
|
||||
void _moo_edit_settings_changed (const char *key,
|
||||
G_GNUC_UNUSED const char *newval,
|
||||
G_GNUC_UNUSED const GValue *newval,
|
||||
MooEdit *edit)
|
||||
{
|
||||
GtkSourceBuffer *buffer = edit->priv->source_buffer;
|
||||
|
@ -48,12 +48,17 @@ libmooutils_la_SOURCES = \
|
||||
moodialogs.h \
|
||||
moofileutils.c \
|
||||
moofileutils.h \
|
||||
moofileview.c \
|
||||
moofileview.h \
|
||||
moofileview-icons.c \
|
||||
moolog.c \
|
||||
moolog.h \
|
||||
moomarkup.c \
|
||||
moomarkup.h \
|
||||
mooobjectfactory.c \
|
||||
mooobjectfactory.h \
|
||||
moopaned.c \
|
||||
moopaned.h \
|
||||
mooparam.c \
|
||||
mooparam.h \
|
||||
mooprefs.c \
|
||||
|
319
moo/mooutils/moofileview-icons.c
Normal file
319
moo/mooutils/moofileview-icons.c
Normal file
@ -0,0 +1,319 @@
|
||||
/*
|
||||
* mooutils/moofileview-icons.c
|
||||
*
|
||||
* Copyright (C) 2004-2005 by Yevgen Muntyan <muntyan@math.tamu.edu>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* See COPYING file that comes with this distribution.
|
||||
*/
|
||||
|
||||
#include "mooutils/moofileview.h"
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* Icon type, supplemented by MIME type
|
||||
*/
|
||||
typedef enum {
|
||||
ICON_NOENT,
|
||||
ICON_NONE, /* "Could not compute the icon type" */
|
||||
ICON_REGULAR, /* Use mime type for icon */
|
||||
ICON_BLOCK_DEVICE,
|
||||
ICON_BROKEN_SYMBOLIC_LINK,
|
||||
ICON_CHARACTER_DEVICE,
|
||||
ICON_DIRECTORY,
|
||||
ICON_EXECUTABLE,
|
||||
ICON_FIFO,
|
||||
ICON_SOCKET
|
||||
} IconType;
|
||||
|
||||
|
||||
typedef struct {
|
||||
gint size;
|
||||
GdkPixbuf *pixbuf;
|
||||
} IconCacheElement;
|
||||
|
||||
static void icon_cache_element_free (IconCacheElement *element)
|
||||
{
|
||||
if (element->pixbuf)
|
||||
g_object_unref (element->pixbuf);
|
||||
g_free (element);
|
||||
}
|
||||
|
||||
static void icon_theme_changed (GtkIconTheme *icon_theme)
|
||||
{
|
||||
GHashTable *cache;
|
||||
|
||||
/* Difference from the initial creation is that we don't
|
||||
* reconnect the signal */
|
||||
cache = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
(GDestroyNotify)g_free,
|
||||
(GDestroyNotify)icon_cache_element_free);
|
||||
g_object_set_data_full (G_OBJECT (icon_theme), "gtk-file-icon-cache",
|
||||
cache, (GDestroyNotify)g_hash_table_destroy);
|
||||
}
|
||||
|
||||
|
||||
static IconType get_icon_type_from_stat (const struct stat *statp)
|
||||
{
|
||||
if (S_ISBLK (statp->st_mode))
|
||||
return ICON_BLOCK_DEVICE;
|
||||
else if (S_ISLNK (statp->st_mode))
|
||||
return ICON_BROKEN_SYMBOLIC_LINK; /* See get_icon_type */
|
||||
else if (S_ISCHR (statp->st_mode))
|
||||
return ICON_CHARACTER_DEVICE;
|
||||
else if (S_ISDIR (statp->st_mode))
|
||||
return ICON_DIRECTORY;
|
||||
#ifdef S_ISFIFO
|
||||
else if (S_ISFIFO (statp->st_mode))
|
||||
return ICON_FIFO;
|
||||
#endif
|
||||
#ifdef S_ISSOCK
|
||||
else if (S_ISSOCK (statp->st_mode))
|
||||
return ICON_SOCKET;
|
||||
#endif
|
||||
else
|
||||
return ICON_REGULAR;
|
||||
}
|
||||
|
||||
|
||||
static IconType get_icon_type (MooFileViewFile *file)
|
||||
{
|
||||
const struct stat *statp = moo_file_view_file_get_stat (file);
|
||||
if (statp)
|
||||
return get_icon_type_from_stat (statp);
|
||||
else
|
||||
return ICON_NOENT;
|
||||
}
|
||||
|
||||
|
||||
static GdkPixbuf *get_cached_icon (GtkWidget *widget,
|
||||
const gchar *name,
|
||||
gint pixel_size)
|
||||
{
|
||||
GtkIconTheme *icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
|
||||
GHashTable *cache = g_object_get_data (G_OBJECT (icon_theme), "gtk-file-icon-cache");
|
||||
IconCacheElement *element;
|
||||
|
||||
if (!cache)
|
||||
{
|
||||
cache = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
(GDestroyNotify)g_free,
|
||||
(GDestroyNotify)icon_cache_element_free);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (icon_theme), "gtk-file-icon-cache",
|
||||
cache, (GDestroyNotify)g_hash_table_destroy);
|
||||
g_signal_connect (icon_theme, "changed",
|
||||
G_CALLBACK (icon_theme_changed), NULL);
|
||||
}
|
||||
|
||||
element = g_hash_table_lookup (cache, name);
|
||||
if (!element)
|
||||
{
|
||||
element = g_new0 (IconCacheElement, 1);
|
||||
g_hash_table_insert (cache, g_strdup (name), element);
|
||||
}
|
||||
|
||||
if (element->size != pixel_size)
|
||||
{
|
||||
if (element->pixbuf)
|
||||
g_object_unref (element->pixbuf);
|
||||
element->size = pixel_size;
|
||||
element->pixbuf = gtk_icon_theme_load_icon (icon_theme, name,
|
||||
pixel_size, 0, NULL);
|
||||
}
|
||||
|
||||
return element->pixbuf;
|
||||
}
|
||||
|
||||
|
||||
static GdkPixbuf *get_icon_for_mime_type (GtkWidget *widget,
|
||||
const char *mime_type,
|
||||
gint pixel_size)
|
||||
{
|
||||
const char *separator;
|
||||
GString *icon_name;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
separator = strchr (mime_type, '/');
|
||||
if (!separator)
|
||||
return NULL; /* maybe we should return a GError with "invalid MIME-type" */
|
||||
|
||||
icon_name = g_string_new ("gnome-mime-");
|
||||
g_string_append_len (icon_name, mime_type, separator - mime_type);
|
||||
g_string_append_c (icon_name, '-');
|
||||
g_string_append (icon_name, separator + 1);
|
||||
pixbuf = get_cached_icon (widget, icon_name->str, pixel_size);
|
||||
g_string_free (icon_name, TRUE);
|
||||
if (pixbuf)
|
||||
return pixbuf;
|
||||
|
||||
icon_name = g_string_new ("gnome-mime-");
|
||||
g_string_append_len (icon_name, mime_type, separator - mime_type);
|
||||
pixbuf = get_cached_icon (widget, icon_name->str, pixel_size);
|
||||
g_string_free (icon_name, TRUE);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
|
||||
/* Returns the name of the icon to be used for a path which is known to be a
|
||||
* directory. This can vary for Home, Desktop, etc.
|
||||
*/
|
||||
static const char *get_icon_name_for_directory (const char *path)
|
||||
{
|
||||
static char *desktop_path = NULL;
|
||||
|
||||
if (!g_get_home_dir ())
|
||||
return "gnome-fs-directory";
|
||||
|
||||
if (!desktop_path)
|
||||
desktop_path = g_build_filename (g_get_home_dir (), "Desktop", NULL);
|
||||
|
||||
if (strcmp (g_get_home_dir (), path) == 0)
|
||||
return "gnome-fs-home";
|
||||
else if (strcmp (desktop_path, path) == 0)
|
||||
return "gnome-fs-desktop";
|
||||
else
|
||||
return "gnome-fs-directory";
|
||||
}
|
||||
|
||||
|
||||
/* Renders an icon for a non-ICON_REGULAR file */
|
||||
static GdkPixbuf *get_special_icon (IconType icon_type,
|
||||
MooFileViewFile *file,
|
||||
GtkWidget *widget,
|
||||
gint pixel_size)
|
||||
{
|
||||
const char *name;
|
||||
|
||||
g_assert (icon_type != ICON_REGULAR);
|
||||
|
||||
switch (icon_type)
|
||||
{
|
||||
case ICON_BLOCK_DEVICE:
|
||||
name = "gnome-fs-blockdev";
|
||||
break;
|
||||
case ICON_BROKEN_SYMBOLIC_LINK:
|
||||
name = "gnome-fs-symlink";
|
||||
break;
|
||||
case ICON_CHARACTER_DEVICE:
|
||||
name = "gnome-fs-chardev";
|
||||
break;
|
||||
case ICON_DIRECTORY:
|
||||
name = get_icon_name_for_directory
|
||||
(moo_file_view_file_path (file));
|
||||
break;
|
||||
case ICON_EXECUTABLE:
|
||||
name ="gnome-fs-executable";
|
||||
break;
|
||||
case ICON_FIFO:
|
||||
name = "gnome-fs-fifo";
|
||||
break;
|
||||
case ICON_SOCKET:
|
||||
name = "gnome-fs-socket";
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return get_cached_icon (widget, name, pixel_size);
|
||||
}
|
||||
|
||||
|
||||
/* Renders a fallback icon from the stock system */
|
||||
static GdkPixbuf *get_fallback_icon (GtkWidget *widget,
|
||||
IconType icon_type,
|
||||
GtkIconSize size)
|
||||
{
|
||||
const char *stock_name;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
switch (icon_type)
|
||||
{
|
||||
case ICON_BLOCK_DEVICE:
|
||||
stock_name = GTK_STOCK_HARDDISK;
|
||||
break;
|
||||
|
||||
case ICON_DIRECTORY:
|
||||
stock_name = GTK_STOCK_DIRECTORY;
|
||||
break;
|
||||
|
||||
case ICON_EXECUTABLE:
|
||||
stock_name = GTK_STOCK_EXECUTE;
|
||||
break;
|
||||
|
||||
case ICON_NOENT:
|
||||
stock_name = GTK_STOCK_MISSING_IMAGE;
|
||||
break;
|
||||
|
||||
default:
|
||||
stock_name = GTK_STOCK_FILE;
|
||||
break;
|
||||
}
|
||||
|
||||
pixbuf = gtk_widget_render_icon (widget, stock_name, size, NULL);
|
||||
|
||||
if (!pixbuf)
|
||||
{
|
||||
g_warning ("%s: could not get a stock icon for %s",
|
||||
G_STRLOC, stock_name);
|
||||
}
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
|
||||
GdkPixbuf *moo_get_icon_for_file (GtkWidget *widget,
|
||||
MooFileViewFile *file,
|
||||
GtkIconSize size)
|
||||
{
|
||||
IconType icon_type;
|
||||
GdkPixbuf *pixbuf;
|
||||
int pixel_size;
|
||||
|
||||
icon_type = get_icon_type (file);
|
||||
|
||||
if (icon_type == ICON_REGULAR && !moo_file_view_file_mime_type (file))
|
||||
icon_type = ICON_NONE;
|
||||
|
||||
if (!gtk_icon_size_lookup (size, &pixel_size, NULL))
|
||||
if (!gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &pixel_size, NULL))
|
||||
pixel_size = 16;
|
||||
|
||||
switch (icon_type)
|
||||
{
|
||||
case ICON_NONE:
|
||||
goto fallback;
|
||||
|
||||
case ICON_NOENT:
|
||||
pixbuf = get_fallback_icon (widget, icon_type, size);
|
||||
break;
|
||||
|
||||
case ICON_REGULAR:
|
||||
pixbuf = get_icon_for_mime_type (widget,
|
||||
moo_file_view_file_mime_type (file),
|
||||
pixel_size);
|
||||
break;
|
||||
|
||||
default:
|
||||
pixbuf = get_special_icon (icon_type, file, widget, pixel_size);
|
||||
}
|
||||
|
||||
if (pixbuf)
|
||||
goto out;
|
||||
|
||||
fallback:
|
||||
pixbuf = get_cached_icon (widget, "gnome-fs-regular", pixel_size);
|
||||
if (!pixbuf)
|
||||
pixbuf = get_fallback_icon (widget, icon_type, size);
|
||||
|
||||
out:
|
||||
return pixbuf;
|
||||
}
|
1179
moo/mooutils/moofileview.c
Normal file
1179
moo/mooutils/moofileview.c
Normal file
File diff suppressed because it is too large
Load Diff
88
moo/mooutils/moofileview.h
Normal file
88
moo/mooutils/moofileview.h
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* mooutils/moofileview.h
|
||||
*
|
||||
* Copyright (C) 2004-2005 by Yevgen Muntyan <muntyan@math.tamu.edu>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* See COPYING file that comes with this distribution.
|
||||
*/
|
||||
|
||||
#ifndef MOOUTILS_MOOFILEVIEW_H
|
||||
#define MOOUTILS_MOOFILEVIEW_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define MOO_TYPE_FILE_VIEW_FILE (moo_file_view_file_get_type ())
|
||||
#define MOO_TYPE_FILE_VIEW_TYPE (moo_file_view_type_get_type ())
|
||||
#define MOO_TYPE_FILE_VIEW (moo_file_view_get_type ())
|
||||
#define MOO_FILE_VIEW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MOO_TYPE_FILE_VIEW, MooFileView))
|
||||
#define MOO_FILE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOO_TYPE_FILE_VIEW, MooFileViewClass))
|
||||
#define MOO_IS_FILE_VIEW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MOO_TYPE_FILE_VIEW))
|
||||
#define MOO_IS_FILE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOO_TYPE_FILE_VIEW))
|
||||
#define MOO_FILE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOO_TYPE_FILE_VIEW, MooFileViewClass))
|
||||
|
||||
|
||||
typedef enum {
|
||||
MOO_FILE_VIEW_LIST,
|
||||
MOO_FILE_VIEW_ICON
|
||||
} MooFileViewType;
|
||||
|
||||
typedef struct _MooFileView MooFileView;
|
||||
typedef struct _MooFileViewFile MooFileViewFile;
|
||||
typedef struct _MooFileViewPrivate MooFileViewPrivate;
|
||||
typedef struct _MooFileViewClass MooFileViewClass;
|
||||
|
||||
struct _MooFileView
|
||||
{
|
||||
GtkVBox vbox;
|
||||
MooFileViewPrivate *priv;
|
||||
};
|
||||
|
||||
struct _MooFileViewClass
|
||||
{
|
||||
GtkVBoxClass vbox_class;
|
||||
|
||||
gboolean (*chdir) (MooFileView *fileview,
|
||||
const char *dir,
|
||||
GError **error);
|
||||
void (*activate) (MooFileView *fileview,
|
||||
MooFileViewFile *file);
|
||||
void (*go_back) (MooFileView *fileview);
|
||||
void (*go_forward) (MooFileView *fileview);
|
||||
void (*go_home) (MooFileView *fileview);
|
||||
void (*go_up) (MooFileView *fileview);
|
||||
};
|
||||
|
||||
|
||||
GType moo_file_view_get_type (void) G_GNUC_CONST;
|
||||
GType moo_file_view_file_get_type (void) G_GNUC_CONST;
|
||||
GType moo_file_view_type_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget *moo_file_view_new (void);
|
||||
|
||||
gboolean moo_file_view_chdir (MooFileView *fileview,
|
||||
const char *dir,
|
||||
GError **error);
|
||||
|
||||
void moo_file_view_set_view_type (MooFileView *fileview,
|
||||
MooFileViewType type);
|
||||
|
||||
gconstpointer moo_file_view_file_get_stat (MooFileViewFile *file);
|
||||
const char *moo_file_view_file_path (MooFileViewFile *file);
|
||||
const char *moo_file_view_file_mime_type (MooFileViewFile *file);
|
||||
|
||||
GdkPixbuf *moo_get_icon_for_file (GtkWidget *widget,
|
||||
MooFileViewFile *file,
|
||||
GtkIconSize size);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* MOOUTILS_MOOFILEVIEW_H */
|
@ -1,6 +1,7 @@
|
||||
BOOL:VOID
|
||||
BOOL:POINTER
|
||||
BOOL:STRING
|
||||
BOOL:STRING,POINTER
|
||||
BOOL:STRING,STRING
|
||||
BOOL:STRING,STRING,POINTER
|
||||
INT:VOID
|
||||
|
1719
moo/mooutils/moopaned.c
Normal file
1719
moo/mooutils/moopaned.c
Normal file
File diff suppressed because it is too large
Load Diff
78
moo/mooutils/moopaned.h
Normal file
78
moo/mooutils/moopaned.h
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* mooutils/moopaned.h
|
||||
*
|
||||
* Copyright (C) 2004-2005 by Yevgen Muntyan <muntyan@math.tamu.edu>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* See COPYING file that comes with this distribution.
|
||||
*/
|
||||
|
||||
#ifndef MOOUTILS_MOOPANED_H
|
||||
#define MOOUTILS_MOOPANED_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define MOO_TYPE_PANED (moo_paned_get_type ())
|
||||
#define MOO_PANED(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MOO_TYPE_PANED, MooPaned))
|
||||
#define MOO_PANED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOO_TYPE_PANED, MooPanedClass))
|
||||
#define MOO_IS_PANED(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MOO_TYPE_PANED))
|
||||
#define MOO_IS_PANED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOO_TYPE_PANED))
|
||||
#define MOO_PANED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOO_TYPE_PANED, MooPanedClass))
|
||||
|
||||
|
||||
typedef struct _MooPaned MooPaned;
|
||||
typedef struct _MooPanedPrivate MooPanedPrivate;
|
||||
typedef struct _MooPanedClass MooPanedClass;
|
||||
|
||||
struct _MooPaned
|
||||
{
|
||||
GtkBin bin;
|
||||
GtkWidget *button_box;
|
||||
MooPanedPrivate *priv;
|
||||
};
|
||||
|
||||
struct _MooPanedClass
|
||||
{
|
||||
GtkBinClass bin_class;
|
||||
};
|
||||
|
||||
|
||||
GType moo_paned_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget *moo_paned_new (GtkPositionType pane_position);
|
||||
|
||||
void moo_paned_add_pane (MooPaned *paned,
|
||||
GtkWidget *pane_widget,
|
||||
const char *button_label,
|
||||
const char *button_stock_id);
|
||||
void moo_paned_insert_pane (MooPaned *paned,
|
||||
GtkWidget *pane_widget,
|
||||
GtkWidget *button_widget,
|
||||
int position);
|
||||
|
||||
guint moo_paned_n_panes (MooPaned *paned);
|
||||
|
||||
GtkWidget *moo_paned_get_nth_pane (MooPaned *paned,
|
||||
guint n);
|
||||
|
||||
void moo_paned_set_sticky_pane (MooPaned *paned,
|
||||
gboolean sticky);
|
||||
|
||||
void moo_paned_set_pane_size (MooPaned *paned,
|
||||
int size);
|
||||
|
||||
void moo_paned_open_pane (MooPaned *paned,
|
||||
guint index);
|
||||
void moo_paned_hide_pane (MooPaned *paned);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* MOOUTILS_MOOPANED_H */
|
@ -3,14 +3,14 @@
|
||||
#
|
||||
|
||||
EXTRA_PROGRAMS = medit mterm markup editor termbuffer
|
||||
bin_PROGRAMS =
|
||||
bin_PROGRAMS =
|
||||
noinst_PROGRAMS =
|
||||
|
||||
EXTRA_DIST = \
|
||||
pyapp.py.in \
|
||||
meditui.xml \
|
||||
editor-ui.xml
|
||||
|
||||
|
||||
BUILT_SOURCES = editor-ui.h
|
||||
editor-ui.h: editor-ui.xml
|
||||
sh $(srcdir)/../moo/mooutils/xml2h.sh MEDIT_UI $(srcdir)/editor-ui.xml > editor-ui.h
|
||||
@ -27,7 +27,7 @@ if BUILD_MOOTERM
|
||||
noinst_PROGRAMS += mterm termbuffer
|
||||
endif
|
||||
if BUILD_MOOUTILS
|
||||
noinst_PROGRAMS += markup
|
||||
noinst_PROGRAMS += markup testpaned testfileview
|
||||
endif
|
||||
|
||||
|
||||
@ -104,3 +104,18 @@ markup_LDFLAGS += -mwindows
|
||||
endif MINGW_BUILD
|
||||
|
||||
markup_SOURCES = markup.c
|
||||
|
||||
|
||||
testpaned_LDFLAGS =
|
||||
testpaned_LDADD = $(MOO_LIBS) ../moo/libmoo.la
|
||||
if MINGW_BUILD
|
||||
testpaned_LDFLAGS += -mwindows
|
||||
endif MINGW_BUILD
|
||||
testpaned_SOURCES = testpaned.c
|
||||
|
||||
testfileview_LDFLAGS =
|
||||
testfileview_LDADD = $(MOO_LIBS) ../moo/libmoo.la
|
||||
if MINGW_BUILD
|
||||
testfileview_LDFLAGS += -mwindows
|
||||
endif MINGW_BUILD
|
||||
testfileview_SOURCES = testfileview.c
|
||||
|
25
tests/testfileview.c
Normal file
25
tests/testfileview.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include "mooutils/moofileview.h"
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window, *tree;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_main_quit), NULL);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), -1, 500);
|
||||
|
||||
tree = moo_file_view_new ();
|
||||
gtk_container_add (GTK_CONTAINER (window), tree);
|
||||
|
||||
moo_file_view_chdir (MOO_FILE_VIEW (tree),
|
||||
g_get_home_dir (), NULL);;
|
||||
|
||||
gtk_widget_show_all (window);
|
||||
|
||||
gtk_main ();
|
||||
return 0;
|
||||
}
|
116
tests/testpaned.c
Normal file
116
tests/testpaned.c
Normal file
@ -0,0 +1,116 @@
|
||||
#include "mooutils/moopaned.h"
|
||||
|
||||
|
||||
static int WINDOWS = 0;
|
||||
|
||||
static void window_destroyed (void)
|
||||
{
|
||||
if (!--WINDOWS) gtk_main_quit ();
|
||||
}
|
||||
|
||||
|
||||
static void sticky_button_toggled (GtkToggleButton *button,
|
||||
MooPaned *paned)
|
||||
{
|
||||
gboolean active = gtk_toggle_button_get_active (button);
|
||||
moo_paned_set_sticky_pane (paned, active);
|
||||
}
|
||||
|
||||
|
||||
static void create_window_with_paned (GtkPositionType pane_position)
|
||||
{
|
||||
GtkWidget *window, *paned, *textview, *button, *label, *swin;
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (window_destroyed), NULL);
|
||||
WINDOWS++;
|
||||
|
||||
paned = moo_paned_new (pane_position);
|
||||
gtk_widget_show (paned);
|
||||
gtk_container_add (GTK_CONTAINER (window), paned);
|
||||
|
||||
textview = gtk_text_view_new ();
|
||||
gtk_widget_show (textview);
|
||||
swin = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_widget_show (swin);
|
||||
gtk_container_add (GTK_CONTAINER (paned), swin);
|
||||
gtk_container_add (GTK_CONTAINER (swin), textview);
|
||||
|
||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (textview), GTK_WRAP_WORD);
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));
|
||||
gtk_text_buffer_insert_at_cursor (buffer, "Click a button. Click a button. "
|
||||
"Click a button. Click a button. Click a button. Click a button. "
|
||||
"Click a button. Click a button. Click a button. Click a button. "
|
||||
"Click a button. Click a button. Click a button. Click a button. "
|
||||
"Click a button. Click a button. Click a button. Click a button. "
|
||||
"Click a button. Click a button. Click a button. Click a button. "
|
||||
"Click a button. Click a button. Click a button. Click a button. "
|
||||
"Click a button. Click a button. Click a button. Click a button. "
|
||||
"Click a button. Click a button. Click a button. Click a button. "
|
||||
"Click a button. Click a button. Click a button. Click a button. "
|
||||
"Click a button. Click a button. Click a button. Click a button. "
|
||||
"Click a button. Click a button. Click a button. Click a button. ",
|
||||
-1);
|
||||
|
||||
textview = gtk_text_view_new ();
|
||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (textview), GTK_WRAP_WORD);
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));
|
||||
gtk_text_buffer_insert_at_cursor (buffer, "Hi there. Hi there. "
|
||||
"Hi there. Hi there. Hi there. Hi there. Hi there. ", -1);
|
||||
moo_paned_add_pane (MOO_PANED (paned),
|
||||
textview,
|
||||
"TextView",
|
||||
GTK_STOCK_OK);
|
||||
moo_paned_add_pane (MOO_PANED (paned),
|
||||
gtk_label_new ("This is a label"),
|
||||
"Label",
|
||||
GTK_STOCK_CANCEL);
|
||||
|
||||
button = gtk_toggle_button_new ();
|
||||
gtk_widget_show (button);
|
||||
g_signal_connect (button, "toggled",
|
||||
G_CALLBACK (sticky_button_toggled),
|
||||
paned);
|
||||
gtk_box_pack_end (GTK_BOX (MOO_PANED(paned)->button_box),
|
||||
button, FALSE, FALSE, 0);
|
||||
|
||||
label = gtk_label_new ("Sticky");
|
||||
switch (pane_position)
|
||||
{
|
||||
case GTK_POS_LEFT:
|
||||
gtk_label_set_angle (GTK_LABEL (label), 90);
|
||||
break;
|
||||
case GTK_POS_RIGHT:
|
||||
gtk_label_set_angle (GTK_LABEL (label), 270);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_widget_show (label);
|
||||
gtk_container_add (GTK_CONTAINER (button), label);
|
||||
|
||||
gtk_widget_show_all (window);
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
// gdk_window_set_debug_updates (TRUE);
|
||||
|
||||
create_window_with_paned (GTK_POS_RIGHT);
|
||||
create_window_with_paned (GTK_POS_LEFT);
|
||||
create_window_with_paned (GTK_POS_TOP);
|
||||
create_window_with_paned (GTK_POS_BOTTOM);
|
||||
|
||||
gtk_main ();
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user