void
panel_properties_dialog_present (PanelToplevel *toplevel)
{
	PanelPropertiesDialog *dialog;
	GtkBuilder            *gui;
	GError                *error;

	if (!panel_properties_dialog_quark)
		panel_properties_dialog_quark =
			g_quark_from_static_string ("panel-properties-dialog");

	dialog = g_object_get_qdata (G_OBJECT (toplevel), panel_properties_dialog_quark);
	if (dialog) {
		gtk_window_set_screen (GTK_WINDOW (dialog->properties_dialog),
				       gtk_window_get_screen (GTK_WINDOW (toplevel)));
		gtk_window_present (GTK_WINDOW (dialog->properties_dialog));
		return;
	}

	gui = gtk_builder_new ();
	gtk_builder_set_translation_domain (gui, GETTEXT_PACKAGE);

	error = NULL;
	gtk_builder_add_from_file (gui,
				   BUILDERDIR "/panel-properties-dialog.ui",
				   &error);

        if (error) {
		char *secondary;

		secondary = g_strdup_printf (_("Unable to load file '%s': %s."),
					     BUILDERDIR"/panel-properties-dialog.ui",
					     error->message);
		panel_error_dialog (GTK_WINDOW (toplevel),
				    gtk_window_get_screen (GTK_WINDOW (toplevel)),
				    "cannot_display_properties_dialog", TRUE,
				    _("Could not display properties dialog"),
				    secondary);
		g_free (secondary);
		g_error_free (error);
		g_object_unref (gui);

		return;
	}

	dialog = panel_properties_dialog_new (toplevel, gui);

	g_object_unref (gui);
}
Beispiel #2
0
static void
action_nemo_manual_callback (GtkAction *action, 
				 gpointer user_data)
{
	NemoWindow *window;
	GError *error;
	GtkWidget *dialog;
	const char* helpuri;
	const char* name = gtk_action_get_name (action);

	error = NULL;
	window = NEMO_WINDOW (user_data);

	if (g_str_equal (name, "NemoHelpSearch")) {
		helpuri = "help:gnome-help/files-search";
	} else if (g_str_equal (name,"NemoHelpSort")) {
		helpuri = "help:gnome-help/files-sort";
	} else if (g_str_equal (name, "NemoHelpLost")) {
		helpuri = "help:gnome-help/files-lost";
	} else if (g_str_equal (name, "NemoHelpShare")) {
		helpuri = "help:gnome-help/files-share";
	} else {
		helpuri = "help:gnome-help/files";
	}

	if (NEMO_IS_DESKTOP_WINDOW (window)) {
		nemo_launch_application_from_command (gtk_window_get_screen (GTK_WINDOW (window)), "gnome-help", FALSE, NULL);
	} else {
		gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (window)),
			      helpuri,
			      gtk_get_current_event_time (), &error);
	}

	if (error) {
		dialog = gtk_message_dialog_new (GTK_WINDOW (window),
						 GTK_DIALOG_MODAL,
						 GTK_MESSAGE_ERROR,
						 GTK_BUTTONS_OK,
						 _("There was an error displaying help: \n%s"),
						 error->message);
		g_signal_connect (G_OBJECT (dialog), "response",
				  G_CALLBACK (gtk_widget_destroy),
				  NULL);

		gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
		gtk_widget_show (dialog);
		g_error_free (error);
	}
}
static PanelPropertiesDialog *
panel_properties_dialog_new (PanelToplevel *toplevel,
			     GtkBuilder    *gui)
{
	PanelPropertiesDialog *dialog;
	char                  *toplevel_settings_path;

	dialog = g_new0 (PanelPropertiesDialog, 1);

	g_object_set_qdata_full (G_OBJECT (toplevel),
				 panel_properties_dialog_quark,
				 dialog,
				 (GDestroyNotify) panel_properties_dialog_free);

	dialog->toplevel = toplevel;

	g_object_get (toplevel, "settings-path", &toplevel_settings_path, NULL);
	dialog->settings = g_settings_new_with_path (PANEL_TOPLEVEL_SCHEMA,
						     toplevel_settings_path);
	dialog->settings_background = g_settings_get_child (dialog->settings,
							    PANEL_BACKGROUND_SCHEMA_CHILD);

	g_free (toplevel_settings_path);

	dialog->properties_dialog = PANEL_GTK_BUILDER_GET (gui, "panel_properties_dialog");
	g_signal_connect_swapped (dialog->properties_dialog, "response",
				  G_CALLBACK (panel_properties_dialog_response), dialog);
	g_signal_connect_swapped (dialog->properties_dialog, "destroy",
				  G_CALLBACK (panel_properties_dialog_destroy), dialog);

	gtk_window_set_screen (GTK_WINDOW (dialog->properties_dialog),
			       gtk_window_get_screen (GTK_WINDOW (toplevel)));

	dialog->writability_warn_general = PANEL_GTK_BUILDER_GET (gui, "writability_warn_general");
	dialog->writability_warn_background = PANEL_GTK_BUILDER_GET (gui, "writability_warn_background");

	panel_properties_dialog_setup_orientation_combo  (dialog, gui);
	panel_properties_dialog_size_spin_setup          (dialog, gui);
	panel_properties_dialog_expand_toggle_setup      (dialog, gui);
	panel_properties_dialog_autohide_toggle_setup    (dialog, gui);
	panel_properties_dialog_hidebuttons_toggle_setup (dialog, gui);
	panel_properties_dialog_arrows_toggle_setup      (dialog, gui);

	panel_properties_dialog_image_chooser_setup     (dialog, gui);
	panel_properties_dialog_color_button_setup      (dialog, gui);
	panel_properties_dialog_opacity_scale_setup     (dialog, gui);
	panel_properties_dialog_background_radios_setup (dialog, gui);

	g_signal_connect (dialog->settings_background, "changed",
			  G_CALLBACK (panel_properties_dialog_background_changed),
			  dialog);

	panel_toplevel_push_autohide_disabler (dialog->toplevel);
	panel_widget_register_open_dialog (panel_toplevel_get_panel_widget (dialog->toplevel),
					   dialog->properties_dialog);

	gtk_widget_show (dialog->properties_dialog);

	return dialog;
}
Beispiel #4
0
static gboolean
panel_popup_menu_left (PanelToplevel *toplevel,
                  guint          button,
                  guint32        activate_time)
{
        PanelWidget *panel_widget;
        GtkWidget   *menu;
        PanelData   *panel_data;
        GdkEvent    *current_event;

        panel_widget = panel_toplevel_get_panel_widget (toplevel);
        panel_data   = g_object_get_data (G_OBJECT (toplevel), "PanelData");

        current_event = gtk_get_current_event ();
        if (current_event->type == GDK_BUTTON_PRESS)
                panel_data->insertion_pos = panel_widget_get_cursorloc (panel_widget);
        else
                panel_data->insertion_pos = -1;

        menu = make_popup_panel_menu (panel_widget);
	//gtk_widget_set_usize(GTK_WINDOW (menu),10,10);
        if (!menu)
                return FALSE;

        gtk_menu_set_screen (GTK_MENU (menu),
                             gtk_window_get_screen (GTK_WINDOW (toplevel)));
        gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button, activate_time);
        gtk_menu_popdown (GTK_MENU (menu));


        return FALSE;
}
	// Constructor. Creates GTK widgets.
	EntityClassChooser::EntityClassChooser () :
		_widget(gtk_window_new(GTK_WINDOW_TOPLEVEL)), _treeStore(NULL), _selection(NULL), _addButton(NULL)
	{
		gtk_window_set_transient_for(GTK_WINDOW(_widget), GlobalRadiant().getMainWindow());
		gtk_window_set_modal(GTK_WINDOW(_widget), TRUE);
		gtk_window_set_position(GTK_WINDOW(_widget), GTK_WIN_POS_CENTER_ON_PARENT);
		gtk_window_set_title(GTK_WINDOW(_widget), ECLASS_CHOOSER_TITLE);

		// Set the default size of the window

		GdkScreen* scr = gtk_window_get_screen(GTK_WINDOW(_widget));
		gint w = gdk_screen_get_width(scr);
		gint h = gdk_screen_get_height(scr);

		gtk_window_set_default_size(GTK_WINDOW(_widget), w / 3, h / 2);

		// Create GUI elements and pack into main VBox

		GtkWidget* vbx = gtk_vbox_new(FALSE, 3);
		gtk_box_pack_start(GTK_BOX(vbx), createTreeView(), TRUE, TRUE, 0);
		gtk_box_pack_start(GTK_BOX(vbx), createUsagePanel(), FALSE, FALSE, 0);
		gtk_box_pack_start(GTK_BOX(vbx), createButtonPanel(), FALSE, FALSE, 0);
		gtk_container_set_border_width(GTK_CONTAINER(_widget), 12);
		gtk_container_add(GTK_CONTAINER(_widget), vbx);

		// Signals
		g_signal_connect(_widget, "delete_event", G_CALLBACK(callbackHide), this);

	}
static void
preferences_show_help (GtkWindow *parent,
		       char const *helpfile,
		       char const *sect_id)
{
	GError *error = NULL;
	GtkWidget *dialog;
	char *help_string;

	g_assert (helpfile != NULL);
	g_assert (sect_id != NULL);

	help_string = g_strdup_printf ("help:%s/%s", helpfile, sect_id);

	gtk_show_uri (gtk_window_get_screen (parent),
		      help_string, gtk_get_current_event_time (),
		      &error);
	g_free (help_string);

	if (error) {
		dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
						 GTK_DIALOG_DESTROY_WITH_PARENT,
						 GTK_MESSAGE_ERROR,
						 GTK_BUTTONS_OK,
						 _("There was an error displaying help: \n%s"),
						 error->message);

		g_signal_connect (G_OBJECT (dialog),
				  "response", G_CALLBACK (gtk_widget_destroy),
				  NULL);
		gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
		gtk_widget_show (dialog);
		g_error_free (error);
	}
}
Beispiel #7
0
gboolean
tray_toggle_visibility(gboolean force_hide)
{
	static int x, y;
	static GdkScreen *screen;
	GtkWindow *win;
	session *sess = sess_list->data;

	if (!sticon)
		return FALSE;

	win = fe_gui_info_ptr(sess, 0);

	tray_stop_flash();
	tray_reset_counts();

	if (!win)
		return FALSE;

	if (force_hide || GTK_WIDGET_VISIBLE(win))
	{
		gtk_window_get_position(win, &x, &y);
		screen = gtk_window_get_screen(win);
		gtk_widget_hide(GTK_WIDGET(win));
	}
	else
	{
		gtk_window_set_screen(win, screen);
		gtk_window_move(win, x, y);
		gtk_widget_show(GTK_WIDGET (win));
		gtk_window_present(win);
	}

	return TRUE;
}
Beispiel #8
0
static gboolean
show_item_menu (GtkWidget      *item,
		GdkEventButton *bevent)
{
	PanelWidget *panel_widget;
	GtkWidget   *menu;

	if (panel_lockdown_get_locked_down ())
		return FALSE;

	panel_widget = menu_get_panel (item);

	menu = g_object_get_data (G_OBJECT (item), "panel-item-context-menu");

	if (!menu)
		menu = create_item_context_menu (item, panel_widget);

	if (!menu)
		return FALSE;

	gtk_menu_set_screen (GTK_MENU (menu),
			     gtk_window_get_screen (GTK_WINDOW (panel_widget->toplevel)));

	gtk_menu_popup (GTK_MENU (menu),
			NULL, NULL, NULL, NULL,
			bevent->button,
			bevent->time);

	return TRUE;
}
static void
realize (GtkWidget *widget)
{
	AthenaDesktopWindow *window;
	AthenaDesktopWindowDetails *details;

	window = ATHENA_DESKTOP_WINDOW (widget);
	details = window->details;

	/* Make sure we get keyboard events */
	gtk_widget_set_events (widget, gtk_widget_get_events (widget) 
			      | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
			      
	/* Do the work of realizing. */
	GTK_WIDGET_CLASS (athena_desktop_window_parent_class)->realize (widget);

	/* This is the new way to set up the desktop window */
	set_wmspec_desktop_hint (gtk_widget_get_window (widget));

	set_desktop_window_id (window, gtk_widget_get_window (widget));

	details->size_changed_id =
		g_signal_connect (gtk_window_get_screen (GTK_WINDOW (window)), "size_changed",
				  G_CALLBACK (athena_desktop_window_screen_size_changed), window);
}
GtkWidget*
remmina_widget_pool_find(GType type, const gchar *tag)
{
	GtkWidget *widget;
	gint i;
	GdkScreen *screen;
	gint screen_number;
	guint workspace;

	screen = gdk_screen_get_default();
	screen_number = gdk_screen_get_number(screen);
	workspace = remmina_public_get_current_workspace(screen);

	if (remmina_widget_pool == NULL)
		return NULL;

	for (i = 0; i < remmina_widget_pool->len; i++)
	{
		widget = GTK_WIDGET(g_ptr_array_index(remmina_widget_pool, i));
		if (!G_TYPE_CHECK_INSTANCE_TYPE(widget, type))
			continue;
		if (screen_number != gdk_screen_get_number(gtk_window_get_screen(GTK_WINDOW(widget))))
			continue;
		if (workspace != remmina_public_get_window_workspace(GTK_WINDOW(widget)))
			continue;
		if (tag && g_strcmp0((const gchar*) g_object_get_data(G_OBJECT(widget), "tag"), tag) != 0)
			continue;
		return widget;
	}
	return NULL;
}
Beispiel #11
0
static gboolean
panel_run_dialog_launch_command (PanelRunDialog *dialog,
				 const char     *command,
				 const char     *locale_command)
{
	GdkScreen  *screen;
	gboolean    result;
	GError     *error = NULL;
	char      **argv;
	int         argc;
	GPid        pid;

	if (!command_is_executable (locale_command, &argc, &argv))
		return FALSE;

	screen = gtk_window_get_screen (GTK_WINDOW (dialog->run_dialog));

	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->terminal_checkbox)))
		mate_desktop_prepend_terminal_to_vector (&argc, &argv);

#if GTK_CHECK_VERSION (3, 0, 0)
	result = g_spawn_async (NULL, /* working directory */
				argv,
				NULL, /* envp */
				G_SPAWN_SEARCH_PATH,
				NULL,
				NULL,
				&pid,
				&error);
#else
	result = gdk_spawn_on_screen (screen,
				      NULL, /* working directory */
				      argv,
				      NULL, /* envp */
				      G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
				      NULL, /* child setup func */
				      NULL, /* user data */
				      &pid, /* child pid */
				      &error);
#endif

	if (!result) {
		char *primary;

		primary = g_markup_printf_escaped (_("Could not run command '%s'"),
						   command);
		panel_error_dialog (GTK_WINDOW (dialog->run_dialog), NULL,
				    "cannot_spawn_command", TRUE,
				    primary, error->message);
		g_free (primary);

		g_error_free (error);
	} else {
		g_child_watch_add (pid, dummy_child_watch, NULL);
	}

	g_strfreev (argv);

	return result;
}
Beispiel #12
0
JNIEXPORT jlong JNICALL
Java_org_gnome_gtk_GtkWindow_gtk_1window_1get_1screen
(
	JNIEnv* env,
	jclass cls,
	jlong _self
)
{
	GdkScreen* result;
	jlong _result;
	GtkWindow* self;

	// convert parameter self
	self = (GtkWindow*) _self;

	// call function
	result = gtk_window_get_screen(self);

	// cleanup parameter self

	// translate return value to JNI type
	_result = (jlong) result;

	// cleanup return value
	if (result != NULL) {
		bindings_java_memory_cleanup((GObject*)result, FALSE);
	}

	// and finally
	return _result;
}
Beispiel #13
0
/********************************************************************\
 * gnc_restore_window_size                                          *
 *   restores the position and size of the given window, if these   *
 *   these parameters have been saved earlier. Does nothing if no   *
 *   saved values are found.                                        *
 *                                                                  *
 * Args: group - the preferences group to look in for saved coords  *
 *       window - the window for which the coords are to be         *
 *                restored                                          *
 * Returns: nothing                                                 *
 \*******************************************************************/
void
gnc_restore_window_size(const char *group, GtkWindow *window)
{
    gint wpos[2], wsize[2];
    GVariant *geometry;

    ENTER("");

    g_return_if_fail(group != NULL);
    g_return_if_fail(window != NULL);

    if (!gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_SAVE_GEOMETRY))
        return;

    geometry = gnc_prefs_get_value (group, GNC_PREF_LAST_GEOMETRY);
    if (g_variant_is_of_type (geometry, (const GVariantType *) "(iiii)") )
    {
        gint screen_width;
        gint screen_height;
#if GTK_CHECK_VERSION(3,22,0)
        GdkWindow *win = gdk_screen_get_root_window (gtk_window_get_screen (window));
        GdkMonitor *mon = gdk_display_get_monitor_at_window (gtk_widget_get_display (GTK_WIDGET(window)), win);
        GdkRectangle monitor_size;

        gdk_monitor_get_geometry (mon, &monitor_size);

        screen_width = monitor_size.width;
        screen_height = monitor_size.height;
#else
        screen_width = gdk_screen_width(); //default screen
        screen_height = gdk_screen_height(); //default screen
#endif
        g_variant_get (geometry, "(iiii)",
                       &wpos[0],  &wpos[1],
                       &wsize[0], &wsize[1]);
        DEBUG("geometry from preferences - wpos[0]: %d, wpos[1]: %d, wsize[0]: %d, wsize[1]: %d",
              wpos[0],  wpos[1], wsize[0], wsize[1]);

        /* (-1, -1) means no geometry was saved (default preferences value) */
        if ((wpos[0] != -1) && (wpos[1] != -1))
        {
            /* Keep the window on screen if possible */
            if (screen_width != 0)
                wpos[0] = wpos[0] % screen_width;
            if (screen_height != 0)
                wpos[1] = wpos[1] % screen_height;
            DEBUG("geometry after screen adaption - wpos[0]: %d, wpos[1]: %d, wsize[0]: %d, wsize[1]: %d",
                  wpos[0],  wpos[1], wsize[0], wsize[1]);

            gtk_window_move(window, wpos[0], wpos[1]);
        }

        /* Don't attempt to restore invalid sizes */
        if ((wsize[0] > 0) && (wsize[1] > 0))
            gtk_window_resize(window, wsize[0], wsize[1]);
    }
    g_variant_unref (geometry);

    LEAVE("");
}
Beispiel #14
0
static void
realize (GtkWidget *widget)
{
    NemoDesktopWindow *window;
    NemoDesktopWindowDetails *details;
    GdkVisual *visual;

    window = NEMO_DESKTOP_WINDOW (widget);
    details = window->details;

    /* Make sure we get keyboard events */
    gtk_widget_set_events (widget, gtk_widget_get_events (widget)
                           | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);

    visual = gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget));
    if (visual) {
        gtk_widget_set_visual (widget, visual);
    }

    /* Do the work of realizing. */
    GTK_WIDGET_CLASS (nemo_desktop_window_parent_class)->realize (widget);

    /* This is the new way to set up the desktop window */
    set_wmspec_desktop_hint (gtk_widget_get_window (widget));

    set_desktop_window_id (window, gtk_widget_get_window (widget));

    details->size_changed_id =
        g_signal_connect (gtk_window_get_screen (GTK_WINDOW (window)), "size_changed",
                          G_CALLBACK (nemo_desktop_window_screen_size_changed), window);
}
static void
nautilus_bookmarks_window_response_callback (GtkDialog *dialog,
					     int response_id,
					     gpointer callback_data)
{
	if (response_id == GTK_RESPONSE_HELP) {
		GError *error = NULL;

		gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (dialog)),
			      "ghelp:gnome-help#nautilus-bookmarks-edit",
			      gtk_get_current_event_time (), &error);

		if (error) {
			GtkWidget *err_dialog;
			err_dialog = gtk_message_dialog_new (GTK_WINDOW (dialog),
							     GTK_DIALOG_DESTROY_WITH_PARENT,
							     GTK_MESSAGE_ERROR,
							     GTK_BUTTONS_OK,
							     _("There was an error displaying help: \n%s"),
							     error->message);

			g_signal_connect (G_OBJECT (err_dialog),
					  "response", G_CALLBACK (gtk_widget_destroy),
					  NULL);
			gtk_window_set_resizable (GTK_WINDOW (err_dialog), FALSE);
			gtk_widget_show (err_dialog);
			g_error_free (error);
		}
	} else if (response_id == GTK_RESPONSE_CLOSE) {
		gtk_widget_hide (GTK_WIDGET (dialog));
        }
}
Beispiel #16
0
void background_info_set_background_by_file(BackgroundInfo* info,
        const char* file)
{
    g_message("[%s] file, :%s", __func__, file);
    GError* error = NULL;

    GdkScreen *screen;
    screen = gtk_window_get_screen (GTK_WINDOW (info->container));
    gint w = gdk_screen_get_width(screen);
    gint h = gdk_screen_get_height(screen);
    g_message("[%s] gdk_screen_get_width:%d, height: %d\n", __func__, w, h);
    GdkPixbuf* pb = gdk_pixbuf_new_from_file_at_scale(file,w,h,FALSE, &error);
    if (error != NULL) {
        g_warning("[%s] failed: %s\n", __func__, error->message);
        g_error_free(error);
        return;
    }
    g_mutex_lock(&info->m);
    if (info->bg != NULL) {
        cairo_surface_destroy(info->bg);
        info->bg = NULL;
    }
    info->bg = gdk_cairo_surface_create_from_pixbuf(pb, 1,
               gtk_widget_get_window(info->container));
    g_mutex_unlock(&info->m);
    g_object_unref(pb);
    if (gtk_widget_get_realized(info->container)) {
        gdk_window_invalidate_rect(gtk_widget_get_window(info->container),
                                   NULL, TRUE);
    }
}
Beispiel #17
0
static gboolean
spawn_synaptic (GtkWindow   *window,
		const gchar *path,
		gint        *child_pid)
{
  gchar **argv;
  GError *error = NULL;
  gboolean retval = TRUE;
  gint i = 0;

  argv = g_new0 (gchar*, 6);
  argv[i++] = g_find_program_in_path ("gksudo");
  argv[i++] = g_strdup ("--desktop");
  argv[i++] = g_strdup ("/usr/share/applications/synaptic.desktop");
  argv[i++] = g_strdup ("--disable-grab");
  argv[i++] = get_synaptic_command_line (window, path);
  argv[i++] = NULL;

  if (!gdk_spawn_on_screen (gtk_window_get_screen (window),
			    NULL, argv, NULL,
			    G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
			    NULL, NULL, child_pid, &error))
    {
      show_error_dialog (window, (error) ? error->message : "");
      g_error_free (error);
      retval = FALSE;
    }

  g_strfreev (argv);

  return retval;
}
Beispiel #18
0
// Create GTK widgets
ParticlesChooser::ParticlesChooser()
: _widget(gtk_window_new(GTK_WINDOW_TOPLEVEL)),
  _particlesList(gtk_list_store_new(1, G_TYPE_STRING)),
  _selectedParticle("")
{
	// Set up main window
	gtk_window_set_transient_for(GTK_WINDOW(_widget), GlobalMainFrame().getTopLevelWindow());
	gtk_window_set_modal(GTK_WINDOW(_widget), TRUE);
	gtk_window_set_title(GTK_WINDOW(_widget), _("Choose particles"));
    gtk_window_set_position(GTK_WINDOW(_widget), GTK_WIN_POS_CENTER_ON_PARENT);
	g_signal_connect(G_OBJECT(_widget), "delete-event", 
					 G_CALLBACK(_onDestroy), this);
	
	// Set the default size of the window
	GdkScreen* scr = gtk_window_get_screen(GTK_WINDOW(_widget));
	gint w = gdk_screen_get_width(scr);
	gint h = gdk_screen_get_height(scr);
	
	gtk_window_set_default_size(GTK_WINDOW(_widget), w / 3, h / 2);
	
	// Main dialog vbox
	GtkWidget* vbx = gtk_vbox_new(FALSE, 12);
	gtk_box_pack_start(GTK_BOX(vbx), createTreeView(), TRUE, TRUE, 0);
	gtk_box_pack_end(GTK_BOX(vbx), createButtons(), FALSE, FALSE, 0);
	
	// Add main vbox to dialog
	gtk_container_set_border_width(GTK_CONTAINER(_widget), 12);
	gtk_container_add(GTK_CONTAINER(_widget), vbx);	
}
static void
action_help (GSimpleAction *action,
	     GVariant *parameter,
	     gpointer user_data)
{
	GtkWindow *window;
	GtkWidget *dialog;
	GtkApplication *application = user_data;
	GError *error = NULL;

	window = gtk_application_get_active_window (application);
	gtk_show_uri (window ? 
		      gtk_window_get_screen (GTK_WINDOW (window)) :
		      gdk_screen_get_default (),
		      "help:gnome-help/files",
		      gtk_get_current_event_time (), &error);

	if (error) {
		dialog = gtk_message_dialog_new (window ? GTK_WINDOW (window) : NULL,
						 GTK_DIALOG_MODAL,
						 GTK_MESSAGE_ERROR,
						 GTK_BUTTONS_OK,
						 _("There was an error displaying help: \n%s"),
						 error->message);
		g_signal_connect (G_OBJECT (dialog), "response",
				  G_CALLBACK (gtk_widget_destroy),
				  NULL);

		gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
		gtk_widget_show (dialog);
		g_error_free (error);
	}
}
Beispiel #20
0
	ParticleEditor::ParticleEditor () :
		_widget(gtk_window_new(GTK_WINDOW_TOPLEVEL))
	{
		// Window properties
		gtk_window_set_transient_for(GTK_WINDOW(_widget), GlobalRadiant().getMainWindow());
		gtk_window_set_modal(GTK_WINDOW(_widget), TRUE);
		gtk_window_set_title(GTK_WINDOW(_widget), PARTICLEEDITOR_TITLE);
		gtk_window_set_position(GTK_WINDOW(_widget), GTK_WIN_POS_CENTER_ON_PARENT);

		// Set the default size of the window
		GdkScreen* scr = gtk_window_get_screen(GTK_WINDOW(_widget));
		gint w = gdk_screen_get_width(scr);
		gint h = gdk_screen_get_height(scr);

		gtk_window_set_default_size(GTK_WINDOW(_widget), gint(w * 0.75), gint(h * 0.8));

		// Create the model preview widget
		gint glSize = gint(h * 0.4);
		_particlePreview.setSize(glSize);

		// Signals
		//g_signal_connect(G_OBJECT(_widget), "delete_event", G_CALLBACK(callbackHide), this);

		// Main window contains a VBox
		GtkWidget* vbx = gtk_vbox_new(FALSE, 3);
		gtk_box_pack_start(GTK_BOX(vbx), createPreviewPanel(), FALSE, FALSE, 0);
		gtk_box_pack_end(GTK_BOX(vbx), createButtons(), FALSE, FALSE, 0);
		gtk_container_add(GTK_CONTAINER(_widget), vbx);
	}
void
panel_menu_button_popup_menu (PanelMenuButton *button,
			      guint            n_button,
			      guint32          activate_time)
{
	GdkScreen *screen;

	g_return_if_fail (PANEL_IS_MENU_BUTTON (button));

	panel_menu_button_create_menu (button);

	panel_toplevel_push_autohide_disabler (button->priv->toplevel);

	button_widget_set_ignore_leave (BUTTON_WIDGET (button), TRUE);

	screen = gtk_window_get_screen (GTK_WINDOW (button->priv->toplevel));
	gtk_menu_set_screen (GTK_MENU (button->priv->menu), screen);

	gtk_menu_popup (GTK_MENU (button->priv->menu),
			NULL,
			NULL,
			(GtkMenuPositionFunc) mate_panel_applet_position_menu,
			GTK_WIDGET (button),
			n_button,
			activate_time);
}
Beispiel #22
0
static void
ide_application_actions_help (GSimpleAction *action,
                              GVariant      *param,
                              gpointer       user_data)
{
  IdeApplication *self = user_data;
  GtkWindow *focused_window= NULL;
  GdkScreen *screen = NULL;
  GError *err = NULL;

  g_assert (IDE_IS_APPLICATION (self));

  focused_window = gtk_application_get_active_window (GTK_APPLICATION (self));

  screen = gtk_window_get_screen (focused_window);
  gtk_show_uri (screen,
                "help:gnome-builder",
                gtk_get_current_event_time (),
                &err);
  if (err)
    {
      g_message ("Unable to open help: %s\n", err->message);
      g_error_free (err);
    }
}
Beispiel #23
0
static gboolean
panel_popup_menu (PanelToplevel *toplevel,
		  guint          button,
		  guint32        activate_time)
{
	PanelWidget *panel_widget;
	GtkWidget   *menu;
	PanelData   *panel_data;
	GdkEvent    *current_event;

	panel_widget = panel_toplevel_get_panel_widget (toplevel);
	panel_data   = g_object_get_data (G_OBJECT (toplevel), "PanelData");

	current_event = gtk_get_current_event ();
	if (current_event->type == GDK_BUTTON_PRESS)
		panel_data->insert_pack_type = panel_widget_get_insert_pack_type_at_cursor (panel_widget);
	else
		panel_data->insert_pack_type = PANEL_OBJECT_PACK_START;
	
	menu = make_popup_panel_menu (panel_widget);
	if (!menu)
		return FALSE;

	gtk_menu_set_screen (GTK_MENU (menu),
			     gtk_window_get_screen (GTK_WINDOW (toplevel)));

	gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button, activate_time);

	return TRUE;
}
Beispiel #24
0
/* Make email in about dialog clickable */
static void 
about_dialog_handle_email_cb (GtkAboutDialog *about, const char *email_address, gpointer data)
{
	GError *error = NULL;
	gboolean ret;
	char *cmdline;
	GdkScreen *gscreen;
	GtkWidget *error_dialog;

	gscreen = gtk_window_get_screen (GTK_WINDOW (about));

	cmdline = g_strconcat ("gnome-open mailto:", email_address, NULL);
	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
	g_free (cmdline);

	if (ret == TRUE)
		return;

	g_error_free (error);
	error = NULL;

	cmdline = g_strconcat ("xdg-open mailto:", email_address, NULL);
	ret = gdk_spawn_command_line_on_screen (gscreen, cmdline, &error);
	g_free (cmdline);
	
	if (ret == FALSE) {
		error_dialog = gtk_message_dialog_new ( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Failed to show url %s", error->message); 
		gtk_dialog_run (GTK_DIALOG (error_dialog));
		g_error_free (error);
	}
}
Beispiel #25
0
static void
applet_show_menu (AppletInfo     *info,
		  GdkEventButton *event)
{
	PanelWidget *panel_widget;

	g_return_if_fail (info != NULL);

	panel_widget = mate_panel_applet_get_panel_widget (info);

	if (info->menu == NULL)
		info->menu = mate_panel_applet_create_menu (info);

	if (info->menu == NULL)
		return;

	mate_panel_applet_menu_set_recurse (GTK_MENU (info->menu),
				       "menu_panel",
				       panel_widget);

	gtk_menu_set_screen (GTK_MENU (info->menu),
			     gtk_window_get_screen (GTK_WINDOW (panel_widget->toplevel)));

	if (!gtk_widget_get_realized (info->menu))
		gtk_widget_show (info->menu);

	gtk_menu_popup (GTK_MENU (info->menu),
			NULL,
			NULL,
			(GtkMenuPositionFunc) mate_panel_applet_position_menu,
			info->widget,
			event->button,
			event->time);
}
Beispiel #26
0
void
show_help_dialog (GtkWindow  *parent,
		  const char *section)
{
	char   *uri;
	GError *error = NULL;

	uri = g_strconcat ("help:engrampa", section ? "/" : NULL, section, NULL);
	if (! show_uri (gtk_window_get_screen (parent), uri, GDK_CURRENT_TIME, &error)) {
  		GtkWidget *dialog;

		dialog = _gtk_message_dialog_new (parent,
						  GTK_DIALOG_DESTROY_WITH_PARENT,
						  GTK_STOCK_DIALOG_ERROR,
						  _("Could not display help"),
						  error->message,
						  GTK_STOCK_OK, GTK_RESPONSE_OK,
						  NULL);
		gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);

		g_signal_connect (G_OBJECT (dialog), "response",
				  G_CALLBACK (gtk_widget_destroy),
				  NULL);

		gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);

		gtk_widget_show (dialog);

		g_clear_error (&error);
	}
	g_free (uri);
}
Beispiel #27
0
static void
applet_show_menu (AppletInfo     *info,
		  GtkWidget      *menu,
		  gboolean        custom_position,
		  GdkEventButton *event)
{
	PanelWidget *panel_widget;

	g_return_if_fail (info != NULL);

	if (menu == NULL)
		return;

	panel_widget = panel_applet_get_panel_widget (info);

	panel_applet_menu_set_recurse (GTK_MENU (menu),
				       "menu_panel",
				       panel_widget);

	gtk_menu_set_screen (GTK_MENU (menu),
			     gtk_window_get_screen (GTK_WINDOW (panel_widget->toplevel)));

	if (!gtk_widget_get_realized (menu))
		gtk_widget_show (menu);

	gtk_menu_popup (GTK_MENU (menu),
			NULL,
			NULL,
			custom_position ?
				(GtkMenuPositionFunc) panel_applet_position_menu : NULL,
			info->widget,
			event->button,
			event->time);
}
Beispiel #28
0
static void
remove_popup (GtkWidget *popup)
{
	GdkWindow        *root;
#if GTK_CHECK_VERSION (3, 0, 0)
	GdkDisplay       *display;
	GdkDevice        *pointer;
	GdkDevice        *keyboard;
	GdkDeviceManager *device_manager;
#endif

	root = gdk_screen_get_root_window (
			gtk_window_get_screen (GTK_WINDOW (popup)));
	gdk_window_remove_filter (root, (GdkFilterFunc) popup_filter, popup);

	gtk_widget_destroy (popup);

#if GTK_CHECK_VERSION (3, 0, 0)
	display = gdk_window_get_display (root);
	device_manager = gdk_display_get_device_manager (display);
	pointer = gdk_device_manager_get_client_pointer (device_manager);
	keyboard = gdk_device_get_associated_device (pointer);

	gdk_device_ungrab (pointer, GDK_CURRENT_TIME);
	gdk_device_ungrab (keyboard, GDK_CURRENT_TIME);
#else
	gdk_pointer_ungrab (GDK_CURRENT_TIME);
	gdk_keyboard_ungrab (GDK_CURRENT_TIME);
#endif
}
Beispiel #29
0
static void
action_caja_manual_callback (GtkAction *action,
                             gpointer user_data)
{
    CajaWindow *window;
    GError *error;
    GtkWidget *dialog;

    error = NULL;
    window = CAJA_WINDOW (user_data);

    gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (window)),
                   CAJA_IS_DESKTOP_WINDOW (window)
                      ? "help:mate-user-guide"
                      : "help:mate-user-guide/goscaja-1",
                  gtk_get_current_event_time (), &error);

    if (error)
    {
        dialog = gtk_message_dialog_new (GTK_WINDOW (window),
                                         GTK_DIALOG_MODAL,
                                         GTK_MESSAGE_ERROR,
                                         GTK_BUTTONS_OK,
                                         _("There was an error displaying help: \n%s"),
                                         error->message);
        g_signal_connect (G_OBJECT (dialog), "response",
                          G_CALLBACK (gtk_widget_destroy),
                          NULL);

        gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
        gtk_widget_show (dialog);
        g_error_free (error);
    }
}
Beispiel #30
0
/* Ask X to move to the desktop on which @window currently is
 * and the present @window. */
void
empathy_move_to_window_desktop (GtkWindow *window,
    guint32 timestamp)
{
#ifdef GDK_WINDOWING_X11
  GdkScreen *screen;
  Screen *xscreen;
  GdkWindow *gdk_window;
  int workspace;

  screen = gtk_window_get_screen (window);
  if (!GDK_IS_X11_SCREEN (screen))
    goto out;

  xscreen = gdk_x11_screen_get_xscreen (screen);
  gdk_window = gtk_widget_get_window (GTK_WIDGET (window));

  workspace = window_get_workspace (xscreen,
      gdk_x11_window_get_xid (gdk_window));
  if (workspace == -1)
    goto out;

  _wnck_activate_workspace (xscreen, workspace, timestamp);

out:
  gtk_window_present_with_time (window, timestamp);
#endif
}