コード例 #1
0
static void
panel_ditem_editor_destroy (GtkObject *object)
{
	PanelDItemEditor *dialog;
	
	dialog = PANEL_DITEM_EDITOR (object);

	/* If there was a timeout, then something changed after last save,
	 * so we must save again now */
	if (dialog->priv->save_timeout) {
		g_source_remove (dialog->priv->save_timeout);
		dialog->priv->save_timeout = 0;
		panel_ditem_editor_save (dialog, FALSE);
	}

	/* remember, destroy can be run multiple times! */

	if (dialog->priv->free_key_file && dialog->priv->key_file != NULL)
		g_key_file_free (dialog->priv->key_file);
	dialog->priv->key_file = NULL;

	if (dialog->priv->revert_key_file != NULL)
		g_key_file_free (dialog->priv->revert_key_file);
	dialog->priv->revert_key_file = NULL;

	if (dialog->priv->uri != NULL)
		g_free (dialog->priv->uri);
	dialog->priv->uri = NULL;

	if (dialog->priv->icon_theme_dir != NULL)
		g_free (dialog->priv->icon_theme_dir);
	dialog->priv->icon_theme_dir = NULL;

	GTK_OBJECT_CLASS (panel_ditem_editor_parent_class)->destroy (object);
}
コード例 #2
0
void
ask_about_launcher (const char          *file,
		    PanelWidget         *panel,
		    PanelObjectPackType  pack_type)
{
	GtkWidget *dialog;
	GKeyFile  *key_file;

	if (panel_lockdown_get_disable_command_line_s ())
		return;

	dialog = panel_ditem_editor_new (NULL, NULL, NULL,
					 _("Create Launcher"));
	panel_widget_register_open_dialog (panel, dialog);

	key_file = panel_ditem_editor_get_key_file (PANEL_DITEM_EDITOR (dialog));
	if (file != NULL)
		panel_key_file_set_string (key_file, "Exec", file);
	panel_key_file_set_string (key_file, "Type", "Application");
	panel_ditem_editor_sync_display (PANEL_DITEM_EDITOR (dialog));

	panel_ditem_register_save_uri_func (PANEL_DITEM_EDITOR (dialog),
					    launcher_save_uri,
					    NULL);

	g_signal_connect (G_OBJECT (dialog), "saved",
			  G_CALLBACK (launcher_new_saved), NULL);

	g_signal_connect (G_OBJECT (dialog), "error_reported",
			  G_CALLBACK (launcher_error_reported), NULL);

	gtk_window_set_screen (GTK_WINDOW (dialog),
			       gtk_widget_get_screen (GTK_WIDGET (panel)));

	g_object_set_data (G_OBJECT (dialog), "pack-type",
			   GINT_TO_POINTER (pack_type));
	g_object_set_data (G_OBJECT (dialog), "panel", panel);

	gtk_widget_show (dialog);
}
コード例 #3
0
static GObject *
panel_ditem_editor_constructor (GType                  type,
				guint                  n_construct_properties,
				GObjectConstructParam *construct_properties)
{
	GObject          *obj;
	PanelDItemEditor *dialog;
	GnomeVFSURI      *vfs_uri;
	gboolean          loaded;

	obj = G_OBJECT_CLASS (panel_ditem_editor_parent_class)->constructor (type,
									     n_construct_properties,
									     construct_properties);

	dialog = PANEL_DITEM_EDITOR (obj);

	if (dialog->priv->key_file) {
		panel_ditem_editor_key_file_loaded (dialog);
		dialog->priv->new_file = FALSE;
		dialog->priv->free_key_file = FALSE;
		loaded = TRUE;
	} else {
		dialog->priv->key_file = panel_util_key_file_new_desktop ();
		dialog->priv->free_key_file = TRUE;
		loaded = FALSE;
	}

	if (!loaded && dialog->priv->uri) {
		vfs_uri = gnome_vfs_uri_new (dialog->priv->uri);
		if (gnome_vfs_uri_exists (vfs_uri)) {
			//FIXME what if there's an error?
			panel_ditem_editor_load_uri (dialog, NULL);
			dialog->priv->new_file = FALSE;
		} else {
			dialog->priv->new_file = TRUE;
		}
		gnome_vfs_uri_unref (vfs_uri);
	} else {
		dialog->priv->new_file = !loaded;
	}

	dialog->priv->dirty = FALSE;

	panel_ditem_editor_setup_ui (dialog);

	return obj;
}
コード例 #4
0
void
launcher_properties (Launcher  *launcher)
{
	if (launcher->prop_dialog != NULL) {
		gtk_window_set_screen (GTK_WINDOW (launcher->prop_dialog),
				       gtk_widget_get_screen (launcher->button));
		gtk_window_present (GTK_WINDOW (launcher->prop_dialog));
		return;
	}

	launcher->prop_dialog = panel_ditem_editor_new (NULL,
							launcher->key_file,
							launcher->location,
							_("Launcher Properties"));
	gtk_window_set_screen (GTK_WINDOW (launcher->prop_dialog),
				       gtk_widget_get_screen (launcher->button));

	panel_widget_register_open_dialog (PANEL_WIDGET 
					   (gtk_widget_get_parent (launcher->info->widget)),
					   launcher->prop_dialog);

	panel_ditem_register_save_uri_func (PANEL_DITEM_EDITOR (launcher->prop_dialog),
					    launcher_save_uri,
					    launcher);

	g_signal_connect (launcher->prop_dialog, "changed",
			  G_CALLBACK (launcher_changed), launcher);

	g_signal_connect (launcher->prop_dialog, "command_changed",
			  G_CALLBACK (launcher_command_changed), launcher);

	g_signal_connect (launcher->prop_dialog, "saved",
			  G_CALLBACK (launcher_saved), launcher);

	g_signal_connect (launcher->prop_dialog, "error_reported",
			  G_CALLBACK (launcher_error_reported), NULL);

	g_signal_connect (launcher->prop_dialog, "destroy",
			  G_CALLBACK (gtk_widget_destroyed),
			  &launcher->prop_dialog);

	gtk_widget_show (launcher->prop_dialog);
}
コード例 #5
0
static void
launcher_new_saved (GtkWidget *dialog,
		    gpointer   data)
{
	PanelWidget         *panel;
	PanelObjectPackType  pack_type;
	int                  pack_index;
	const char          *uri;

	pack_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog),
				     "pack-type"));
	panel = g_object_get_data (G_OBJECT (dialog), "panel");

	pack_index = panel_widget_get_new_pack_index (panel, pack_type);

	uri = panel_ditem_editor_get_uri (PANEL_DITEM_EDITOR (dialog));
	if (panel_launcher_get_filename (uri) != NULL)
		uri = panel_launcher_get_filename (uri);
	panel_launcher_create (panel->toplevel, pack_type, pack_index, uri);
}
コード例 #6
0
static void
launcher_saved (GtkWidget *dialog,
		Launcher  *launcher)
{
	const char *uri;

	uri = panel_ditem_editor_get_uri (PANEL_DITEM_EDITOR (dialog));
	if (panel_launcher_get_filename (uri) != NULL)
		uri = panel_launcher_get_filename (uri);

	if (uri && launcher->location && strcmp (uri, launcher->location)) {
		GSettings *settings;

		settings = panel_layout_get_instance_settings (launcher->info->settings,
							       PANEL_LAUNCHER_SCHEMA);
		g_settings_set_string (settings, PANEL_LOCATION_KEY, uri);
		g_object_unref (settings);

		if (launcher->location)
			g_free (launcher->location);
		launcher->location = g_strdup (uri);
	}
}
コード例 #7
0
static void
panel_ditem_editor_set_property (GObject       *object,
				 guint	       prop_id,
				 const GValue *value,
				 GParamSpec   *pspec)
{
	PanelDItemEditor *dialog;

	g_return_if_fail (PANEL_IS_DITEM_EDITOR (object));

	dialog = PANEL_DITEM_EDITOR (object);

	switch (prop_id) {
	case PROP_KEYFILE:
		panel_ditem_editor_set_key_file (dialog, g_value_get_pointer (value));
		break;
	case PROP_URI:
		panel_ditem_editor_set_uri (dialog, g_value_get_string (value));
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}