One more test app
This commit is contained in:
parent
66d8110990
commit
9560b61703
@ -36,7 +36,7 @@
|
||||
<useconfiguration>debug</useconfiguration>
|
||||
</general>
|
||||
<run>
|
||||
<mainprogram>tests/testfileview</mainprogram>
|
||||
<mainprogram>tests/testpanedfileview</mainprogram>
|
||||
<directoryradio>executable</directoryradio>
|
||||
<customdirectory>/</customdirectory>
|
||||
<programargs></programargs>
|
||||
@ -158,7 +158,7 @@
|
||||
<abortonerror>true</abortonerror>
|
||||
<numberofjobs>1</numberofjobs>
|
||||
<dontact>false</dontact>
|
||||
<makebin/>
|
||||
<makebin></makebin>
|
||||
<prio>0</prio>
|
||||
</make>
|
||||
</kdevautoproject>
|
||||
|
@ -2,7 +2,7 @@
|
||||
# tests/Makefile.am
|
||||
#
|
||||
|
||||
EXTRA_PROGRAMS = medit mterm markup editor termbuffer testfileview testpaned
|
||||
EXTRA_PROGRAMS = medit mterm markup editor termbuffer testfileview testpaned testpanedfileview
|
||||
bin_PROGRAMS =
|
||||
noinst_PROGRAMS =
|
||||
|
||||
@ -21,7 +21,7 @@ if BUILD_MOOAPP
|
||||
bin_PROGRAMS += editor
|
||||
endif
|
||||
if BUILD_MOOEDIT
|
||||
noinst_PROGRAMS += medit testfileview
|
||||
noinst_PROGRAMS += medit testfileview testpanedfileview
|
||||
endif
|
||||
if BUILD_MOOTERM
|
||||
noinst_PROGRAMS += mterm termbuffer
|
||||
@ -119,3 +119,10 @@ if MINGW_BUILD
|
||||
testfileview_LDFLAGS += -mwindows
|
||||
endif MINGW_BUILD
|
||||
testfileview_SOURCES = testfileview.c
|
||||
|
||||
testpanedfileview_LDFLAGS =
|
||||
testpanedfileview_LDADD = $(MOO_LIBS) ../moo/libmoo.la
|
||||
if MINGW_BUILD
|
||||
testpanedfileview_LDFLAGS += -mwindows
|
||||
endif MINGW_BUILD
|
||||
testpanedfileview_SOURCES = testpanedfileview.c
|
||||
|
115
tests/testpanedfileview.c
Normal file
115
tests/testpanedfileview.c
Normal file
@ -0,0 +1,115 @@
|
||||
#include "mooutils/moopaned.h"
|
||||
#include "mooedit/moofileview.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, *fileview;
|
||||
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);
|
||||
|
||||
fileview = moo_file_view_new ();
|
||||
moo_file_view_chdir (MOO_FILE_VIEW (fileview),
|
||||
g_get_home_dir (), NULL);;
|
||||
moo_paned_add_pane (MOO_PANED (paned),
|
||||
fileview,
|
||||
"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