Пример #1
0
static void device_changed (GtkTreeModel *model,
			     GtkTreePath  *path,
			     GtkTreeIter  *_iter,
			     gpointer      data)
{
	GtkTreeIter iter, *default_iter;
	gboolean powered, cont;

	default_iter = NULL;
	num_adapters_present = num_adapters_powered = 0;

	cont = gtk_tree_model_get_iter_first (model, &iter);
	while (cont) {
		gboolean is_default;

		num_adapters_present++;

		gtk_tree_model_get (model, &iter,
				    BLUETOOTH_COLUMN_DEFAULT, &is_default,
				    BLUETOOTH_COLUMN_POWERED, &powered,
				    -1);
		if (powered)
			num_adapters_powered++;
		if (is_default && powered)
			default_iter = gtk_tree_iter_copy (&iter);

		cont = gtk_tree_model_iter_next (model, &iter);
	}

	update_discoverability (default_iter);
	update_icon_visibility ();
	update_menu_items ();
	update_device_list (default_iter);

	if (default_iter != NULL)
		gtk_tree_iter_free (default_iter);
}
Пример #2
0
int main(int argc, char *argv[])
{
	GApplication *app;
#ifdef HAVE_APP_INDICATOR
	AppIndicator *indicator;
#else
	GtkStatusIcon *statusicon;
#endif /* HAVE_APP_INDICATOR */
	GtkWidget *menu;
	GOptionContext *context;
	GError *error = NULL;

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

	g_type_init ();

	/* Parse command-line options */
	context = g_option_context_new (N_("- Bluetooth applet"));
	g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
	if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) {
		g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
			 error->message, argv[0]);
		g_error_free (error);
		return 1;
	}

	if (option_debug == FALSE) {
		GError *error = NULL;

		app = g_application_new ("org.cinnamon.Bluetooth.applet",
					 G_APPLICATION_FLAGS_NONE);
		if (!g_application_register (app, NULL, &error)) {
			g_object_unref (app);
			g_warning ("%s", error->message);
			g_error_free (error);
			return 1;
		}
		if (g_application_get_is_remote (app)) {
			g_object_unref (app);
			g_warning ("Applet is already running, exiting");
			return 0;
		}
	} else {
		app = NULL;
	}

	g_set_application_name(_("Bluetooth Applet"));

	gtk_window_set_default_icon_name("bluetooth");

	applet = g_object_new (BLUETOOTH_TYPE_APPLET, NULL);
	g_signal_connect (G_OBJECT (applet), "notify::killswitch-state",
			G_CALLBACK (killswitch_state_changed), NULL);

	menu = create_popupmenu();

#ifdef HAVE_APP_INDICATOR
	indicator = init_notification();
	app_indicator_set_menu(indicator, GTK_MENU(menu));
	app_indicator_set_title(indicator, _("Bluetooth"));
	gsettings = g_settings_new (BLUETOOTH_INDICATOR_GSETTINGS_SCHEMA_ID);
	g_signal_connect (gsettings, "changed::" GSETTINGS_VISIBLE_KEY,
	                  G_CALLBACK(update_icon_visibility), NULL);
#else
	statusicon = init_notification();
#endif /* HAVE_APP_INDICATOR */

	g_signal_connect (G_OBJECT (applet), "devices-changed",
			G_CALLBACK (update_device_list), NULL);
	g_signal_connect (G_OBJECT (applet), "notify::discoverable",
			G_CALLBACK (update_discoverability), NULL);
	g_signal_connect (G_OBJECT (applet), "notify::show-full-menu",
			G_CALLBACK (update_menu_items), NULL);

	killswitch_state_changed ((GObject*) applet, NULL, NULL);
	update_menu_items ((GObject*) applet, NULL, NULL);
	update_discoverability ((GObject*) applet, NULL, NULL);
	update_device_list (applet, NULL);

	update_icon_visibility();

#ifndef HAVE_APP_INDICATOR
	g_signal_connect(statusicon, "activate",
				G_CALLBACK(activate_callback), menu);
	g_signal_connect(statusicon, "popup-menu",
				G_CALLBACK(popup_callback), menu);
#endif /* HAVE_APP_INDICATOR */

	setup_agents(applet);

	gtk_main();

	gtk_widget_destroy(menu);

	cleanup_notification();

	g_object_unref(applet);

	if (app != NULL)
		g_object_unref (app);

	return 0;
}
Пример #3
0
void digest_media_verify()
{
  int i;
  char buf[256], *device = NULL;
  hd_t *hd;

  update_device_list(0);

  iso.err = 1;

  if(config.device) get_info(device = config.device);

  if(iso.err) {
    for(hd = fix_device_names(hd_list(config.hd_data, hw_cdrom, 0, NULL)); hd; hd = hd->next) {
      if(hd->is.notready) continue;
      get_info(device = hd->unix_dev_name);
      if(!iso.err) break;
    }
  }

  if(iso.err) {
    if(dia_message("Insert Installation CD-ROM or DVD.", MSGTYPE_INFO)) return;

    for(hd = fix_device_names(hd_list(config.hd_data, hw_cdrom, 0, NULL)); hd; hd = hd->next) {
      if(hd->is.notready) continue;
      get_info(device = hd->unix_dev_name);
      if(!iso.err) break;
    }
  }

  if(iso.err) {
    dia_message("No CD-ROM or DVD found.", MSGTYPE_ERROR);
    config.manual=1;
    return;
  }

  fprintf(stderr,
    "  app: %s\nmedia: %s%d\n size: %u kB\n  pad: %u kB\n",
    iso.app_id,
    iso.media_type,
    iso.media_nr ?: 1,
    iso.size,
    iso.pad
  );

  fprintf(stderr, "  ref: ");
  if(iso.digest.got_old) for(i = 0; i < iso.digest.size; i++) fprintf(stderr, "%02x", iso.digest.old[i]);
  fprintf(stderr, "\n");

  if(!*iso.app_id || !iso.digest.got_old || iso.pad >= iso.size) {
    sprintf(buf, "This is not a %s CD-ROM.", config.product);
    dia_message(buf, MSGTYPE_ERROR);
    config.manual=1;
    return;
  }

  do_digest(device);

  if(iso.err_ofs) {
    fprintf(stderr, "  err: sector %u\n", iso.err_ofs >> 1);
  }