Ejemplo n.º 1
0
void
on_page_switch (GtkNotebook     * notebook,
		gpointer          page,
		guint             page_num,
		gpointer          data)
{
	Netinfo *netinfo;
	char *title;

	netinfo = get_netinfo_for_page (notebook, page_num);
	if (!netinfo)
		return;

	if (netinfo->running) {
		netinfo_progress_indicator_start (netinfo);
		if (netinfo->stbar_text) {
			gtk_statusbar_pop (GTK_STATUSBAR (netinfo->status_bar), 0);
			gtk_statusbar_push (GTK_STATUSBAR (netinfo->status_bar),
					    0, netinfo->stbar_text);
		}
	} else {
		netinfo_progress_indicator_stop (netinfo);
		gtk_statusbar_pop (GTK_STATUSBAR (netinfo->status_bar), 0);
		gtk_statusbar_push (GTK_STATUSBAR (netinfo->status_bar),
					    0, _("Idle"));
	}

	/* Dear Translator: This is the Window Title. 'Network Tools' is the
	 * name of the application */
	title = g_strdup_printf (_("%s - Network Tools"),
				 gtk_label_get_text (GTK_LABEL (netinfo->page_label)));
	gtk_window_set_title (GTK_WINDOW (netinfo->main_window), title);
	g_free (title);
}
Ejemplo n.º 2
0
/* Widget behaviour */
void
netinfo_toggle_state (Netinfo * netinfo, gboolean state,
		      gpointer user_data)
{
	GdkCursor *cursor;
	PangoFontDescription *font_desc;

	g_assert (netinfo != NULL);
	g_return_if_fail (netinfo != NULL);

	if (! netinfo->toggle) {
		netinfo->running = !state;
		return;
	}

	if (GTK_IS_WIDGET (netinfo->sensitive)) {
		gtk_widget_set_sensitive (GTK_WIDGET (netinfo->sensitive),
					  state);
	}

	font_desc = pango_font_description_new ();

	if (state) {
		pango_font_description_set_weight (font_desc,
						   PANGO_WEIGHT_NORMAL);

		netinfo_progress_indicator_stop (netinfo);
		gdk_window_set_cursor (gtk_widget_get_window(netinfo->output), NULL);
		netinfo->child_pid = 0;
		
		gtk_statusbar_pop (GTK_STATUSBAR (netinfo->status_bar), 0);
		gtk_statusbar_push (GTK_STATUSBAR (netinfo->status_bar),
					    0, _("Idle"));
	} else {
		pango_font_description_set_weight (font_desc,
						   PANGO_WEIGHT_BOLD);

		netinfo_progress_indicator_start (netinfo);
		cursor = gdk_cursor_new (GDK_WATCH);
		if (!gtk_widget_get_realized (netinfo->output))
			gtk_widget_realize (GTK_WIDGET (netinfo->output));
		gdk_window_set_cursor (gtk_widget_get_window(netinfo->output), cursor);
		gdk_cursor_unref (cursor);

		if (netinfo->stbar_text) {
			gtk_statusbar_pop (GTK_STATUSBAR (netinfo->status_bar), 0);
			gtk_statusbar_push (GTK_STATUSBAR (netinfo->status_bar),
					    0, netinfo->stbar_text);
		}
	}

	gtk_widget_modify_font (netinfo->page_label, font_desc);
	pango_font_description_free (font_desc);

	netinfo->running = !state;

	netinfo_toggle_button (netinfo);
}
Ejemplo n.º 3
0
void
netinfo_progress_indicator_start (Netinfo * netinfo)
{
	g_return_if_fail (netinfo != NULL);

	if (progress_timeout_id != 0)
		netinfo_progress_indicator_stop (netinfo);

	progress_timeout_id = g_timeout_add (100, update_progress_bar,
					     netinfo->progress_bar);
}
Ejemplo n.º 4
0
gboolean
gn_quit_app (GtkWidget * widget, gpointer data)
{
	gint status, pid;

	pid = getpid () + 1;
	while (waitpid (-1, &status, WNOHANG) == 0) {
		if (waitpid (pid, &status, WNOHANG) == 0)
			kill (pid, SIGKILL);
		pid ++;
	}

	netinfo_progress_indicator_stop (NULL);

	gtk_main_quit ();

	return TRUE;
}