Beispiel #1
0
static void
uni_scroll_win_adjustment_changed (GtkAdjustment * adj, UniScrollWin * window)
{
    GtkAdjustment *hadj, *vadj;
    hadj = gtk_range_get_adjustment (GTK_RANGE (window->hscroll));
    vadj = gtk_range_get_adjustment (GTK_RANGE (window->vscroll));

    /* We compare with the allocation size for the window instead of
       hadj->page_size and vadj->page_size. If the scrollbars are
       shown the views size is about 15 pixels shorter and thinner,
       which makes the page sizes inaccurate. The scroll windows
       allocation, on the other hand, always gives the correct number
       of pixels that COULD be shown if the scrollbars weren't
       there.
     */
    int width = GTK_WIDGET (window)->allocation.width;
    int height = GTK_WIDGET (window)->allocation.height;

    gboolean hide_hscr = (hadj->upper <= width);
    gboolean hide_vscr = (vadj->upper <= height);

    if (hide_hscr && hide_vscr)
    {
        gtk_widget_hide (window->vscroll);
        gtk_widget_hide (window->hscroll);
        gtk_widget_hide (window->nav_box);
    }
    else
    {
        gtk_widget_show_now (window->vscroll);
        gtk_widget_show_now (window->hscroll);
        gtk_widget_show_now (window->nav_box);
    }
}
Beispiel #2
0
void CreateInfoDialog(InfoDialog * infoDialog, GtkWidget * window)
{
	GtkWidget *hbox, *pixmap;

	infoDialog->dialog = gtk_dialog_new();
	gtk_window_set_title(GTK_WINDOW(infoDialog->dialog), _("Info"));
	gtk_window_set_modal(GTK_WINDOW(infoDialog->dialog), TRUE);
	gtk_window_position(GTK_WINDOW(infoDialog->dialog), GTK_WIN_POS_MOUSE);
	gtk_container_set_border_width(GTK_CONTAINER(infoDialog->dialog), 5);
	gtk_signal_connect(GTK_OBJECT(infoDialog->dialog), "delete_event",
			   GTK_SIGNAL_FUNC(DeleteEvent), NULL);

	hbox = gtk_hbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(GTK_DIALOG(infoDialog->dialog)->vbox), hbox);
	gtk_widget_show_now(hbox);

	if (window) {
		pixmap = NewPixmap(info_xpm, window->window, &window->style->bg[GTK_STATE_NORMAL]);
		gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 10);
		gtk_widget_show_now(pixmap);
	}

	infoDialog->text = gtk_label_new("");
	gtk_box_pack_start(GTK_BOX(hbox), infoDialog->text, FALSE, FALSE, 10);
	gtk_widget_show_now(infoDialog->text);
}
Beispiel #3
0
static void
test_click_content_widget (void)
{
  GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test click on content widget");
  GtkWidget *expander = gtk_expander_new ("Test Expander");
  GtkWidget *entry = gtk_entry_new ();
  gboolean expanded;
  gboolean simsuccess;
  gtk_container_add (GTK_CONTAINER (expander), entry);
  gtk_container_add (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (window))), expander);
  gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
  gtk_widget_show (expander);
  gtk_widget_show (entry);
  gtk_widget_show_now (window);

  /* check click on content with expander open */
  expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
  g_assert (expanded);
  simsuccess = gtk_test_widget_click (entry, 1, 0);
  g_assert (simsuccess == TRUE);
  while (gtk_events_pending ()) /* let expander timeout/idle handlers update */
    gtk_main_iteration ();
  expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
  g_assert (expanded);
}
Beispiel #4
0
void disp_tsin_select(int index)
{
    int x,y;

    if (index < 0)
        return;

//  dbg("hime_edit_display_ap_only() %d\n", hime_edit_display_ap_only());

    if (hime_edit_display_ap_only()) {
        getRootXY(current_CS->client_win, current_CS->spot_location.x, current_CS->spot_location.y, &x, &y);
    } else {
#if 1
        int i;
        // bug in GTK, widget position is wrong, repeat util find one
        for(i=index; i>=0; i--) {
            gtk_widget_show_now(chars[i].label);
            gtk_widget_show(chars[i].vbox);
            gtk_main_iteration_do(FALSE);

            int tx = get_widget_xy(gwin0, chars[i].vbox, &x, &y);

            if (tx>=0)
                break;
        }
#else
        get_widget_xy(gwin0, chars[index].vbox, &x, &y);
#endif
        get_win0_geom();
    }
    disp_selections(x, y);
}
Beispiel #5
0
/**
 * gtk_test_display_button_window:
 * @window_title:       Title of the window to be displayed.
 * @dialog_text:        Text inside the window to be displayed.
 * @...:                %NULL terminated list of (const char *label, int *nump) pairs.
 *
 * Create a window with window title @window_title, text contents @dialog_text,
 * and a number of buttons, according to the paired argument list given
 * as @... parameters.
 * Each button is created with a @label and a ::clicked signal handler that
 * incremrents the integer stored in @nump.
 * The window will be automatically shown with gtk_widget_show_now() after
 * creation, so when this function returns it has already been mapped,
 * resized and positioned on screen.
 * The window will quit any running gtk_main()-loop when destroyed, and it
 * will automatically be destroyed upon test function teardown.
 *
 * Returns: (transfer full): a widget pointer to the newly created GtkWindow.
 *
 * Since: 2.14
 **/
GtkWidget*
gtk_test_display_button_window (const gchar *window_title,
                                const gchar *dialog_text,
                                ...) /* NULL terminated list of (label, &int) pairs */
{
    va_list var_args;
    GtkWidget *window = gtk_test_create_widget (GTK_TYPE_WINDOW, "title", window_title, NULL);
    GtkWidget *vbox = gtk_test_create_widget (GTK_TYPE_BOX, "parent", window, "orientation", GTK_ORIENTATION_VERTICAL, NULL);
    const char *arg1;
    gtk_test_create_widget (GTK_TYPE_LABEL, "label", dialog_text, "parent", vbox, NULL);
    g_signal_connect (window, "destroy", G_CALLBACK (try_main_quit), NULL);
    va_start (var_args, dialog_text);
    arg1 = va_arg (var_args, const char*);
    while (arg1)
    {
        int *arg2 = va_arg (var_args, int*);
        GtkWidget *button = gtk_test_create_widget (GTK_TYPE_BUTTON, "label", arg1, "parent", vbox, NULL);
        g_signal_connect_swapped (button, "clicked", G_CALLBACK (test_increment_intp), arg2);
        arg1 = va_arg (var_args, const char*);
    }
    va_end (var_args);
    gtk_widget_show_all (vbox);
    gtk_widget_show_now (window);
    while (gtk_events_pending ())
        gtk_main_iteration ();
    return window;
}
Beispiel #6
0
JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1widget_1show_1now)
	(JNIEnv *env, jclass that, jint arg0)
{
	GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1show_1now_FUNC);
	gtk_widget_show_now((GtkWidget *)arg0);
	GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1show_1now_FUNC);
}
Beispiel #7
0
static void
test_click_content_widget (void)
{
  GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test click on content widget");
  GtkWidget *expander = gtk_expander_new ("Test Expander");
  GtkWidget *entry = gtk_entry_new ();
  gboolean expanded;
  gboolean simsuccess;
  gtk_container_add (GTK_CONTAINER (expander), entry);
  gtk_container_add (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (window))), expander);
  gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
  gtk_widget_show (expander);
  gtk_widget_show (entry);
  gtk_widget_show_now (window);

  /* check click on content with expander open */
  expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
  g_assert (expanded);
  simsuccess = gtk_test_widget_click (entry, 1, 0);
  g_assert (simsuccess == TRUE);

  gtk_test_widget_wait_for_draw (expander);

  expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
  g_assert (expanded);
}
/*
 * stop all the mitm attack(s)
 */
void gtkui_mitm_stop(void)
{
   GtkWidget *dialog;
   
   DEBUG_MSG("gtk_mitm_stop");

   /* create the dialog */
   dialog = gtk_message_dialog_new(GTK_WINDOW (window), GTK_DIALOG_MODAL,
            GTK_MESSAGE_INFO, 0, "Stopping the mitm attack...");
   gtk_window_set_position(GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
   gtk_window_set_resizable(GTK_WINDOW (dialog), FALSE);
   gtk_widget_queue_draw(dialog);
   gtk_widget_show_now(dialog);

   /* for GTK to display the dialog now */
   while (gtk_events_pending ())
      gtk_main_iteration ();

   /* stop the mitm process */
   mitm_stop();

   gtk_widget_destroy(dialog);
   
   gtkui_message("MITM attack(s) stopped");
}
Beispiel #9
0
static void
test_action_widgets (void)
{
  GtkWidget *dialog;
  GtkFileChooserAction action;
  gboolean passed;

  dialog = gtk_file_chooser_dialog_new ("Test file chooser",
					NULL,
					GTK_FILE_CHOOSER_ACTION_OPEN,
					GTK_STOCK_CANCEL,
					GTK_RESPONSE_CANCEL,
					GTK_STOCK_OK,
					GTK_RESPONSE_ACCEPT,
					NULL);
  gtk_widget_show_now (dialog);

  action = gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog));

  passed = test_widgets_for_current_action (GTK_FILE_CHOOSER_DIALOG (dialog), action);
  log_test (passed, "test_action_widgets(): widgets for initial action %s", get_action_name (action));
  g_assert (passed);

  passed = foreach_action (GTK_FILE_CHOOSER_DIALOG (dialog), switch_from_action_cb, NULL);
  log_test (passed, "test_action_widgets(): all transitions through property change");
  g_assert (passed);

  gtk_widget_destroy (dialog);
}
Beispiel #10
0
static void
test_click_expander (void)
{
  GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test click on expander");
  GtkWidget *expander = gtk_expander_new ("Test Expander");
  GtkWidget *label = gtk_label_new ("Test Label");
  gboolean expanded;
  gboolean simsuccess;
  gtk_container_add (GTK_CONTAINER (expander), label);
  gtk_container_add (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (window))), expander);
  gtk_widget_show (expander);
  gtk_widget_show (label);
  gtk_widget_show_now (window);
  /* check initial expander state */
  expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
  g_assert (!expanded);
  /* check expanding */
  simsuccess = gtk_test_widget_click (expander, 1, 0);
  g_assert (simsuccess == TRUE);
  while (gtk_events_pending ()) /* let expander timeout/idle handlers update */
    gtk_main_iteration ();
  expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
  g_assert (expanded);
  /* check collapsing */
  simsuccess = gtk_test_widget_click (expander, 1, 0);
  g_assert (simsuccess == TRUE);
  while (gtk_events_pending ()) /* let expander timeout/idle handlers update */
    gtk_main_iteration ();
  expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
  g_assert (!expanded);
}
Beispiel #11
0
gint
main (gint argc, gchar **argv)
{
	GOptionContext *context;
	GtkWidget *window;
	GError *error = NULL;

	static gchar **remaining_args = NULL;
	gchar *initial_key = NULL;
		
	const GOptionEntry entries[] = 
	{
	  { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args, NULL, N_("[KEY]") },
	  { NULL }
	};

	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	context = g_option_context_new (N_("- Directly edit your entire configuration database"));

	g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
	g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
	g_option_context_add_group (context, gtk_get_option_group (TRUE));

	if (!g_option_context_parse (context, &argc, &argv, &error)) {
		g_critical ("Failed to parse arguments: %s", error->message);
		g_error_free (error);
		g_option_context_free (context);
		exit (1);
	}

	g_option_context_free (context);

	/* Register our stock icons */
        gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), ICONDIR);
	mateconf_stock_icons_register ();
	load_accel_map ();

        gtk_window_set_default_icon_name ("mateconf-editor");

	window = mateconf_editor_application_create_editor_window (MATECONF_EDITOR_WINDOW_TYPE_NORMAL);
	gtk_widget_show_now (window);

	/* get the key specified on the command line if any. Ignore the rest */
	initial_key = remaining_args != NULL ? remaining_args[0] : NULL;

	if (initial_key != NULL)
		mateconf_editor_window_go_to (MATECONF_EDITOR_WINDOW (window),initial_key);
	
	gtk_main ();

	save_accel_map ();
	g_strfreev (remaining_args);

	return 0;
}
Beispiel #12
0
static IncProgressDialog *inc_progress_dialog_create(gboolean autocheck)
{
	IncProgressDialog *dialog;
	ProgressDialog *progress;
	static GdkGeometry geometry;

	dialog = g_new0(IncProgressDialog, 1);

	progress = progress_dialog_create();
	gtk_window_set_title(GTK_WINDOW(progress->window),
			     _("Retrieving new messages"));
	g_signal_connect(G_OBJECT(progress->showlog_btn), "clicked",
			 G_CALLBACK(inc_showlog_cb), dialog);
	g_signal_connect(G_OBJECT(progress->cancel_btn), "clicked",
			 G_CALLBACK(inc_cancel_cb), dialog);
	g_signal_connect(G_OBJECT(progress->window), "delete_event",
			 G_CALLBACK(inc_dialog_delete_cb), dialog);
	g_signal_connect(G_OBJECT(progress->window), "size_allocate",
			 G_CALLBACK(inc_progress_dialog_size_allocate_cb), NULL);
 	/* manage_window_set_transient(GTK_WINDOW(progress->window)); */

	progress_dialog_get_fraction(progress);

	stock_pixbuf_gdk(progress->treeview, STOCK_PIXMAP_COMPLETE,
			 &okpix);
	stock_pixbuf_gdk(progress->treeview, STOCK_PIXMAP_CONTINUE,
			 &currentpix);
	stock_pixbuf_gdk(progress->treeview, STOCK_PIXMAP_ERROR,
			 &errorpix);

	if (!geometry.min_height) {
		geometry.min_width = 460;
		geometry.min_height = 250;
	}

	gtk_window_set_geometry_hints(GTK_WINDOW(progress->window), NULL, &geometry,
				      GDK_HINT_MIN_SIZE);
	gtk_widget_set_size_request(progress->window, prefs_common.receivewin_width,
				    prefs_common.receivewin_height);

	if (prefs_common.recv_dialog_mode == RECV_DIALOG_ALWAYS ||
	    (prefs_common.recv_dialog_mode == RECV_DIALOG_MANUAL &&
	     !autocheck)) {
		dialog->show_dialog = TRUE;
		gtk_widget_show_now(progress->window);
	}

	dialog->dialog = progress;
	g_get_current_time(&dialog->progress_tv);
	g_get_current_time(&dialog->folder_tv);
	dialog->queue_list = NULL;
	dialog->cur_row = 0;

	inc_dialog_list = g_list_append(inc_dialog_list, dialog);

	return dialog;
}
Beispiel #13
0
void ease_dialog_progress_show (EaseDialogProgress* self) {
#line 95 "ease-dialog-progress.vala"
	g_return_if_fail (self != NULL);
#line 99 "ease-dialog-progress.vala"
	if (!self->priv->destroyed) {
#line 99 "ease-dialog-progress.vala"
		gtk_widget_show_now ((GtkWidget*) self->priv->dialog);
#line 241 "ease-dialog-progress.c"
	}
}
Beispiel #14
0
/* Show a widget now */
int
clip_GTK_WIDGETSHOWNOW(ClipMachine * cm)
{
	C_widget *cwid = _fetch_cw_arg(cm);
	CHECKCWID(cwid,GTK_IS_WIDGET);
	gtk_widget_show_now(cwid->widget);
	return 0;
err:
	return 1;
}
bool C4Window::ReInit(C4AbstractApp* pApp)
{
	// Check whether multisampling settings was changed. If not then we
	// don't need to ReInit anything.
#ifdef GDK_WINDOWING_X11
	int value;
	Display * const dpy = gdk_x11_display_get_xdisplay(gdk_display_get_default());
	glXGetFBConfigAttrib(dpy, Info, GLX_SAMPLES, &value);
	if(value == Config.Graphics.MultiSampling) return true;

	// Check whether we have a visual with the requested number of samples
	GLXFBConfig new_info;
	if(!FindFBConfig(Config.Graphics.MultiSampling, &new_info)) return false;

	GdkScreen * scr = gtk_widget_get_screen(GTK_WIDGET(render_widget));
	XVisualInfo *vis_info = glXGetVisualFromFBConfig(dpy, new_info);
	assert(vis_info);
	GdkVisual * vis = gdk_x11_screen_lookup_visual(scr, vis_info->visualid);
	XFree(vis_info);

	// Un- and re-realizing the render_widget does not work, the window
	// remains hidden afterwards. So we re-create it from scratch.
	gtk_widget_destroy(GTK_WIDGET(render_widget));
	render_widget = gtk_drawing_area_new();
#if !GTK_CHECK_VERSION(3,10,0)
	gtk_widget_set_double_buffered (GTK_WIDGET(render_widget), false);
#endif
	g_object_set(G_OBJECT(render_widget), "can-focus", TRUE, NULL);
	
	gtk_widget_set_visual(GTK_WIDGET(render_widget),vis);

	Info = new_info;

	// Wait until window is mapped to get the window's XID
	gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(render_widget));
	gtk_widget_show_now(GTK_WIDGET(render_widget));

	if (GTK_IS_LAYOUT(render_widget))
	{
		GdkWindow* bin_wnd = gtk_layout_get_bin_window(GTK_LAYOUT(render_widget));
		renderwnd = GDK_WINDOW_XID(bin_wnd);
	}
	else
	{
		GdkWindow* render_wnd = gtk_widget_get_window(GTK_WIDGET(render_widget));
		renderwnd = GDK_WINDOW_XID(render_wnd);
	}

	gdk_flush();
	gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(render_widget)),
	                      gdk_cursor_new_for_display(gdk_display_get_default(), GDK_BLANK_CURSOR));
	return true;
#endif
}
Beispiel #16
0
void Ctrl::WndShow(bool b)
{
	GuiLock __;
	LLOG("WndShow " << Name() << ", " << b);
	if(IsOpen()) {
		if(b)
			gtk_widget_show_now(top->window);
		else
			gtk_widget_hide(top->window);
		StateH(SHOW);
	}
}
Beispiel #17
0
gint main (gint argc, gchar *argv[])
{
	GtkWidget *win, *html_widget, *sw;
	GtkHTML *html;
	gint i = 0, n_all, n_successful;

	if (argc > 1)
		return 0;

	gtk_init (&argc, &argv);

	html_widget = gtk_html_new ();
	html = GTK_HTML (html_widget);
	gtk_html_load_empty (html);
	gtk_html_set_editable (html, TRUE);
	win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_widget_set_size_request (win, 600, 400);
	gtk_container_add (GTK_CONTAINER (sw), html_widget);
	gtk_container_add (GTK_CONTAINER (win), sw);

	gtk_widget_show_all (win);
	gtk_widget_show_now (win);

	n_all = n_successful = 0;

	fprintf (stderr, "\nGtkHTML test suite\n");
	fprintf (stderr, "--------------------------------------------------------------------------------\n");
	for (i = 0; tests [i].name; i ++) {
		gint j, result;

		if (tests [i].test_function) {
			fprintf (stderr, "  %s ", tests [i].name);
			for (j = strlen (tests [i].name); j < 69; j ++)
				fputc ('.', stderr);
			result = (*tests [i].test_function) (html);
			fprintf (stderr, " %s\n", result ? "passed" : "failed");

			n_all ++;
			if (result)
				n_successful ++;
		} else {
			fprintf (stderr, "* %s\n", tests [i].name);
		}
	}

	fprintf (stderr, "--------------------------------------------------------------------------------\n");
	fprintf (stderr, "%d tests failed %d tests passed (of %d tests)\n\n", n_all - n_successful, n_successful, n_all);

	gtk_main ();

	return n_all != n_successful;
}
Beispiel #18
0
/*
 * The button with this handler appears in the F10 menu, so it
 * cannot depend on callback data being passed in.
 */
void
mdm_lang_handler (gpointer user_data)
{
  if (dialog == NULL)
    mdm_lang_setup_treeview ();

  gtk_widget_show_all (dialog);
  mdm_wm_center_window (GTK_WINDOW (dialog));

  mdm_wm_no_login_focus_push ();
  if (tv != NULL)
    {
      GtkTreeSelection *selection;
	  
      gtk_widget_show_now (dialog);
      selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tv));
      if (selection == NULL)
	gtk_tree_selection_select_path (selection, gtk_tree_path_new_first ());
      else
        {
          GtkTreeIter iter;
          GtkTreePath *path;
          GtkTreeModel *tm = GTK_TREE_MODEL (lang_model);

          gtk_tree_selection_get_selected (selection, &tm, &iter);
          path = gtk_tree_model_get_path (GTK_TREE_MODEL (lang_model), &iter);
          gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tv), path, NULL, FALSE, 0.0, 0.0);
          gtk_tree_path_free (path);
        }
    }
  switch (gtk_dialog_run (GTK_DIALOG (dialog)))
    {
    case GTK_RESPONSE_OK:
      if (dialog_selected_language)
        {
          gchar *language = g_strdup (dialog_selected_language);

          /* dialog_selected_language will be freed in mdm_lang_set */
          mdm_lang_set_restart_dialog (language);
          g_free (language);
        }

      break;
    case GTK_RESPONSE_CANCEL:
    default:
      break;
    }

  mdm_wm_no_login_focus_pop ();

  if (dialog)
    gtk_widget_hide (dialog);
}
Beispiel #19
0
/**
 * @brief
 * @param ui The GstSwitchUI instance.
 * @param error
 * @memberof GstSwitchUI
 */
static void
gst_switch_ui_on_controller_closed (GstSwitchUI * ui, GError * error)
{
#if 0
  GtkWidget *msg = gtk_message_dialog_new (GTK_WINDOW (ui->window),
      GTK_DIALOG_MODAL,
      GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
      "Switch server closed.\n" "%s",
      error->message);
  gtk_widget_show_now (msg);
#endif
  gtk_main_quit ();
}
Beispiel #20
0
/**
 * thunar_util_parse_parent:
 * @parent        : a #GtkWidget, a #GdkScreen or %NULL.
 * @window_return : return location for the toplevel #GtkWindow or
 *                  %NULL.
 *
 * Determines the screen for the @parent and returns that #GdkScreen.
 * If @window_return is not %NULL, the pointer to the #GtkWindow is
 * placed into it, or %NULL if the window could not be determined.
 *
 * Return value: the #GdkScreen for the @parent.
 **/
GdkScreen*
thunar_util_parse_parent (gpointer    parent,
                          GtkWindow **window_return)
{
  GdkScreen *screen;
  GtkWidget *window = NULL;

  _thunar_return_val_if_fail (parent == NULL || GDK_IS_SCREEN (parent) || GTK_IS_WIDGET (parent), NULL);

  /* determine the proper parent */
  if (parent == NULL)
    {
      /* just use the default screen then */
      screen = gdk_screen_get_default ();
    }
  else if (GDK_IS_SCREEN (parent))
    {
      /* yep, that's a screen */
      screen = GDK_SCREEN (parent);
    }
  else
    {
      /* parent is a widget, so let's determine the toplevel window */
      window = gtk_widget_get_toplevel (GTK_WIDGET (parent));
      if (window != NULL
          && gtk_widget_is_toplevel (window))
        {
          /* make sure the toplevel window is shown */
          gtk_widget_show_now (window);
        }
      else
        {
          /* no toplevel, not usable then */
          window = NULL;
        }

      /* determine the screen for the widget */
      screen = gtk_widget_get_screen (GTK_WIDGET (parent));
    }

  /* check if we should return the window */
  if (G_LIKELY (window_return != NULL))
    *window_return = (GtkWindow *) window;

  return screen;
}
Beispiel #21
0
static void
test_xserver_sync (void)
{
  GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test: test_xserver_sync");
  GtkWidget *darea = gtk_drawing_area_new ();
  GTimer *gtimer = g_timer_new();
  gint sync_is_slower = 0, repeat = 5;
  gtk_widget_set_size_request (darea, 320, 200);
  gtk_container_add (GTK_CONTAINER (GTK_BIN (window)->child), darea);
  gtk_widget_show (darea);
  gtk_widget_show_now (window);
  while (repeat--)
    {
      gint i, many = 200;
      double nosync_time, sync_time;
      cairo_t *cr;

      while (gtk_events_pending ())
        gtk_main_iteration ();
      cr = gdk_cairo_create (darea->window);
      cairo_set_source_rgba (cr, 0, 1, 0, 0.1);
      /* run a number of consecutive drawing requests, just using drawing queue */
      g_timer_start (gtimer);
      for (i = 0; i < many; i++)
        {
          cairo_paint (cr);
        }
      g_timer_stop (gtimer);
      nosync_time = g_timer_elapsed (gtimer, NULL);
      gdk_flush();
      while (gtk_events_pending ())
        gtk_main_iteration ();
      g_timer_start (gtimer);
      /* run a number of consecutive drawing requests with intermediate drawing syncs */
      for (i = 0; i < many; i++)
        {
          cairo_paint (cr);
          gdk_test_render_sync (darea->window);
        }
      g_timer_stop (gtimer);
      sync_time = g_timer_elapsed (gtimer, NULL);
      sync_is_slower += sync_time > nosync_time * 1.5;
    }
  g_timer_destroy (gtimer);
  g_assert (sync_is_slower > 0);
}
Beispiel #22
0
static void
test_spin_button_arrows (void)
{
  GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test: test_spin_button_arrows");
  GtkWidget *spinner = gtk_spin_button_new_with_range (0, 100, 5);
  gboolean simsuccess;
  double oldval, newval;
  gtk_container_add (GTK_CONTAINER (GTK_BIN (window)->child), spinner);
  gtk_widget_show (spinner);
  gtk_widget_show_now (window);
  gtk_test_slider_set_perc (spinner, 0);
  /* check initial spinner value */
  oldval = gtk_test_slider_get_value (spinner);
  g_assert (oldval == 0);
  /* check simple increment */
  simsuccess = gtk_test_spin_button_click (GTK_SPIN_BUTTON (spinner), 1, TRUE);
  g_assert (simsuccess == TRUE);
  while (gtk_events_pending ()) /* let spin button timeout/idle handlers update */
    gtk_main_iteration ();
  newval = gtk_test_slider_get_value (spinner);
  g_assert (newval > oldval);
  /* check maximum warp */
  simsuccess = gtk_test_spin_button_click (GTK_SPIN_BUTTON (spinner), 3, TRUE);
  g_assert (simsuccess == TRUE);
  while (gtk_events_pending ()) /* let spin button timeout/idle handlers update */
    gtk_main_iteration ();
  oldval = gtk_test_slider_get_value (spinner);
  g_assert (oldval == 100);
  /* check simple decrement */
  oldval = gtk_test_slider_get_value (spinner);
  simsuccess = gtk_test_spin_button_click (GTK_SPIN_BUTTON (spinner), 1, FALSE);
  g_assert (simsuccess == TRUE);
  while (gtk_events_pending ()) /* let spin button timeout/idle handlers update */
    gtk_main_iteration ();
  newval = gtk_test_slider_get_value (spinner);
  g_assert (newval < oldval);
  /* check minimum warp */
  simsuccess = gtk_test_spin_button_click (GTK_SPIN_BUTTON (spinner), 3, FALSE);
  g_assert (simsuccess == TRUE);
  while (gtk_events_pending ()) /* let spin button timeout/idle handlers update */
    gtk_main_iteration ();
  oldval = gtk_test_slider_get_value (spinner);
  g_assert (oldval == 0);
}
Beispiel #23
0
/**
 * Handles the 'activate' signal on the tray_icon,
 * usually opening the popup_window and grabbing pointer and keyboard.
 *
 * @param status_icon the object which received the signal
 * @param user_data user data set when the signal handler was connected
 */
void
tray_icon_on_click(G_GNUC_UNUSED GtkStatusIcon *status_icon,
		G_GNUC_UNUSED gpointer user_data)
{
	get_current_levels();
	if (!gtk_widget_get_visible(GTK_WIDGET(popup_window))) {
		gtk_widget_show_now(popup_window);
		gtk_widget_grab_focus(vol_scale);
#ifdef WITH_GTK3
		GdkDevice *pointer_dev = gtk_get_current_event_device();
		if (pointer_dev != NULL) {
			GdkDevice *keyboard_dev =
				gdk_device_get_associated_device(pointer_dev);
			if (gdk_device_grab(pointer_dev,
					    gtk_widget_get_window(GTK_WIDGET(popup_window)),
					    GDK_OWNERSHIP_NONE,
					    TRUE,
					    GDK_BUTTON_PRESS_MASK,
					    NULL, GDK_CURRENT_TIME) != GDK_GRAB_SUCCESS)
				g_warning("Could not grab %s\n",
					  gdk_device_get_name(pointer_dev));
			if (keyboard_dev != NULL) {
				if (gdk_device_grab(keyboard_dev,
						    gtk_widget_get_window(GTK_WIDGET(popup_window)),
						    GDK_OWNERSHIP_NONE,
						    TRUE,
						    GDK_KEY_PRESS_MASK,
						    NULL, GDK_CURRENT_TIME) != GDK_GRAB_SUCCESS)
					g_warning("Could not grab %s\n",
						  gdk_device_get_name(keyboard_dev));
			}
		}
#else
		gdk_keyboard_grab(gtk_widget_get_window(popup_window),
				  TRUE, GDK_CURRENT_TIME);
		gdk_pointer_grab(gtk_widget_get_window(popup_window), TRUE,
				 GDK_BUTTON_PRESS_MASK, NULL, NULL, GDK_CURRENT_TIME);
#endif
	} else {
		gtk_widget_hide(popup_window);
	}
}
Beispiel #24
0
static SendProgressDialog *send_progress_dialog_create(void)
{
	SendProgressDialog *dialog;
	ProgressDialog *progress;
	static GdkGeometry geometry;

	dialog = g_new0(SendProgressDialog, 1);

	progress = progress_dialog_create();
	gtk_window_set_title(GTK_WINDOW(progress->window),
			     _("Sending message"));
	g_signal_connect(G_OBJECT(progress->showlog_btn), "clicked",
			 G_CALLBACK(send_showlog_button_cb), dialog);
	g_signal_connect(G_OBJECT(progress->cancel_btn), "clicked",
			 G_CALLBACK(send_cancel_button_cb), dialog);
	g_signal_connect(G_OBJECT(progress->window), "delete_event",
			 G_CALLBACK(gtk_true), NULL);
	gtk_window_set_modal(GTK_WINDOW(progress->window), TRUE);
	g_signal_connect(G_OBJECT(progress->window), "size_allocate",
			 G_CALLBACK(send_progress_dialog_size_allocate_cb), NULL);
	manage_window_set_transient(GTK_WINDOW(progress->window));

	progress_dialog_get_fraction(progress);

	if (!geometry.min_height) {
		geometry.min_width = 460;
		geometry.min_height = 250;
	}

	gtk_window_set_geometry_hints(GTK_WINDOW(progress->window), NULL, &geometry,
				      GDK_HINT_MIN_SIZE);
	gtk_widget_set_size_request(progress->window, prefs_common.sendwin_width,
				    prefs_common.sendwin_height);

	if (!prefs_common.send_dialog_invisible) {
		gtk_widget_show_now(progress->window);
	}
	
	dialog->dialog = progress;

	return dialog;
}
Beispiel #25
0
int main(int argc, char **argv)
{
	gtk_test_init(&argc, &argv);

	hash_init();
	resources_register_resource();
	gui_init();
	list_init();

	// Ignore user input during testing
	gtk_widget_set_sensitive(GTK_WIDGET(gui.window), false);

	if (g_test_slow())
		gtk_widget_show_now(GTK_WIDGET(gui.window));

	callbacks_init();
	test_init();

	return g_test_run();
}
Beispiel #26
0
/**
 * Shows the popup window, and grab the focus.
 *
 * @param window a PopupWindow instance.
 */
void
popup_window_show(PopupWindow *window)
{
	GtkWidget *popup_window = window->popup_window;
	GtkWidget *vol_scale = window->vol_scale;

	/* Update window elements at first */
	update_mute_check(GTK_TOGGLE_BUTTON(window->mute_check),
	                  G_CALLBACK(on_mute_check_toggled), window,
	                  audio_is_muted(window->audio));
	update_volume_slider(window->vol_scale_adj,
	                     audio_get_volume(window->audio));

	/* Show the window */
	gtk_widget_show_now(popup_window);

	/* Give focus to volume scale */
	gtk_widget_grab_focus(vol_scale);

	/* Grab mouse and keyboard */
	grab_devices(popup_window);
}
Beispiel #27
0
static void
test_slider_ranges (void)
{
  GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test: gtk_test_warp_slider");
  GtkWidget *hscale = gtk_hscale_new_with_range (-50, +50, 5);
  gtk_container_add (GTK_CONTAINER (GTK_BIN (window)->child), hscale);
  gtk_widget_show (hscale);
  gtk_widget_show_now (window);
  while (gtk_events_pending ())
    gtk_main_iteration ();
  gtk_test_slider_set_perc (hscale, 0.0);
  while (gtk_events_pending ())
    gtk_main_iteration ();
  g_assert (gtk_test_slider_get_value (hscale) == -50);
  gtk_test_slider_set_perc (hscale, 50.0);
  while (gtk_events_pending ())
    gtk_main_iteration ();
  g_assert (fabs (gtk_test_slider_get_value (hscale)) < 0.0001);
  gtk_test_slider_set_perc (hscale, 100.0);
  while (gtk_events_pending ())
    gtk_main_iteration ();
  g_assert (gtk_test_slider_get_value (hscale) == +50.0);
}
Beispiel #28
0
void gMainWindow::setVisible(bool vl)
{
	if (!vl)
		_hidden = true;

	if (vl == isVisible())
		return;

	if (vl)
	{
		bool arr = !isVisible();
	
		emitOpen();
		if (!opened)
			return;
		
		_not_spontaneous = !visible;
		visible = true;
		_hidden = false;
		
		setTransparent(_transparent);

		if (isTopLevel())
		{
			if (!_title || !*_title)
				gtk_window_set_title(GTK_WINDOW(border), gApplication::defaultTitle());
			
			/*if (!_xembed)
			{
				fprintf(stderr, "gtk_window_group_add_window: %p -> %p\n", border, gApplication::currentGroup());
				gtk_window_group_add_window(gApplication::currentGroup(), GTK_WINDOW(border));
				fprintf(stderr, "-> %p\n", gtk_window_get_group(GTK_WINDOW(border)));
			}*/
			
			// Thanks for Ubuntu's GTK+ patching :-(
			#if GTK_CHECK_VERSION(3,0,0)
			gtk_window_set_has_resize_grip(GTK_WINDOW(border), false);
			#else
			if (g_object_class_find_property(G_OBJECT_GET_CLASS(border), "has-resize-grip"))
				g_object_set(G_OBJECT(border), "has-resize-grip", false, (char *)NULL);
			#endif
				
			gtk_window_move(GTK_WINDOW(border), bufX, bufY);
			if (isPopup())
			{
				gtk_widget_show_now(border);
				gtk_widget_grab_focus(border);
			}
			else
				gtk_window_present(GTK_WINDOW(border));

			if (isUtility())
			{
				gMainWindow *parent = _current;
				
				if (!parent && gApplication::mainWindow() && gApplication::mainWindow() != this)
					parent = gApplication::mainWindow();
				
				if (parent)
					gtk_window_set_transient_for(GTK_WINDOW(border), GTK_WINDOW(parent->border));
			}

			if (gApplication::mainWindow() == this)
			{
				int desktop = session_manager_get_desktop();
				if (desktop >= 0)
				{
					//fprintf(stderr, "X11_window_set_desktop: %d (%d)\n", desktop, true);
					X11_window_set_desktop((Window)handle(), true, desktop);
					session_manager_set_desktop(-1);
				}
			}
		}
		else 
		{
			gtk_widget_show(border);
			parent()->performArrange();
		}
		
		drawMask();
		
		if (focus)
		{
			//fprintf(stderr, "focus = %s\n", focus->name());
			focus->setFocus();
			focus = 0;
		}
		
		if (skipTaskBar())
			_activate = true;

		if (arr)
			performArrange();
	}
	else
	{
		if (this == _active)
			focus = gApplication::activeControl();
			
		_not_spontaneous = visible;
		gContainer::setVisible(false);
		
		if (_popup)
			gApplication::exitLoop(this);

		if (gApplication::_button_grab && !gApplication::_button_grab->isReallyVisible())
				gApplication::setButtonGrab(NULL);
	}
}
Beispiel #29
0
GtkWidget *
create_main_window(void)
{
  GtkWidget *notebook1;
  GtkWidget *frame3;
  GtkWidget *frame4;
  GtkWidget *hbox1;
  GtkWidget *vbox1;
  GtkWidget *scrolledwindow1;
  GtkWidget *node_label1;
  GtkWidget *node_label2;
  GtkWidget *node_label3;
  GtkWidget *node_label4;
  GtkWidget *node_label7;
  GtkWidget *node_label8;
  GtkWidget *node_label9;
  GtkWidget *mid_frame;
  GtkWidget *mpr_frame;
  GtkWidget *hna_frame;
  GtkWidget *mid_scrolledwindow;
  GtkWidget *mpr_scrolledwindow;
  GtkWidget *hna_scrolledwindow;
  GtkWidget *Main;
  GtkWidget *label_routes;
  GtkWidget *hbox2;
  GtkWidget *frame2;
  GtkWidget *scrolledwindow4;
  GtkWidget *label17;
  GtkWidget *label18;
  GtkWidget *label19;
  GtkWidget *scrolledwindow3;
  GtkWidget *label13;
  GtkWidget *label14;
  GtkWidget *label15;
  GtkWidget *label16;
  GtkWidget *label_packets;
  //GtkWidget *empty_notebook_page2;
  GtkWidget *label3;
  GtkWidget *net_vbox;
  GtkWidget *pack_vbox;
  GtkWidget *pack_disp_vbox;
  GtkWidget *disp_frame;
  GtkWidget *route_frame;
  GtkWidget *route_stats_frame;
  GtkWidget *route_scrolledwindow;
  GtkWidget *route_label1;
  GtkWidget *route_label2;
  GtkWidget *route_label3;
  GtkWidget *route_label4;
  GtkWidget *route_hbox1;

  GtkWidget *traffic_label;

  GtkWidget *settings_label;
  GtkWidget *settings_hbox1;

  GtkWidget *about_hbox1;
  GtkWidget *about_label;

  GtkWidget *empty1;

  GdkPixmap *unik_logo_gdk;
  GtkWidget *unik_logo;

  /*
   *The main window
   */

  main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_object_set_data(GTK_OBJECT(main_window), "main_window", main_window);
  gtk_window_set_title(GTK_WINDOW(main_window), (olsrd_version));
  gtk_window_set_default_size(GTK_WINDOW(main_window), 600, 550);
  gtk_signal_connect(GTK_OBJECT(main_window), "destroy", GTK_SIGNAL_FUNC(gui_shutdown),
                     //GTK_SIGNAL_FUNC(gtk_main_quit),
                     NULL);
  gtk_window_set_position(GTK_WINDOW(main_window), GTK_WIN_POS_CENTER); /* Position window in center */
  gtk_window_set_policy(GTK_WINDOW(main_window), FALSE, TRUE, TRUE);    /* No user-resizing */

  /*
   *Initialize the pixmaps
   */
  unik_logo_gdk =
    gdk_pixmap_colormap_create_from_xpm_d(NULL, gtk_widget_get_colormap(main_window), &mask, NULL, (gchar **) logo_xpm);

  unik_logo = gtk_pixmap_new(unik_logo_gdk, mask);

  /*
   *The notebook
   */

  notebook1 = gtk_notebook_new();
  gtk_widget_ref(notebook1);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "notebook1", notebook1, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(notebook1);
  gtk_container_add(GTK_CONTAINER(main_window), notebook1);

  /*
   *The first vbox
   */
  vbox1 = gtk_vbox_new(FALSE, 0);
  gtk_widget_ref(vbox1);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "vbox1", vbox1, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(vbox1);
  //gtk_box_pack_start (GTK_BOX (hbox1), vbox1, TRUE, TRUE, 1);
  gtk_container_add(GTK_CONTAINER(notebook1), vbox1);

  /*
   *The nodes frame
   */
  frame3 = gtk_frame_new("Registered nodes:");
  gtk_widget_ref(frame3);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "frame3", frame3, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(frame3);
  gtk_box_pack_start(GTK_BOX(vbox1), frame3, TRUE, TRUE, 0);
  gtk_widget_set_size_request(frame3, -1, 300);
  gtk_container_set_border_width(GTK_CONTAINER(frame3), 1);

  /*
   *The scrolled window to contain the node list
   */

  scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
  gtk_widget_ref(scrolledwindow1);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "scrolledwindow1", scrolledwindow1, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(scrolledwindow1);
  gtk_container_add(GTK_CONTAINER(frame3), scrolledwindow1);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow1), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);

  //gtk_box_pack_start (GTK_BOX (frame3), scrolledwindow1, TRUE, TRUE, 0);
  //gtk_widget_set_usize (scrolledwindow1, -2, 332);

  /*
   *The node list
   */

  node_list = gtk_clist_new(7);
  gtk_widget_ref(node_list);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "node_list", node_list, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(node_list);
  gtk_container_add(GTK_CONTAINER(scrolledwindow1), node_list);
  gtk_clist_set_column_width(GTK_CLIST(node_list), 0, 150);     /* IP */
  //gtk_clist_set_column_justification(GTK_CLIST(node_list), 0, GTK_JUSTIFY_CENTER);
  gtk_clist_set_column_width(GTK_CLIST(node_list), 1, 150);     /* gateway */
  //gtk_clist_set_column_justification(GTK_CLIST(node_list), 1, GTK_JUSTIFY_CENTER);
  gtk_clist_set_column_width(GTK_CLIST(node_list), 2, 50);      /* hopcount */
  gtk_clist_set_column_justification(GTK_CLIST(node_list), 2, GTK_JUSTIFY_CENTER);
  gtk_clist_set_column_width(GTK_CLIST(node_list), 3, 80);      /* dev */
  gtk_clist_set_column_justification(GTK_CLIST(node_list), 3, GTK_JUSTIFY_CENTER);

  gtk_clist_set_column_width(GTK_CLIST(node_list), 4, 70);      /* timer */
  gtk_clist_set_column_justification(GTK_CLIST(node_list), 4, GTK_JUSTIFY_CENTER);
  //gtk_clist_set_column_width (GTK_CLIST (node_list), 7, 100); /* last about */
  //gtk_clist_set_column_justification(GTK_CLIST(node_list), 7, GTK_JUSTIFY_CENTER);

  gtk_clist_set_column_width(GTK_CLIST(node_list), 5, 40);      /* MID */
  gtk_clist_set_column_justification(GTK_CLIST(node_list), 5, GTK_JUSTIFY_CENTER);
  gtk_clist_set_column_width(GTK_CLIST(node_list), 6, 40);      /* HNA */
  gtk_clist_set_column_justification(GTK_CLIST(node_list), 6, GTK_JUSTIFY_CENTER);

  gtk_clist_column_titles_show(GTK_CLIST(node_list));

  /*
   *Row selection callback
   */
  gtk_signal_connect(GTK_OBJECT(node_list), "select_row", GTK_SIGNAL_FUNC(selection_made), NULL);

  /*
   *Column selection callback
   */
  gtk_signal_connect(GTK_OBJECT(node_list), "click_column", GTK_SIGNAL_FUNC(column_clicked_callback), NULL);

  node_label1 = gtk_label_new("Dest");
  gtk_widget_ref(node_label1);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "IP", node_label1, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(node_label1);
  gtk_clist_set_column_widget(GTK_CLIST(node_list), 0, node_label1);

  node_label2 = gtk_label_new("Gateway");
  gtk_widget_ref(node_label2);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "hops", node_label2, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(node_label2);
  gtk_clist_set_column_widget(GTK_CLIST(node_list), 1, node_label2);

  node_label3 = gtk_label_new("Metric");
  gtk_widget_ref(node_label3);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "info", node_label3, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(node_label3);
  gtk_clist_set_column_widget(GTK_CLIST(node_list), 2, node_label3);

  node_label4 = gtk_label_new("Device");
  gtk_widget_ref(node_label4);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "Device", node_label4, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(node_label4);
  gtk_clist_set_column_widget(GTK_CLIST(node_list), 3, node_label4);

  node_label7 = gtk_label_new("Timer");
  gtk_widget_ref(node_label7);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "LMF", node_label7, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(node_label7);
  gtk_clist_set_column_widget(GTK_CLIST(node_list), 4, node_label7);

  /*
     node_label8 = gtk_label_new ("LMA");
     gtk_widget_ref (node_label8);
     gtk_object_set_data_full (GTK_OBJECT (main_window), "LMA", node_label8,
     (GtkDestroyNotify) gtk_widget_unref);
     gtk_widget_show (node_label8);
     gtk_clist_set_column_widget (GTK_CLIST (node_list), 7, node_label8);
   */

  node_label8 = gtk_label_new("MID");
  gtk_widget_ref(node_label8);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "MID", node_label8, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(node_label8);
  gtk_clist_set_column_widget(GTK_CLIST(node_list), 5, node_label8);

  node_label9 = gtk_label_new("HNA");
  gtk_widget_ref(node_label9);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "HNA", node_label9, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(node_label9);
  gtk_clist_set_column_widget(GTK_CLIST(node_list), 6, node_label9);

  gtk_clist_column_titles_active(GTK_CLIST(node_list));

  gtk_widget_show_now(node_list);

  /*
   *Row selection callback
   */
  gtk_signal_connect(GTK_OBJECT(node_list), "select_row", GTK_SIGNAL_FUNC(node_selection), NULL);

  /*
   *The first hbox
   */
  hbox1 = gtk_hbox_new(FALSE, 0);
  gtk_widget_ref(hbox1);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "hbox1", hbox1, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(hbox1);
  gtk_box_pack_start(GTK_BOX(vbox1), hbox1, FALSE, FALSE, 0);
  //gtk_container_add (GTK_CONTAINER (notebook1), hbox1);
  gtk_container_set_border_width(GTK_CONTAINER(hbox1), 4);
  gtk_widget_set_size_request(hbox1, -1, 200);

  /*
   *The net-info frame
   */
  frame4 = gtk_frame_new("Info:");
  gtk_widget_ref(frame4);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "frame4", frame4, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(frame4);
  gtk_box_pack_start(GTK_BOX(hbox1), frame4, TRUE, TRUE, 0);
  //gtk_widget_set_size_request(frame4, 200, -1);
  gtk_container_set_border_width(GTK_CONTAINER(frame4), 1);

  /*
   *The net-info hbox
   */
  net_vbox = gtk_vbox_new(FALSE, 0);
  gtk_widget_ref(net_vbox);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "net_vbox", net_vbox, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(net_vbox);
  gtk_container_add(GTK_CONTAINER(frame4), net_vbox);

  /*
   *The net-info label field
   */
  net_label = gtk_label_new(NULL);
  gtk_widget_ref(net_label);
  gtk_misc_set_alignment((GtkMisc *) net_label, 0, 0);
  //gtk_label_set_justify((GtkLabel *)net_label,GTK_JUSTIFY_LEFT);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "net_label", net_label, (GtkDestroyNotify) gtk_widget_unref);

  //set_net_info("Not connected...");
  gtk_widget_show(net_label);
  gtk_box_pack_start(GTK_BOX(net_vbox), net_label, TRUE, TRUE, 0);

  //gtk_container_add (GTK_CONTAINER (frame4), net_label);

  /*
   *The connect button
   */

  connect_button = gtk_button_new_with_label("Connect to host");
  gtk_widget_ref(connect_button);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "connect_button", connect_button, (GtkDestroyNotify) gtk_widget_unref);
  /* Connect the "clicked" signal of the button to our callback */
  gtk_signal_connect(GTK_OBJECT(connect_button), "clicked", GTK_SIGNAL_FUNC(connect_callback), NULL);
  gtk_widget_show(connect_button);
  gtk_box_pack_start(GTK_BOX(net_vbox), connect_button, FALSE, FALSE, 1);
  gtk_container_set_border_width(GTK_CONTAINER(connect_button), 5);

  /*
   *The node MPR info frame
   */
  mpr_frame = gtk_frame_new("MPR:");
  gtk_widget_ref(mpr_frame);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "mpr_frame", mpr_frame, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(mpr_frame);
  gtk_box_pack_start(GTK_BOX(hbox1), mpr_frame, FALSE, FALSE, 0);
  //gtk_widget_set_size_request(mid_frame, 125, -1);
  gtk_container_set_border_width(GTK_CONTAINER(mpr_frame), 1);

  /*
   *The scrolledwindow to contain the MPR node info
   */
  mpr_scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
  gtk_widget_ref(mpr_scrolledwindow);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "mpr_scrolledwindow", mpr_scrolledwindow, (GtkDestroyNotify) gtk_widget_unref);

  gtk_widget_show(mpr_scrolledwindow);
  gtk_container_add(GTK_CONTAINER(mpr_frame), mpr_scrolledwindow);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(mpr_scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_container_set_border_width(GTK_CONTAINER(mpr_scrolledwindow), 3);

  /*
   *The node MID info frame
   */
  mid_frame = gtk_frame_new("MID:");
  gtk_widget_ref(mid_frame);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "mid_frame", mid_frame, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(mid_frame);
  gtk_box_pack_start(GTK_BOX(hbox1), mid_frame, FALSE, FALSE, 0);
  //gtk_widget_set_size_request(mid_frame, 125, -1);
  gtk_container_set_border_width(GTK_CONTAINER(mid_frame), 1);

  /*
   *The scrolledwindow to contain the MID node info
   */
  mid_scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
  gtk_widget_ref(mid_scrolledwindow);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "mid_scrolledwindow", mid_scrolledwindow, (GtkDestroyNotify) gtk_widget_unref);

  gtk_widget_show(mid_scrolledwindow);
  gtk_container_add(GTK_CONTAINER(mid_frame), mid_scrolledwindow);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(mid_scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_container_set_border_width(GTK_CONTAINER(mid_scrolledwindow), 3);

  /*
   *The MPR list
   */
  mpr_list = gtk_clist_new(1);
  gtk_widget_ref(mpr_list);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "mpr_list", mpr_list, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(mpr_list);
  gtk_container_add(GTK_CONTAINER(mpr_scrolledwindow), mpr_list);
  gtk_clist_set_column_width(GTK_CLIST(mpr_list), 0, 120);      /* IP */
  gtk_clist_column_titles_hide(GTK_CLIST(mpr_list));

  /*
   *The MID list
   */
  mid_list = gtk_clist_new(1);
  gtk_widget_ref(mid_list);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "mid_list", mid_list, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(mid_list);
  gtk_container_add(GTK_CONTAINER(mid_scrolledwindow), mid_list);
  gtk_clist_set_column_width(GTK_CLIST(mid_list), 0, 120);      /* IP */
  gtk_clist_column_titles_hide(GTK_CLIST(mid_list));

  /*
   *The node HNA info frame
   */
  hna_frame = gtk_frame_new("HNA:");
  gtk_widget_ref(hna_frame);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "hna_frame", hna_frame, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(hna_frame);
  gtk_box_pack_start(GTK_BOX(hbox1), hna_frame, FALSE, FALSE, 0);
  //gtk_widget_set_size_request(mid_frame, 125, -1);
  gtk_container_set_border_width(GTK_CONTAINER(hna_frame), 1);

  /*
   *The HNA scrolled window
   */
  hna_scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
  gtk_widget_ref(hna_scrolledwindow);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "hna_scrolledwindow", hna_scrolledwindow, (GtkDestroyNotify) gtk_widget_unref);

  gtk_widget_show(hna_scrolledwindow);
  gtk_container_add(GTK_CONTAINER(hna_frame), hna_scrolledwindow);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(hna_scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_container_set_border_width(GTK_CONTAINER(hna_scrolledwindow), 3);

  /*
   *The HNA list
   */
  hna_list = gtk_clist_new(1);
  gtk_widget_ref(hna_list);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "hna_list", hna_list, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(hna_list);
  gtk_container_add(GTK_CONTAINER(hna_scrolledwindow), hna_list);
  gtk_clist_set_column_width(GTK_CLIST(hna_list), 0, 120);      /* IP */
  gtk_clist_column_titles_hide(GTK_CLIST(hna_list));

  /*
   *The "main" notebook page
   */
  Main = gtk_label_new("Main");
  gtk_widget_ref(Main);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "Main", Main, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(Main);
  gtk_notebook_set_tab_label(GTK_NOTEBOOK(notebook1), gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook1), 0), Main);

  /*
   *The main hbox of the Packet page
   */

  hbox2 = gtk_hbox_new(FALSE, 0);
  gtk_widget_ref(hbox2);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "hbox2", hbox2, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(hbox2);
  gtk_container_add(GTK_CONTAINER(notebook1), hbox2);

  /*
   *The packet hbox
   */
  pack_vbox = gtk_vbox_new(FALSE, 0);
  gtk_widget_ref(pack_vbox);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "pack_vbox", pack_vbox, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(pack_vbox);
  gtk_box_pack_start(GTK_BOX(hbox2), pack_vbox, TRUE, TRUE, 0);

  /*
   *The packet frame
   */

  frame2 = gtk_frame_new("Packet");
  gtk_widget_ref(frame2);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "frame2", frame2, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(frame2);
  gtk_box_pack_start(GTK_BOX(pack_vbox), frame2, TRUE, TRUE, 0);        /* Do not expand */

  /*
   *Packet list scrolled window
   */
  scrolledwindow4 = gtk_scrolled_window_new(NULL, NULL);
  gtk_widget_ref(scrolledwindow4);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "scrolledwindow4", scrolledwindow4, (GtkDestroyNotify) gtk_widget_unref);

  gtk_widget_show(scrolledwindow4);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow4), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);

  gtk_container_add(GTK_CONTAINER(frame2), scrolledwindow4);

  /*
   *The packet list
   */

  packet_list = gtk_clist_new(3);
  gtk_widget_ref(packet_list);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "packet_list", packet_list, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(packet_list);
  gtk_container_add(GTK_CONTAINER(scrolledwindow4), packet_list);
  gtk_clist_set_column_width(GTK_CLIST(packet_list), 0, 80);    /* Type */
  gtk_clist_set_column_width(GTK_CLIST(packet_list), 1, 150);   /* Origin IP */
  gtk_clist_set_column_width(GTK_CLIST(packet_list), 2, 20);    /* size */
  gtk_clist_column_titles_show(GTK_CLIST(packet_list));

  label17 = gtk_label_new("Type");
  gtk_widget_ref(label17);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "label17", label17, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(label17);
  gtk_clist_set_column_widget(GTK_CLIST(packet_list), 0, label17);

  label18 = gtk_label_new("Origin");
  gtk_widget_ref(label18);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "label18", label18, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(label18);
  gtk_clist_set_column_widget(GTK_CLIST(packet_list), 1, label18);

  label19 = gtk_label_new("Size");
  gtk_widget_ref(label19);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "label19", label19, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(label19);
  gtk_clist_set_column_widget(GTK_CLIST(packet_list), 2, label19);

  /*
   *Row selection callback
   */
  gtk_signal_connect(GTK_OBJECT(packet_list), "select_row", GTK_SIGNAL_FUNC(packet_selection), NULL);

  /*
   *The packet button
   */

  packet_button = gtk_button_new_with_label("Grab packets");
  gtk_widget_ref(packet_button);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "packet_button", packet_button, (GtkDestroyNotify) gtk_widget_unref);

  /* Connect the "clicked" signal of the button to our callback */
  gtk_signal_connect(GTK_OBJECT(packet_button), "clicked", GTK_SIGNAL_FUNC(packet_callback), NULL);
  gtk_widget_show(packet_button);
  gtk_box_pack_start(GTK_BOX(pack_vbox), packet_button, FALSE, FALSE, 5);

  /*
   *The packet disp hbox
   */
  pack_disp_vbox = gtk_vbox_new(FALSE, 0);
  gtk_widget_ref(pack_disp_vbox);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "pack_disp_vbox", pack_disp_vbox, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(pack_disp_vbox);
  gtk_box_pack_start(GTK_BOX(hbox2), pack_disp_vbox, TRUE, TRUE, 0);

  /*
   *The packet disp frame
   */

  disp_frame = gtk_frame_new("Packet content");
  gtk_widget_ref(disp_frame);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "disp_frame", disp_frame, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(disp_frame);
  gtk_box_pack_start(GTK_BOX(pack_disp_vbox), disp_frame, TRUE, TRUE, 0);       /* Do not expand */

  /*
   *Scrolled window for the packet display
   *list
   */

  scrolledwindow3 = gtk_scrolled_window_new(NULL, NULL);
  gtk_widget_ref(scrolledwindow3);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "scrolledwindow3", scrolledwindow3, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(scrolledwindow3);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow3), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);

  gtk_container_add(GTK_CONTAINER(disp_frame), scrolledwindow3);

  //gtk_box_pack_start (GTK_BOX (disp_frame), scrolledwindow3, TRUE, TRUE, 0);

  /*
   *The packet display list
   */
  packet_content_list = gtk_clist_new(4);
  gtk_widget_ref(packet_content_list);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "packet_content_list", packet_content_list,
                           (GtkDestroyNotify) gtk_widget_unref);

  gtk_widget_show(packet_content_list);
  gtk_container_add(GTK_CONTAINER(scrolledwindow3), packet_content_list);
  gtk_clist_set_column_width(GTK_CLIST(packet_content_list), 0, 70);    /* 0-7 */
  gtk_clist_set_column_justification(GTK_CLIST(packet_content_list), 0, GTK_JUSTIFY_CENTER);
  gtk_clist_set_column_width(GTK_CLIST(packet_content_list), 1, 70);    /* 8-15 */
  gtk_clist_set_column_justification(GTK_CLIST(packet_content_list), 1, GTK_JUSTIFY_CENTER);
  gtk_clist_set_column_width(GTK_CLIST(packet_content_list), 2, 70);    /* 16-23 */
  gtk_clist_set_column_justification(GTK_CLIST(packet_content_list), 2, GTK_JUSTIFY_CENTER);
  gtk_clist_set_column_width(GTK_CLIST(packet_content_list), 3, 70);    /* 24-31 */
  gtk_clist_set_column_justification(GTK_CLIST(packet_content_list), 3, GTK_JUSTIFY_CENTER);
  gtk_clist_column_titles_show(GTK_CLIST(packet_content_list));

  label13 = gtk_label_new("0 - 7");
  gtk_widget_ref(label13);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "label13", label13, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(label13);
  gtk_clist_set_column_widget(GTK_CLIST(packet_content_list), 0, label13);

  label14 = gtk_label_new("8 - 15");
  gtk_widget_ref(label14);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "label14", label14, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(label14);
  gtk_clist_set_column_widget(GTK_CLIST(packet_content_list), 1, label14);

  label15 = gtk_label_new("16 - 23");
  gtk_widget_ref(label15);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "label15", label15, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(label15);
  gtk_clist_set_column_widget(GTK_CLIST(packet_content_list), 2, label15);

  label16 = gtk_label_new("24 - 31");
  gtk_widget_ref(label16);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "label16", label16, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(label16);
  gtk_clist_set_column_widget(GTK_CLIST(packet_content_list), 3, label16);

  //gtk_clist_set_selection_mode(GTK_CLIST (packet_content_list), GTK_SELECTION_NONE); /* no selections */

  /*
   *The packet button
   */

  packet_disp_button = gtk_button_new_with_label("Display hex");
  gtk_widget_ref(packet_disp_button);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "packet_disp_button", packet_disp_button, (GtkDestroyNotify) gtk_widget_unref);

  /* Connect the "clicked" signal of the button to our callback */
  gtk_signal_connect(GTK_OBJECT(packet_disp_button), "clicked", GTK_SIGNAL_FUNC(packet_disp_callback), NULL);
  gtk_widget_show(packet_disp_button);
  gtk_box_pack_start(GTK_BOX(pack_disp_vbox), packet_disp_button, FALSE, FALSE, 5);

  /*
   *The "packets" notebook
   */

  label_packets = gtk_label_new("Packets");
  gtk_widget_ref(label_packets);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "label_packets", label_packets, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(label_packets);
  gtk_notebook_set_tab_label(GTK_NOTEBOOK(notebook1), gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook1), 1), label_packets);

  /*
   *The route hbox
   */
  route_hbox1 = gtk_hbox_new(FALSE, 0);
  gtk_widget_ref(route_hbox1);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "route_hbox1", route_hbox1, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(route_hbox1);
  //gtk_box_pack_start (GTK_BOX (hbox1), vbox1, TRUE, TRUE, 1);
  gtk_container_add(GTK_CONTAINER(notebook1), route_hbox1);

  /*
   *The routes frame
   */

  route_frame = gtk_frame_new("OLSR routes in kernel:");
  gtk_widget_ref(route_frame);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "route_frame", route_frame, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(route_frame);

  //gtk_container_add (GTK_CONTAINER (notebook1), route_frame);
  gtk_widget_set_size_request(route_frame, 200, -1);
  gtk_box_pack_start(GTK_BOX(route_hbox1), route_frame, TRUE, TRUE, 0); /* Do not expand */

  /*
   *Scrolled window for the packet display
   *list
   */

  route_scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
  gtk_widget_ref(route_scrolledwindow);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "route_scrolledwindow", route_scrolledwindow,
                           (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(route_scrolledwindow);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(route_scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);

  gtk_container_add(GTK_CONTAINER(route_frame), route_scrolledwindow);

  //gtk_box_pack_start (GTK_BOX (route_frame), scrolledwindow3, TRUE, TRUE, 0);

  /*
   *The routes display list
   */
  route_list = gtk_clist_new(4);
  gtk_widget_ref(route_list);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "route_list", route_list, (GtkDestroyNotify) gtk_widget_unref);

  gtk_widget_show(route_list);
  gtk_container_add(GTK_CONTAINER(route_scrolledwindow), route_list);
  gtk_clist_set_column_width(GTK_CLIST(route_list), 0, 120);    /* dest */
  //gtk_clist_set_column_justification(GTK_CLIST (route_list), 0, GTK_JUSTIFY_CENTER);
  gtk_clist_set_column_width(GTK_CLIST(route_list), 1, 120);    /* gw */
  //gtk_clist_set_column_justification(GTK_CLIST (route_list), 1, GTK_JUSTIFY_CENTER);
  gtk_clist_set_column_width(GTK_CLIST(route_list), 2, 50);     /* weight */
  gtk_clist_set_column_justification(GTK_CLIST(route_list), 2, GTK_JUSTIFY_CENTER);
  gtk_clist_set_column_width(GTK_CLIST(route_list), 3, 70);     /* interface */
  gtk_clist_set_column_justification(GTK_CLIST(route_list), 3, GTK_JUSTIFY_CENTER);
  gtk_clist_column_titles_show(GTK_CLIST(route_list));

  route_label1 = gtk_label_new("Destination");
  gtk_widget_ref(route_label1);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "route_label1", route_label1, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(route_label1);
  gtk_clist_set_column_widget(GTK_CLIST(route_list), 0, route_label1);

  route_label2 = gtk_label_new("Gateway");
  gtk_widget_ref(route_label2);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "route_label2", route_label2, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(route_label2);
  gtk_clist_set_column_widget(GTK_CLIST(route_list), 1, route_label2);

  route_label3 = gtk_label_new("Weight");
  gtk_widget_ref(route_label3);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "route_label3", route_label3, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(route_label3);
  gtk_clist_set_column_widget(GTK_CLIST(route_list), 2, route_label3);

  route_label4 = gtk_label_new("Interface");
  gtk_widget_ref(route_label4);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "route_label4", route_label4, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(route_label4);
  gtk_clist_set_column_widget(GTK_CLIST(route_list), 3, route_label4);

  //gtk_clist_set_selection_mode(GTK_CLIST (route_list), GTK_SELECTION_NONE); /* no selections */

  /*
   *The routes stats frame
   */

  route_stats_frame = gtk_frame_new("Stats:");
  gtk_widget_ref(route_stats_frame);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "route_stats_frame", route_stats_frame, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(route_stats_frame);

  //gtk_container_add (GTK_CONTAINER (notebook1), route_frame);
  gtk_box_pack_start(GTK_BOX(route_hbox1), route_stats_frame, TRUE, TRUE, 1);

  /*
   *The "routes" notebook
   */
  label_routes = gtk_label_new("Routes");
  gtk_widget_ref(label_routes);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "label_routes", label_routes, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(label_routes);
  gtk_notebook_set_tab_label(GTK_NOTEBOOK(notebook1), gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook1), 2), label_routes);

  empty1 = gtk_vbox_new(FALSE, 0);
  gtk_widget_show(empty1);
  gtk_container_add(GTK_CONTAINER(notebook1), empty1);

  /*
   *The "traffic" notebook
   */
  traffic_label = gtk_label_new("Traffic");
  gtk_widget_ref(traffic_label);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "traffic_label", traffic_label, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(traffic_label);
  gtk_notebook_set_tab_label(GTK_NOTEBOOK(notebook1), gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook1), 3), traffic_label);

  /*
   *The settings hbox
   */
  settings_hbox1 = gtk_hbox_new(FALSE, 0);
  gtk_widget_ref(settings_hbox1);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "settings_hbox1", settings_hbox1, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(settings_hbox1);
  //gtk_box_pack_start (GTK_BOX (hbox1), vbox1, TRUE, TRUE, 1);
  gtk_container_add(GTK_CONTAINER(notebook1), settings_hbox1);

  /*
   *The settings-info label field
   */
  info_label = gtk_label_new(NULL);
  gtk_widget_ref(info_label);
  gtk_misc_set_alignment((GtkMisc *) info_label, 0, 0);
  //gtk_label_set_justify((GtkLabel *)net_label,GTK_JUSTIFY_LEFT);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "info_label", info_label, (GtkDestroyNotify) gtk_widget_unref);

  //set_net_info("Not connected...");
  gtk_widget_show(info_label);
  gtk_box_pack_start(GTK_BOX(settings_hbox1), info_label, TRUE, TRUE, 0);

  /*
   *The "settings" notebook
   */
  settings_label = gtk_label_new("Settings");
  gtk_widget_ref(settings_label);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "settings_label", settings_label, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(settings_label);
  gtk_notebook_set_tab_label(GTK_NOTEBOOK(notebook1), gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook1), 4), settings_label);

  /*
   *The "about" hbox
   */
  about_hbox1 = gtk_hbox_new(FALSE, 0);
  gtk_widget_ref(about_hbox1);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "about_hbox1", about_hbox1, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(about_hbox1);
  //gtk_box_pack_start (GTK_BOX (hbox1), vbox1, TRUE, TRUE, 1);
  gtk_container_add(GTK_CONTAINER(notebook1), about_hbox1);
  gtk_container_set_border_width(GTK_CONTAINER(about_hbox1), 10);

  /*
   *The about label field
   */
  about_label = gtk_label_new(NULL);
  gtk_widget_ref(about_label);
  gtk_misc_set_alignment((GtkMisc *) about_label, 0, 0);
  gtk_label_set_justify((GtkLabel *) about_label, GTK_JUSTIFY_CENTER);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "about_label", about_label, (GtkDestroyNotify) gtk_widget_unref);

  //set_net_info("Not connected...");
  gtk_widget_show(about_label);
  gtk_box_pack_start(GTK_BOX(about_hbox1), unik_logo, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(about_hbox1), about_label, TRUE, TRUE, 0);
  gtk_widget_show(unik_logo);

  gtk_label_set_text((GtkLabel *) about_label, "OLSRD-GUI by Andreas Tonnesen ([email protected])");

  /*
   *The "about" notebook
   */
  label3 = gtk_label_new("About");
  gtk_widget_ref(label3);
  gtk_object_set_data_full(GTK_OBJECT(main_window), "About", label3, (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show(label3);
  gtk_notebook_set_tab_label(GTK_NOTEBOOK(notebook1), gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook1), 5), label3);

  return main_window;

}
static int
passphrase_dialog(char *message)
{
	const char *failed;
	char *passphrase, *local;
	int result, grab_tries, grab_server, grab_pointer;
	GtkWidget *dialog, *entry;
	GdkGrabStatus status;

	grab_server = (getenv("GNOME_SSH_ASKPASS_GRAB_SERVER") != NULL);
	grab_pointer = (getenv("GNOME_SSH_ASKPASS_GRAB_POINTER") != NULL);
	grab_tries = 0;

	dialog = gtk_message_dialog_new(NULL, 0,
					GTK_MESSAGE_QUESTION,
					GTK_BUTTONS_OK_CANCEL,
					"%s",
					message);

	entry = gtk_entry_new();
	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), entry, FALSE,
	    FALSE, 0);
	gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
	gtk_widget_grab_focus(entry);
	gtk_widget_show(entry);

	gtk_window_set_title(GTK_WINDOW(dialog), "OpenSSH");
	gtk_window_set_position (GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
	gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
	gtk_label_set_line_wrap(GTK_LABEL((GTK_MESSAGE_DIALOG(dialog))->label),
				TRUE);

	/* Make <enter> close dialog */
	gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
	g_signal_connect(G_OBJECT(entry), "activate",
			 G_CALLBACK(ok_dialog), dialog);

	/* Grab focus */
	gtk_widget_show_now(dialog);
	if (grab_pointer) {
		for(;;) {
			status = gdk_pointer_grab(
			   (GTK_WIDGET(dialog))->window, TRUE, 0, NULL,
			   NULL, GDK_CURRENT_TIME);
			if (status == GDK_GRAB_SUCCESS)
				break;
			usleep(GRAB_WAIT * 1000);
			if (++grab_tries > GRAB_TRIES) {
				failed = "mouse";
				goto nograb;
			}
		}
	}
	for(;;) {
		status = gdk_keyboard_grab((GTK_WIDGET(dialog))->window,
		   FALSE, GDK_CURRENT_TIME);
		if (status == GDK_GRAB_SUCCESS)
			break;
		usleep(GRAB_WAIT * 1000);
		if (++grab_tries > GRAB_TRIES) {
			failed = "keyboard";
			goto nograbkb;
		}
	}
	if (grab_server) {
		gdk_x11_grab_server();
	}

	result = gtk_dialog_run(GTK_DIALOG(dialog));

	/* Ungrab */
	if (grab_server)
		XUngrabServer(GDK_DISPLAY());
	if (grab_pointer)
		gdk_pointer_ungrab(GDK_CURRENT_TIME);
	gdk_keyboard_ungrab(GDK_CURRENT_TIME);
	gdk_flush();

	/* Report passphrase if user selected OK */
	passphrase = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
	if (result == GTK_RESPONSE_OK) {
		local = g_locale_from_utf8(passphrase, strlen(passphrase),
					   NULL, NULL, NULL);
		if (local != NULL) {
			puts(local);
			memset(local, '\0', strlen(local));
			g_free(local);
		} else {
			puts(passphrase);
		}
	}
		
	/* Zero passphrase in memory */
	memset(passphrase, '\b', strlen(passphrase));
	gtk_entry_set_text(GTK_ENTRY(entry), passphrase);
	memset(passphrase, '\0', strlen(passphrase));
	g_free(passphrase);
			
	gtk_widget_destroy(dialog);
	return (result == GTK_RESPONSE_OK ? 0 : -1);

	/* At least one grab failed - ungrab what we got, and report
	   the failure to the user.  Note that XGrabServer() cannot
	   fail.  */
 nograbkb:
	gdk_pointer_ungrab(GDK_CURRENT_TIME);
 nograb:
	if (grab_server)
		XUngrabServer(GDK_DISPLAY());
	gtk_widget_destroy(dialog);
	
	report_failed_grab(failed);

	return (-1);
}