2005-06-23 13:18:45 -07:00
|
|
|
/*
|
|
|
|
* tests/markup.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.
|
|
|
|
*/
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#define MOOTERM_COMPILATION
|
2005-07-10 19:54:58 -07:00
|
|
|
#include "mooterm/mooterm-private.h"
|
|
|
|
#include "mooterm/mootermbuffer-private.h"
|
2005-06-22 11:20:32 -07:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2005-06-23 13:18:45 -07:00
|
|
|
|
2005-07-22 02:49:39 -07:00
|
|
|
static void breakpoint_log_handler (const gchar *log_domain,
|
|
|
|
GLogLevelFlags log_level,
|
|
|
|
const gchar *message,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
g_log_default_handler (log_domain, log_level, message, user_data);
|
|
|
|
|
|
|
|
if (log_level &
|
|
|
|
(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL))
|
|
|
|
{
|
|
|
|
G_BREAKPOINT ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void init (int *argc, char ***argv, const char **cmd)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
gboolean gdk_debug = FALSE;
|
|
|
|
gboolean set_breakpoint = FALSE;
|
|
|
|
|
|
|
|
gtk_init (argc, argv);
|
|
|
|
|
|
|
|
for (i = 1; i < *argc; ++i)
|
|
|
|
{
|
|
|
|
if (!strcmp ((*argv)[i], "--gdk-debug"))
|
|
|
|
gdk_debug = TRUE;
|
|
|
|
else if (!strcmp ((*argv)[i], "--set-breakpoint"))
|
|
|
|
set_breakpoint = TRUE;
|
|
|
|
else
|
|
|
|
*cmd = (*argv)[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gdk_debug)
|
|
|
|
gdk_window_set_debug_updates (TRUE);
|
|
|
|
|
2005-07-22 05:00:30 -07:00
|
|
|
if (set_breakpoint)
|
2005-07-25 09:12:16 -07:00
|
|
|
{
|
|
|
|
#if GLIB_CHECK_VERSION(2,6,0)
|
2005-07-22 02:49:39 -07:00
|
|
|
g_log_set_default_handler (breakpoint_log_handler, NULL);
|
2005-07-25 09:12:16 -07:00
|
|
|
#else
|
|
|
|
g_log_set_handler ("Gtk", breakpoint_log_handler, NULL);
|
|
|
|
g_log_set_handler ("Glib", breakpoint_log_handler, NULL);
|
|
|
|
g_log_set_handler ("Pango", breakpoint_log_handler, NULL);
|
|
|
|
g_log_set_handler ("Gdk", breakpoint_log_handler, NULL);
|
|
|
|
g_log_set_handler ("Moo", breakpoint_log_handler, NULL);
|
|
|
|
g_log_set_handler (NULL, breakpoint_log_handler, NULL);
|
|
|
|
#endif
|
|
|
|
}
|
2005-07-22 02:49:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-21 15:11:16 -07:00
|
|
|
static void set_width (MooTerm *term, guint width, GtkWindow *window)
|
|
|
|
{
|
|
|
|
guint height;
|
|
|
|
height = term_char_height (term) * 25;
|
|
|
|
width *= term_char_width (term);
|
|
|
|
gtk_widget_set_size_request (GTK_WIDGET (term), width, height);
|
|
|
|
gtk_window_resize (window, 10, 10);
|
|
|
|
gtk_container_check_resize (GTK_CONTAINER (window));
|
|
|
|
gdk_window_process_updates (GTK_WIDGET(window)->window, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-22 15:13:12 -07:00
|
|
|
int main (int argc, char *argv[])
|
2005-06-22 11:20:32 -07:00
|
|
|
{
|
2005-07-01 02:53:39 -07:00
|
|
|
const char *cmd = NULL;
|
2005-06-23 13:18:45 -07:00
|
|
|
GtkWidget *win, *swin, *term;
|
|
|
|
|
2005-07-22 02:49:39 -07:00
|
|
|
init (&argc, &argv, &cmd);
|
2005-07-10 19:54:58 -07:00
|
|
|
|
|
|
|
if (!cmd)
|
2005-06-22 15:13:12 -07:00
|
|
|
{
|
2005-07-01 02:53:39 -07:00
|
|
|
cmd = g_getenv ("SHELL");
|
|
|
|
if (!cmd)
|
|
|
|
cmd = "sh";
|
2005-06-22 11:20:32 -07:00
|
|
|
}
|
|
|
|
|
2005-06-23 13:18:45 -07:00
|
|
|
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
2005-07-04 12:22:02 -07:00
|
|
|
gtk_window_set_default_size (GTK_WINDOW (win), 700, 500);
|
2005-06-23 13:18:45 -07:00
|
|
|
swin = gtk_scrolled_window_new (NULL, NULL);
|
2005-06-22 11:20:32 -07:00
|
|
|
gtk_container_add (GTK_CONTAINER (win), swin);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
|
|
|
|
GTK_POLICY_NEVER,
|
2005-07-10 19:54:58 -07:00
|
|
|
// GTK_POLICY_NEVER);
|
|
|
|
// GTK_POLICY_AUTOMATIC);
|
|
|
|
GTK_POLICY_ALWAYS);
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-20 08:52:15 -07:00
|
|
|
term = GTK_WIDGET (g_object_new (MOO_TYPE_TERM,
|
2005-07-21 15:11:16 -07:00
|
|
|
"cursor-blinks", FALSE,
|
|
|
|
"font-name", "Courier New 11",
|
2005-07-20 08:52:15 -07:00
|
|
|
NULL));
|
2005-07-21 15:11:16 -07:00
|
|
|
|
2005-06-22 11:20:32 -07:00
|
|
|
gtk_container_add (GTK_CONTAINER (swin), term);
|
|
|
|
|
|
|
|
gtk_widget_show_all (win);
|
2005-07-21 15:11:16 -07:00
|
|
|
gtk_container_set_resize_mode (GTK_CONTAINER (win),
|
|
|
|
GTK_RESIZE_IMMEDIATE);
|
|
|
|
gtk_container_set_resize_mode (GTK_CONTAINER (swin),
|
|
|
|
GTK_RESIZE_IMMEDIATE);
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-21 15:11:16 -07:00
|
|
|
g_signal_connect (term, "set-width",
|
|
|
|
G_CALLBACK (set_width), win);
|
2005-07-10 19:54:58 -07:00
|
|
|
g_signal_connect_swapped (term, "set-window-title",
|
2005-07-01 03:26:55 -07:00
|
|
|
G_CALLBACK (gtk_window_set_title), win);
|
2005-07-10 19:54:58 -07:00
|
|
|
g_signal_connect_swapped (term, "set-icon-name",
|
|
|
|
G_CALLBACK (gdk_window_set_icon_name), win->window);
|
2005-07-01 03:26:55 -07:00
|
|
|
|
2005-06-22 15:13:12 -07:00
|
|
|
moo_term_fork_command (MOO_TERM (term), cmd, NULL, NULL);
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-14 23:39:21 -07:00
|
|
|
g_signal_connect (win, "destroy", gtk_main_quit, NULL);
|
|
|
|
g_signal_connect_swapped (term, "child-died",
|
|
|
|
G_CALLBACK (gtk_widget_destroy), win);
|
|
|
|
g_signal_connect (term, "bell", G_CALLBACK (gdk_beep), NULL);
|
|
|
|
|
2005-06-22 11:20:32 -07:00
|
|
|
gtk_main ();
|
|
|
|
}
|