Esempio n. 1
0
void setup_adapter(GtkNotebook *_notebook)
{
	killswitch = bluetooth_killswitch_new ();
	notebook = _notebook;

	/* Create our static pages first */
	create_killswitch_page (notebook);
	create_no_adapter_page (notebook, "properties-no-adapter.ui");
	create_no_adapter_page (notebook, "properties-killed-adapter.ui");

	client = bluetooth_client_new();

	adapter_model = bluetooth_client_get_adapter_model(client);

	g_signal_connect_after(G_OBJECT(adapter_model), "row-inserted",
					G_CALLBACK(adapter_added), notebook);
	g_signal_connect_after(G_OBJECT(adapter_model), "row-deleted",
					G_CALLBACK(adapter_removed), notebook);
	g_signal_connect_after (G_OBJECT(adapter_model), "row-changed",
				G_CALLBACK (adapter_changed), notebook);

	gtk_tree_model_foreach(adapter_model, adapter_insert, notebook);

	set_current_page (notebook);
}
Esempio n. 2
0
void EditorArea::add_editor(SourceEditor *editor)
{
    m_editors[editor->get_file()->get_path()] = editor;    
    int idx = append_page(*editor, editor->get_file()->get_basename());
    editor->show_all();
    set_current_page(idx);
}
Esempio n. 3
0
static void
killswitch_state_changed (BluetoothKillswitch *killswitch,
			  KillswitchState state,
			  gpointer user_data)
{
	if (state != KILLSWITCH_STATE_UNBLOCKED)
		g_timeout_add_seconds (3, set_sensitive_now, user_data);
	set_current_page (GTK_NOTEBOOK (notebook));
}
Esempio n. 4
0
// paste external text
void clipboard_paste_text(gchar *text)
{
  struct Item *item;
  double pt[2];

  reset_selection();
  get_current_pointer_coords(pt);
  set_current_page(pt);  

  ui.selection = g_new(struct Selection, 1);
  ui.selection->type = ITEM_SELECTRECT;
  ui.selection->layer = ui.cur_layer;
  ui.selection->items = NULL;

  item = g_new(struct Item, 1);
  ui.selection->items = g_list_append(ui.selection->items, item);
  ui.cur_layer->items = g_list_append(ui.cur_layer->items, item);
  ui.cur_layer->nitems++;
  item->type = ITEM_TEXT;
  g_memmove(&(item->brush), &(ui.brushes[ui.cur_mapping][TOOL_PEN]), sizeof(struct Brush));
  item->text = text; // text was newly allocated, we keep it
  item->font_name = g_strdup(ui.font_name);
  item->font_size = ui.font_size;
  item->bbox.left = pt[0]; item->bbox.top = pt[1];
  make_canvas_item_one(ui.cur_layer->group, item);
  update_item_bbox(item);

  // move the text to fit on the page if needed
  if (item->bbox.right > ui.cur_page->width) item->bbox.left += ui.cur_page->width-item->bbox.right;
  if (item->bbox.left < 0) item->bbox.left = 0;
  if (item->bbox.bottom > ui.cur_page->height) item->bbox.top += ui.cur_page->height-item->bbox.bottom;
  if (item->bbox.top < 0) item->bbox.top = 0;
  gnome_canvas_item_set(item->canvas_item, "x", item->bbox.left, "y", item->bbox.top, NULL);
  update_item_bbox(item);
  
  ui.selection->bbox = item->bbox;
  ui.selection->canvas_item = gnome_canvas_item_new(ui.cur_layer->group,
      gnome_canvas_rect_get_type(), "width-pixels", 1,
      "outline-color-rgba", 0x000000ff,
      "fill-color-rgba", 0x80808040,
      "x1", ui.selection->bbox.left, "x2", ui.selection->bbox.right, 
      "y1", ui.selection->bbox.top, "y2", ui.selection->bbox.bottom, NULL);
  make_dashed(ui.selection->canvas_item);

  prepare_new_undo();
  undo->type = ITEM_PASTE;
  undo->layer = ui.cur_layer;
  undo->itemlist = g_list_copy(ui.selection->items);  
  
  update_copy_paste_enabled();
  update_color_menu();
  update_thickness_buttons();
  update_color_buttons();
  update_font_button();  
  update_cursor(); // FIXME: can't know if pointer is within selection!
}
Esempio n. 5
0
// paste an external image
void clipboard_paste_image(GdkPixbuf *pixbuf)
{
  double pt[2];

  reset_selection();

  get_current_pointer_coords(pt);
  set_current_page(pt);  

  create_image_from_pixbuf(pixbuf, pt);
}
Esempio n. 6
0
static void adapter_removed(GtkTreeModel *model, GtkTreePath *path,
							gpointer user_data)
{
	GtkNotebook *notebook = user_data;
	int i, count = gtk_notebook_get_n_pages(notebook);

	for (i = 0; i < count; i++) {
		GtkWidget *widget;
		adapter_data *adapter;

		widget = gtk_notebook_get_nth_page(notebook, i);
		if (widget == NULL)
			continue;

		adapter = g_object_get_data(G_OBJECT(widget), "adapter");
		if (adapter == NULL)
			continue;

		if (gtk_tree_row_reference_valid(adapter->reference) == TRUE)
			continue;

		gtk_tree_row_reference_free(adapter->reference);
		adapter->reference = NULL;

		gtk_notebook_remove_page(notebook, i);
		set_current_page (notebook);
		/* When the default adapter changes, the adapter_changed signal will
		 * take care of setting the right page */

		g_signal_handlers_disconnect_by_func(adapter->proxy,
						property_changed, adapter);

		g_object_unref(adapter->proxy);
		g_free(adapter);
	}
}
Esempio n. 7
0
void insert_image(GdkEvent *event)
{
  GtkTextBuffer *buffer;
  GnomeCanvasItem *canvas_item;
  GdkColor color;
  GtkWidget *dialog;
  GtkFileFilter *filt_all;
  GtkFileFilter *filt_gdkimage;
  char *filename;
  GdkPixbuf *pixbuf;
  double scale=1;
  double pt[2];
  
  dialog = gtk_file_chooser_dialog_new(_("Insert Image"), GTK_WINDOW (winMain),
     GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
     GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
#ifdef FILE_DIALOG_SIZE_BUGFIX
  gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 400);
#endif
     
  filt_all = gtk_file_filter_new();
  gtk_file_filter_set_name(filt_all, _("All files"));
  gtk_file_filter_add_pattern(filt_all, "*");
  filt_gdkimage = gtk_file_filter_new();
  gtk_file_filter_set_name(filt_gdkimage, _("Image files"));
  gtk_file_filter_add_pixbuf_formats(filt_gdkimage);
  gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filt_gdkimage);
  gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filt_all);

  if (ui.default_image != NULL) gtk_file_chooser_set_filename(GTK_FILE_CHOOSER (dialog), ui.default_image);

  if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK) {
    gtk_widget_destroy(dialog);
    return;
  }
  filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
  gtk_widget_destroy(dialog);

  if (filename == NULL) return; /* nothing selected */

  if (ui.default_image != NULL) g_free(ui.default_image);
  ui.default_image = g_strdup(filename);
  
  set_cursor_busy(TRUE);
  pixbuf=gdk_pixbuf_new_from_file(filename, NULL);
  set_cursor_busy(FALSE);
  
  if(pixbuf==NULL) { /* open failed */
    dialog = gtk_message_dialog_new(GTK_WINDOW (winMain), GTK_DIALOG_MODAL,
      GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error opening image '%s'"), filename);
    gtk_dialog_run(GTK_DIALOG(dialog));
    gtk_widget_destroy(dialog);
    g_free(filename);
    ui.cur_item = NULL;
    ui.cur_item_type = ITEM_NONE;
    return;
  }

  ui.cur_item_type = ITEM_IMAGE;

  get_pointer_coords(event, pt);
  set_current_page(pt);  

  create_image_from_pixbuf(pixbuf, pt);
}