コード例 #1
0
/* callbacks */
void
on_service_toggled (GtkCellRenderer *renderer, gchar *path_str, gpointer data)
{
	GtkTreeView *treeview = GTK_TREE_VIEW (gst_dialog_get_widget (tool->main_dialog, "services_list"));
	GtkTreeModel *model = gtk_tree_view_get_model (treeview);
	GtkTreePath *path;
	GstTool *tool = GST_TOOL (data);
	GtkTreeIter iter;
	OobsService *service;
	gboolean value, new_value, dangerous;

	path = gtk_tree_path_new_from_string (path_str);
	value = gtk_cell_renderer_toggle_get_active (GTK_CELL_RENDERER_TOGGLE (renderer));
	new_value = !value;

	if (!gtk_tree_model_get_iter (model, &iter, path))
		return;

	gtk_tree_model_get (model,
			    &iter,
			    COL_OBJECT, &service,
			    COL_DANGEROUS, &dangerous,
			    -1);

	if (new_value || !dangerous || show_warning_dialog (tool, service)) {
		OobsServicesRunlevel *rl;
		
		rl = GST_SERVICES_TOOL (tool)->default_runlevel;
		oobs_service_set_runlevel_configuration (service, rl,
							 (new_value) ? OOBS_SERVICE_START : OOBS_SERVICE_IGNORE,
							 /* FIXME: hardcoded value... */
							 50);
		oobs_object_commit (GST_SERVICES_TOOL (tool)->services_config);

		gtk_list_store_set (GTK_LIST_STORE (model),
				    &iter,
				    COL_ACTIVE, new_value,
				    -1);
	}

	gtk_tree_path_free (path);
}
コード例 #2
0
int 
main (int argc, char *argv[]) 
{
	int err, i;
	GNOME_Pilot_Survival survive;
	GError *error;
	GList *pilots = NULL;
	GOptionContext *option_context;
        
	bindtextdomain (PACKAGE, GNOMELOCALEDIR);
	textdomain (PACKAGE);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");

	if (argc<2) {
		g_message ("usage : %s [--now|--later] [--pilot PDA] [FILE ...]", argv[0]);
		exit (1);
	}

	option_context = g_option_context_new (PACKAGE);
	g_option_context_add_main_entries (option_context, options, NULL);
	if (!g_option_context_parse(option_context, &argc, &argv, &error)) {
		g_error (_("Error parsing commandline arguments: %s"), error->message);
		exit (1);
	}

	gtk_init (&argc, &argv);

	gpc = GNOME_PILOT_CLIENT (gnome_pilot_client_new ());
	g_object_ref_sink (G_OBJECT (gpc));
	g_signal_connect (G_OBJECT (gpc),"completed_request", G_CALLBACK(gpilotd_request_completed), NULL);
	gnome_pilot_client_connect_to_daemon (gpc);

	if (pilot_arg!=NULL) {
		pilots = g_list_append (pilots, g_strdup (pilot_arg));
	} else {
		err = gnome_pilot_client_get_pilots (gpc, &pilots);
		if (err !=GPILOTD_OK || pilots == NULL) {
			g_warning (_("Unable to get PDA names"));
			show_warning_dialog (_("Unable to get PDA names"));
			exit (1);
		}
	}

	notfailed = failed = handles = NULL;

	survive = GNOME_Pilot_IMMEDIATE;
	if (later) survive = GNOME_Pilot_PERSISTENT;
	
	i=0;

	while (filenames && filenames[i]!=NULL) {
		gint err;
		err = gnome_pilot_client_install_file (gpc,
						       pilots->data, /* get first pilot */
						       filenames[i],
						       survive,
						       0,
						       &handle);
		if (err == GPILOTD_OK) {
			handles = g_slist_prepend (handles,GINT_TO_POINTER(handle));
			notfailed = g_slist_prepend (notfailed, (void *) filenames[i]);
		} else {
			failed = g_slist_prepend (failed, (void *) filenames[i]);
		}
		i++;
	}

	if (!later) {
		gchar *message;
		
		message = NULL;
		if (failed != NULL) {
			GSList *e;
			message = g_strdup (_("Following files failed :\n"));
			for (e=failed;e;e = g_slist_next (e)) {
				gchar *tmp;
				tmp = g_strconcat (message,"\t- ", e->data,"\n", NULL);
				g_free (message);
				message = tmp;
			}
			g_slist_free (failed);
		}
		{
			GSList *e;
			if (message == NULL)
				message = g_strdup_printf (_("Installing to %s:\n"), (char*)pilots->data);
			else {
				gchar *tmp;
				tmp = g_strconcat (message,"\nInstalling to ", 
						   (char*)pilots->data, ":\n", NULL);
				g_free (message);
				message = tmp;
			}
			for (e=notfailed;e;e = g_slist_next (e)) {
				gchar *tmp;
				tmp = g_strconcat (message,"\t- ", e->data,"\n", NULL);
				g_free (message);
				message = tmp;
			}
			g_slist_free (notfailed);
		}
		{
			gchar *tmp;
			gchar *info;

			if (handles == NULL) 
				info = g_strdup (_("No files to install"));
			else {
				
				info = g_strdup (_("Press synchronize on the cradle to install\n" 
						  " or cancel the operation."));
                                err = gnome_pilot_client_conduit (gpc,
                                                            pilots->data,
                                                            "File",
                                                            GNOME_Pilot_CONDUIT_DEFAULT,
                                                            survive,
                                                            0,
                                                            &handle);
			}
						
			tmp = g_strconcat (message==NULL?"":message,
					  "\n",
					  info,
					  NULL);
			g_free (message);
			g_free (info);
			message = tmp;
		}
		dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
		    GTK_MESSAGE_OTHER, GTK_BUTTONS_CANCEL, "%s",
		    message);
		gint response = gtk_dialog_run(GTK_DIALOG(dialog));
		if (dialog != NULL) /* if not destroyed by callback */
			gtk_widget_destroy(dialog);
		if (response == GTK_RESPONSE_CANCEL) {
			GSList *e;
			for (e=handles;e;e = g_slist_next (e)) {
				gnome_pilot_client_remove_request
				    (gpc,GPOINTER_TO_INT(e->data));  
			}
			g_slist_free (handles);
		}
		g_free (message);
	}

	g_object_unref (G_OBJECT (gpc));

	return 0;
}