static gboolean
gpw_key_press_event (GtkWidget   *box,
		     GdkEventKey *key_event)
{
	GncPopupEntry *widget = GNC_POPUP_ENTRY (box);
	GdkEvent       tmp_event;
	
	if (key_event->keyval == GDK_Escape) {
		widget->editing_canceled = TRUE;

		gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (widget));
		gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (widget));
		
		return TRUE;
	}

	gtk_widget_grab_focus (widget->entry);

	/* Hackish :/ Synthesize a key press event for the entry. */
	memcpy (&tmp_event, key_event, sizeof (GdkEventKey));

	tmp_event.key.window = widget->entry->window;
	tmp_event.key.send_event = TRUE;
	
	gtk_widget_event (widget->entry, &tmp_event);

	return GTK_WIDGET_CLASS (parent_class)->key_press_event (GTK_WIDGET (widget), 
								 key_event);
}
예제 #2
0
파일: combo-flags.c 프로젝트: GNOME/anjuta
void
cg_combo_flags_popdown(CgComboFlags *combo)
{
	CgComboFlagsPrivate *priv;
	priv = CG_COMBO_FLAGS_PRIVATE (combo);

	if (priv->window != NULL)
	{
		gtk_grab_remove (priv->window);
		gdk_device_ungrab (priv->pointer_device, GDK_CURRENT_TIME);
		gdk_device_ungrab (priv->keyboard_device, GDK_CURRENT_TIME);
		gtk_widget_hide (priv->window);

		g_object_unref (priv->column);
		g_idle_add (cg_combo_flags_popdown_idle, priv->window);

		priv->window = NULL;
		priv->treeview = NULL;
		priv->column = NULL;

		if (priv->editing_started)
		{
			priv->editing_started = FALSE;
			gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (combo));

			/* Seems like someone already calls _remove_widget when the
			 * cell renderer emits its edited signal (which we rely on if
			 * the editing was not canceled). */
			if (priv->editing_canceled)
				gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (combo));
		}
	}
}
예제 #3
0
static gboolean
grab_key_callback (GtkWidget    *widget,
                   GdkEventKey  *event,
                   void         *data)
{
  char *path;
  CellRendererKey* key = CELL_RENDERER_KEY(data);
  guint scancode = event->hardware_keycode;

  gdk_keyboard_ungrab (event->time);
  gdk_pointer_ungrab (event->time);

  path = g_strdup (g_object_get_data (G_OBJECT (key->edit_widget), CELL_RENDERER_TEXT_PATH));

  gtk_cell_editable_editing_done(GTK_CELL_EDITABLE (key->edit_widget));
  gtk_cell_editable_remove_widget(GTK_CELL_EDITABLE (key->edit_widget));
  key->edit_widget = NULL;
  key->grab_widget = NULL;

  cell_renderer_key_set_scancode(key, scancode);
  g_signal_emit_by_name (G_OBJECT(key), "accel_edited", path, scancode);

  g_free (path);
  return TRUE;
}
예제 #4
0
static void
ccm_cell_extension_on_enable_clicked (CCMCellExtension * self)
{
    ccm_cell_extension_set_active (self, !self->priv->active);

    gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (self));
}
예제 #5
0
static void
gdaui_entry_string_start_editing (GtkCellEditable *iface, GdkEvent *event)
{
	GdauiEntryString *mgstr;

	g_return_if_fail (GDAUI_IS_ENTRY_STRING (iface));
	mgstr = GDAUI_ENTRY_STRING (iface);
	GdauiEntryStringPrivate *priv = gdaui_entry_string_get_instance_private (mgstr);

	priv->editing_canceled = FALSE;
	g_object_set (G_OBJECT (priv->entry), "has-frame", FALSE, "xalign", 0., NULL);
	gtk_text_view_set_border_window_size (GTK_TEXT_VIEW (priv->view), GTK_TEXT_WINDOW_LEFT, 0);
	gtk_text_view_set_border_window_size (GTK_TEXT_VIEW (priv->view), GTK_TEXT_WINDOW_RIGHT, 0);
	gtk_text_view_set_border_window_size (GTK_TEXT_VIEW (priv->view), GTK_TEXT_WINDOW_TOP, 0);
	gtk_text_view_set_border_window_size (GTK_TEXT_VIEW (priv->view), GTK_TEXT_WINDOW_BOTTOM, 0);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->sw), GTK_SHADOW_NONE);
	gtk_container_set_border_width (GTK_CONTAINER (priv->sw), 0);

	gtk_cell_editable_start_editing (GTK_CELL_EDITABLE (priv->entry), event);
	g_signal_connect (priv->entry, "editing-done",
			  G_CALLBACK (gtk_cell_editable_entry_editing_done_cb), mgstr);
	g_signal_connect (priv->entry, "remove-widget",
			  G_CALLBACK (gtk_cell_editable_entry_remove_widget_cb), mgstr);
	
	gtk_widget_grab_focus (priv->entry);
	gtk_widget_queue_draw (GTK_WIDGET (mgstr));
}
static GtkCellEditable *
ccm_cell_renderer_extension_start_editing (GtkCellRenderer * cell,
                                           GdkEvent * event, GtkWidget * widget,
                                           const gchar * path,
                                           GdkRectangle * background_area,
                                           GdkRectangle * cell_area,
                                           GtkCellRendererState flags)
{
    g_return_val_if_fail (cell != NULL, NULL);
    g_return_val_if_fail (path != NULL, NULL);

    CCMCellRendererExtension *self = CCM_CELL_RENDERER_EXTENSION (cell);
    CCMCellExtension *cell_editable = NULL;
    gboolean editable = FALSE;

    g_object_get (G_OBJECT (self), "editable", &editable, NULL);
    if (!editable) return NULL;

    cell_editable = ccm_cell_extension_new (path, cell_area->width);
    if (cell_editable)
    {
        ccm_cell_extension_set_active (cell_editable, self->priv->enabled);

        gtk_widget_show (GTK_WIDGET (cell_editable));

        g_signal_connect_swapped (cell_editable, "editing-done",
                                  G_CALLBACK (ccm_cell_renderer_extension_on_editing_done),
                                  self);
    }

    return cell_editable ? GTK_CELL_EDITABLE (cell_editable) : NULL;
}
static gboolean
gtk_cell_editable_key_press_event (GtkEntry      *entry,
				   GdkEventKey   *key_event,
				   GncPopupEntry *widget)
{
	if (key_event->keyval == GDK_Escape) {
		widget->editing_canceled = TRUE;
		
		gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (widget));
		gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (widget));
		
		return TRUE;
	}

	return FALSE;
}
예제 #8
0
static gboolean
cg_cell_renderer_flags_focus_out_event (GtkWidget *widget,
                                        G_GNUC_UNUSED GdkEvent *event,
                                        gpointer data)
{
	cg_cell_renderer_flags_editing_done (GTK_CELL_EDITABLE (widget), data);
	return FALSE;
}
static gboolean ddb_cell_renderer_text_multiline_gtk_cell_renderer_focus_out_event (DdbCellEditableTextView* entry, GdkEvent* event, DdbCellRendererTextMultiline* _self_) {
	gboolean result = FALSE;
	g_return_val_if_fail (entry != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	g_return_val_if_fail (_self_ != NULL, FALSE);

    DdbCellRendererTextMultilinePrivate *priv;

    priv = DDB_CELL_RENDERER_TEXT_MULTILINE_GET_PRIVATE (_self_);

	entry->priv->editing_canceled = TRUE;
	if (priv->in_entry_menu)
	    return FALSE;

    gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (entry));
	gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (entry));
	result = FALSE;
	return result;
}
예제 #10
0
static void
clear_key_callback(GtkButton *widget, gpointer data)
{
  char *path;
  CellRendererKey* key = CELL_RENDERER_KEY(data);

  gdk_keyboard_ungrab(GDK_CURRENT_TIME);
  gdk_pointer_ungrab(GDK_CURRENT_TIME);

  path = g_strdup (g_object_get_data (G_OBJECT (key->edit_widget), CELL_RENDERER_TEXT_PATH));

  gtk_cell_editable_editing_done(GTK_CELL_EDITABLE (key->edit_widget));
  gtk_cell_editable_remove_widget(GTK_CELL_EDITABLE (key->edit_widget));
  key->edit_widget = NULL;
  key->grab_widget = NULL;

  cell_renderer_key_set_scancode(key, 0);
  g_signal_emit_by_name (G_OBJECT(key), "accel_cleared", path);

  g_free (path);
}
예제 #11
0
static gboolean
thunar_text_renderer_focus_out_event (GtkWidget          *entry,
                                      GdkEventFocus      *event,
                                      ThunarTextRenderer *text_renderer)
{
  /* cancel editing if we haven't popped up the menu */
  if (G_LIKELY (!text_renderer->entry_menu_active))
    thunar_text_renderer_editing_done (GTK_CELL_EDITABLE (entry), text_renderer);

  /* we need to pass the event to the entry */
  return FALSE;
}
static gboolean
gtk_cell_editable_key_press_event (GtkEntry      *entry,
                                   GdkEventKey   *key_event,
                                   GncPopupEntry *widget)
{
    const char *date_string;
    gint year = 0, month = 0, day = 0;
    struct tm when;

    if (key_event->keyval == GDK_KEY_Escape)
    {
        widget->editing_canceled = TRUE;

        gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (widget));
        gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (widget));

        return TRUE;
    }

    date_string = gtk_entry_get_text (entry);

    memset (&when, 0, sizeof (when));

    if (qof_scan_date (date_string, &day, &month, &year))
    {
        when.tm_year = year - 1900;
        when.tm_mon = month - 1 ;
        when.tm_mday = day;

        if (!gnc_handle_date_accelerator (key_event, &when, date_string))
            return FALSE;

        gtk_entry_set_text (entry, qof_print_date (gnc_mktime (&when)));
        gtk_widget_grab_focus (GTK_WIDGET (entry));
        return TRUE;
    }
    return FALSE;
}
예제 #13
0
static gboolean
marlin_text_renderer_focus_out_event (GtkWidget          *entry,
                                      GdkEventFocus      *event,
                                      MarlinTextRenderer *text_renderer)
{
    //renametest
    //printf ("%s\n", G_STRFUNC);
    /* cancel editing if we haven't popped up the menu */
    if (G_LIKELY (!text_renderer->entry_menu_active))
        marlin_text_renderer_editing_done (GTK_CELL_EDITABLE (entry), text_renderer);

    /* we need to pass the event to the entry */
    return FALSE;
}
예제 #14
0
static gboolean
key_pressed_cb (GtkWidget *widget,
                GdkEvent *event,
                gpointer user_data)
{
#if !GDK_KEY_Tab
	#define GDK_KEY_Tab GDK_Tab
#endif

	/* Tab should behave the same way as Enter (finish editing) */
	if (event->type == GDK_KEY_PRESS && event->key.keyval == GDK_KEY_Tab)
		gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (widget));

	return FALSE;
}
예제 #15
0
static gboolean
marlin_text_renderer_entry_menu_popdown_timer (gpointer user_data)
{
    MarlinTextRenderer *text_renderer = MARLIN_TEXT_RENDERER (user_data);

    GDK_THREADS_ENTER ();

    /* check if we still have the keyboard focus */
    if (G_UNLIKELY (!gtk_widget_has_focus (text_renderer->entry)))
        marlin_text_renderer_editing_done (GTK_CELL_EDITABLE (text_renderer->entry), text_renderer);

    GDK_THREADS_LEAVE ();

    return FALSE;
}
예제 #16
0
static gboolean
thunar_text_renderer_entry_menu_popdown_timer (gpointer user_data)
{
  ThunarTextRenderer *text_renderer = THUNAR_TEXT_RENDERER (user_data);

  GDK_THREADS_ENTER ();

  /* check if we still have the keyboard focus */
  if (G_UNLIKELY (!GTK_WIDGET_HAS_FOCUS (text_renderer->entry)))
    thunar_text_renderer_editing_done (GTK_CELL_EDITABLE (text_renderer->entry), text_renderer);

  GDK_THREADS_LEAVE ();

  return FALSE;
}
예제 #17
0
static GtkCellEditable*
thunar_text_renderer_start_editing (GtkCellRenderer     *renderer,
                                    GdkEvent            *event,
                                    GtkWidget           *widget,
                                    const gchar         *path,
                                    GdkRectangle        *background_area,
                                    GdkRectangle        *cell_area,
                                    GtkCellRendererState flags)
{
  ThunarTextRenderer *text_renderer = THUNAR_TEXT_RENDERER (renderer);

  /* verify that we are editable */
  if (renderer->mode != GTK_CELL_RENDERER_MODE_EDITABLE)
    return NULL;

  /* allocate a new text entry widget to be used for editing */
  text_renderer->entry = g_object_new (GTK_TYPE_ENTRY,
                                       "has-frame", FALSE,
                                       "text", text_renderer->text,
                                       "visible", TRUE,
                                       "xalign", renderer->xalign,
                                       NULL);

  /* select the whole text */
  gtk_editable_select_region (GTK_EDITABLE (text_renderer->entry), 0, -1);

  /* remember the tree path that we're editing */
  g_object_set_data_full (G_OBJECT (text_renderer->entry), I_("thunar-text-renderer-path"), g_strdup (path), g_free);

  /* connect required signals */
  g_signal_connect (G_OBJECT (text_renderer->entry), "editing-done", G_CALLBACK (thunar_text_renderer_editing_done), text_renderer);
  g_signal_connect_after (G_OBJECT (text_renderer->entry), "grab-focus", G_CALLBACK (thunar_text_renderer_grab_focus), text_renderer);
  g_signal_connect (G_OBJECT (text_renderer->entry), "focus-out-event", G_CALLBACK (thunar_text_renderer_focus_out_event), text_renderer);
  g_signal_connect (G_OBJECT (text_renderer->entry), "populate-popup", G_CALLBACK (thunar_text_renderer_populate_popup), text_renderer);

  return GTK_CELL_EDITABLE (text_renderer->entry);
}
/* GtkCellEditable method implementations
 */
static void
gtk_cell_editable_entry_activated (GtkEntry *entry, GncPopupEntry *widget)
{
	gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (widget));
	gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (widget));
}
예제 #19
0
파일: gtk_glue.c 프로젝트: TobiasBales/rgtk
GtkCellEditable *cast_GtkCellEditable(GtkWidget* widget) {
    return GTK_CELL_EDITABLE(widget);
}
예제 #20
0
static GtkCellEditable *
cell_renderer_key_start_editing (GtkCellRenderer      *cell,
				      GdkEvent             *event,
				      GtkWidget            *widget,
				      const gchar          *path,
				      GdkRectangle         *background_area,
				      GdkRectangle         *cell_area,
				      GtkCellRendererState  flags)
{
  GtkCellRendererText *celltext;
  CellRendererKey *key;
  GtkWidget *hbox;
  GtkWidget *label;
  GtkWidget *clear_button;
  GtkWidget *eventbox;
  
  celltext = GTK_CELL_RENDERER_TEXT (cell);
  key = CELL_RENDERER_KEY (cell);

  /* If the cell isn't editable we return NULL. */
  if (celltext->editable == FALSE)
    return NULL;

  g_return_val_if_fail (widget->window != NULL, NULL);
  
  if (gdk_keyboard_grab (widget->window, FALSE,
                         gdk_event_get_time (event)) != GDK_GRAB_SUCCESS)
    return NULL;

  if (gdk_pointer_grab (widget->window, TRUE,
                        GDK_BUTTON_PRESS_MASK,
                        NULL, NULL,
                        gdk_event_get_time (event)) != GDK_GRAB_SUCCESS)
    {
      gdk_keyboard_ungrab (gdk_event_get_time (event));
      return NULL;
    }
  
  key->grab_widget = widget;

  g_signal_connect(G_OBJECT (widget), "key_press_event",
                    G_CALLBACK (grab_key_callback), key);

  eventbox = g_object_new(pointless_eventbox_subclass_get_type(), NULL);
  key->edit_widget = eventbox;
  g_object_add_weak_pointer (G_OBJECT (key->edit_widget),
                             (void**) &key->edit_widget);


  hbox = gtk_hbox_new(FALSE, 2);

  label = gtk_label_new(TOOLTIP_TEXT);
  gtk_label_set_single_line_mode(GTK_LABEL(label), TRUE);
  gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);

  clear_button = gtk_button_new_from_stock(GTK_STOCK_DELETE);
  g_signal_connect(G_OBJECT(clear_button), "clicked",
                    G_CALLBACK(clear_key_callback), key);

  gtk_widget_modify_bg(eventbox, GTK_STATE_NORMAL,
                        &widget->style->bg[GTK_STATE_SELECTED]);

  gtk_widget_modify_fg(label, GTK_STATE_NORMAL,
                        &widget->style->fg[GTK_STATE_SELECTED]);

  gtk_box_pack_start_defaults(GTK_BOX(hbox), label);
  gtk_box_pack_start(GTK_BOX(hbox), clear_button, FALSE, FALSE, 0);
  gtk_container_add(GTK_CONTAINER(eventbox), hbox);
  gtk_container_set_border_width(GTK_CONTAINER(eventbox), 0);
  gtk_widget_set_size_request(GTK_WIDGET(eventbox),
    cell_area->width, cell_area->height);

  g_object_set_data_full(G_OBJECT(eventbox), CELL_RENDERER_TEXT_PATH,
                          g_strdup (path), g_free);

  gtk_widget_show_all(eventbox);

  g_signal_connect (G_OBJECT(eventbox), "unrealize",
                    G_CALLBACK (ungrab_stuff), key);

  return GTK_CELL_EDITABLE(eventbox);
}
예제 #21
0
static GtkCellEditable *
cg_cell_renderer_flags_start_editing (GtkCellRenderer *cell,
                                      G_GNUC_UNUSED GdkEvent *event,
                                      G_GNUC_UNUSED GtkWidget *widget,
                                      const gchar *path,
                                      G_GNUC_UNUSED const GdkRectangle *background_area,
                                      G_GNUC_UNUSED const GdkRectangle *cell_area,
                                      G_GNUC_UNUSED GtkCellRendererState flags)
{
	CgCellRendererFlags *cell_flags;
	CgCellRendererFlagsPrivate *priv;
	GtkCellRendererText *cell_text;
	gboolean editable;
	gchar *text;
	const gchar *prev;
	const gchar *pos;

	GtkWidget *combo;
	GtkCellRenderer *cell_combo_set;
	GtkCellRenderer *cell_combo_text;

	cell_flags = CG_CELL_RENDERER_FLAGS (cell);
	priv = CG_CELL_RENDERER_FLAGS_PRIVATE (cell_flags);

	cell_text = GTK_CELL_RENDERER_TEXT (cell);

	g_object_get (cell_text,
		      "editable", &editable,
		      "text", &text,
		      NULL);

	if (editable == FALSE) return NULL;

	if (priv->model == NULL || priv->text_column < 0 || priv->abbr_column < 0)
		return NULL;

	cell_combo_set = gtk_cell_renderer_toggle_new ();
	cell_combo_text = gtk_cell_renderer_text_new ();

	combo = cg_combo_flags_new_with_model (priv->model);

	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo),
	                            cell_combo_set, FALSE);
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo),
	                            cell_combo_text, TRUE);

	gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo),
	                               cell_combo_text, "text", priv->text_column);

	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
	                                    cell_combo_set,
                                        cg_cell_renderer_flags_set_data_func,
                                        cell_flags, NULL);

	g_object_set (G_OBJECT (cell_combo_set), "activatable", FALSE, NULL);

	/* Create hash table with current status. We could also operate
	 * directly on a string here, but a hash table is probably more
	 * efficient. */
	g_assert (priv->edit_status == NULL);
	priv->edit_status = g_hash_table_new_full (g_str_hash, g_str_equal,
	                                           (GDestroyNotify) g_free, NULL);

	pos = text;
	prev = text;

	while (prev != NULL && *prev != '\0')
	{
		while (*pos != '|' && *pos != '\0') ++ pos;

		g_hash_table_insert (priv->edit_status, g_strndup(prev, pos - prev),
		                     GINT_TO_POINTER(1));

		if(*pos != '\0') ++ pos;
		prev = pos;
	}
	g_free (text);

	g_object_set_data_full (G_OBJECT (combo), CG_CELL_RENDERER_FLAGS_PATH,
	                        g_strdup (path), g_free);

	gtk_widget_show (combo);

	g_signal_connect (G_OBJECT (combo), "editing-done",
	                  G_CALLBACK (cg_cell_renderer_flags_editing_done),
                      cell_flags);

	g_signal_connect (G_OBJECT (combo), "selected",
	                  G_CALLBACK (cg_cell_renderer_flags_selected),
	                  cell_flags);

	priv->focus_out_id =
		g_signal_connect (G_OBJECT (combo), "focus_out_event",
		                  G_CALLBACK (cg_cell_renderer_flags_focus_out_event),
		                  cell_flags);

	return GTK_CELL_EDITABLE (combo);
}
static GtkCellEditable* ddb_cell_renderer_text_multiline_real_start_editing (GtkCellRenderer* base, GdkEvent* event, GtkWidget* widget, const gchar* path, GdkRectangle* background_area, GdkRectangle* cell_area, GtkCellRendererState flags) {
	DdbCellRendererTextMultiline * self;
	GtkCellEditable* result = NULL;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_;
	const gchar* _tmp2_;
	GtkTreePath* _tmp3_;
	GtkTreePath* p;
	GtkWidget* _tmp4_;
	GtkTreeView* _tmp5_;
	GtkTreeView* tv;
	GtkTreeView* _tmp6_;
	GtkTreeModel* _tmp7_ = NULL;
	GtkListStore* _tmp8_;
	GtkListStore* store;
	GtkTreeIter iter = {0};
	GtkListStore* _tmp9_;
	GtkTreePath* _tmp10_;
	GtkTreeIter _tmp11_ = {0};
	GValue v = {0};
	GtkListStore* _tmp12_;
	GtkTreeIter _tmp13_;
	GValue _tmp14_ = {0};
	gint _tmp15_ = 0;
	gint mult;
	DdbCellEditableTextView* _tmp16_;
	DdbCellEditableTextView* _tmp17_;
	gint _tmp18_;
	DdbCellEditableTextView* _tmp19_;
	const gchar* _tmp20_;
	gchar* _tmp21_;
	GtkTextBuffer* _tmp22_;
	GtkTextBuffer* buf;
	gchar* _tmp23_ = NULL;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gboolean _tmp26_;
	DdbCellEditableTextView* _tmp31_;
	GtkTextBuffer* _tmp32_;
	DdbCellEditableTextView* _tmp33_;
	DdbCellEditableTextView* _tmp34_;
	gulong _tmp35_ = 0UL;
	DdbCellEditableTextView* _tmp36_;
	GdkRectangle _tmp37_;
	gint _tmp38_;
	GdkRectangle _tmp39_;
	gint _tmp40_;
	DdbCellEditableTextView* _tmp41_;
	DdbCellEditableTextView* _tmp42_;
	self = (DdbCellRendererTextMultiline*) base;
	g_return_val_if_fail (widget != NULL, NULL);
	g_return_val_if_fail (path != NULL, NULL);
	g_return_val_if_fail (background_area != NULL, NULL);
	g_return_val_if_fail (cell_area != NULL, NULL);
	g_object_get ((GtkCellRendererText*) self, "editable", &_tmp0_, NULL);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		result = GTK_CELL_EDITABLE (NULL);
		return result;
	}
	_tmp2_ = path;
	_tmp3_ = gtk_tree_path_new_from_string (_tmp2_);
	p = _tmp3_;
	_tmp4_ = widget;
	_tmp5_ = _g_object_ref0 (GTK_TREE_VIEW (_tmp4_));
	tv = _tmp5_;
	_tmp6_ = tv;
	_tmp7_ = gtk_tree_view_get_model (_tmp6_);
	_tmp8_ = _g_object_ref0 (GTK_LIST_STORE (_tmp7_));
	store = _tmp8_;
	_tmp9_ = store;
	_tmp10_ = p;
	gtk_tree_model_get_iter ((GtkTreeModel*) _tmp9_, &_tmp11_, _tmp10_);
	iter = _tmp11_;
	_tmp12_ = store;
	_tmp13_ = iter;
	gtk_tree_model_get_value ((GtkTreeModel*) _tmp12_, &_tmp13_, 3, &_tmp14_);
	G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
	v = _tmp14_;
	_tmp15_ = g_value_get_int (&v);
	mult = _tmp15_;
	_tmp16_ = ddb_cell_editable_text_view_new ();
	_tmp17_ = g_object_ref_sink (_tmp16_);
	_g_object_unref0 (self->priv->entry);
	self->priv->entry = _tmp17_;
	_tmp18_ = mult;
	if (_tmp18_ != 0) {
		g_object_set ((GtkCellRendererText*) self, "text", "", NULL);
	}
	_tmp19_ = self->priv->entry;
	_tmp20_ = path;
	_tmp21_ = g_strdup (_tmp20_);
	_g_free0 (_tmp19_->tree_path);
	_tmp19_->tree_path = _tmp21_;
	_tmp22_ = gtk_text_buffer_new (NULL);
	buf = _tmp22_;
	g_object_get ((GtkCellRendererText*) self, "text", &_tmp23_, NULL);
	_tmp24_ = _tmp23_;
	_tmp25_ = _tmp24_;
	_tmp26_ = _tmp25_ != NULL;
	_g_free0 (_tmp25_);
	if (_tmp26_) {
		GtkTextBuffer* _tmp27_;
		gchar* _tmp28_ = NULL;
		gchar* _tmp29_;
		gchar* _tmp30_;
		_tmp27_ = buf;
		g_object_get ((GtkCellRendererText*) self, "text", &_tmp28_, NULL);
		_tmp29_ = _tmp28_;
		_tmp30_ = _tmp29_;
		gtk_text_buffer_set_text (_tmp27_, _tmp30_, -1);
		_g_free0 (_tmp30_);
	}
	_tmp31_ = self->priv->entry;
	_tmp32_ = buf;
	gtk_text_view_set_buffer ((GtkTextView*) _tmp31_, _tmp32_);
	_tmp33_ = self->priv->entry;

    self->priv->in_entry_menu = FALSE;
    if (self->priv->entry_menu_popdown_timeout)
    {
        g_source_remove (self->priv->entry_menu_popdown_timeout);
        self->priv->entry_menu_popdown_timeout = 0;
    }

	g_signal_connect (_tmp33_, "editing-done", (GCallback) ddb_cell_renderer_text_multiline_gtk_cell_renderer_text_editing_done, self);
	_tmp34_ = self->priv->entry;
	_tmp35_ = g_signal_connect_after (_tmp34_, "focus-out-event", (GCallback) ddb_cell_renderer_text_multiline_gtk_cell_renderer_focus_out_event, self);

    self->priv->populate_popup_id =
        g_signal_connect (self->priv->entry, "populate-popup",
                G_CALLBACK (ddb_cell_renderer_text_multiline_populate_popup),
                self);

	self->priv->focus_out_id = _tmp35_;
	_tmp36_ = self->priv->entry;
	_tmp37_ = *cell_area;
	_tmp38_ = _tmp37_.width;
	_tmp39_ = *cell_area;
	_tmp40_ = _tmp39_.height;
	gtk_widget_set_size_request ((GtkWidget*) _tmp36_, _tmp38_, _tmp40_);
	_tmp41_ = self->priv->entry;
	gtk_widget_show ((GtkWidget*) _tmp41_);
	_tmp42_ = self->priv->entry;
	result = GTK_CELL_EDITABLE (_tmp42_);
	_g_object_unref0 (buf);
	G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
	_g_object_unref0 (store);
	_g_object_unref0 (tv);
	_gtk_tree_path_free0 (p);
	// evil hack! need to make an event for that
	extern int trkproperties_block_keyhandler;
	trkproperties_block_keyhandler = 1;
	return result;
}
예제 #23
0
static GtkCellEditable *
gtk_cell_renderer_accel_start_editing (GtkCellRenderer      *cell,
                                       GdkEvent             *event,
                                       GtkWidget            *widget,
                                       const gchar          *path,
                                       GdkRectangle         *background_area,
                                       GdkRectangle         *cell_area,
                                       GtkCellRendererState  flags)
{
  GtkCellRendererText *celltext;
  GtkCellRendererAccel *accel;
  GtkWidget *label;
  GtkWidget *eventbox;
  
  celltext = GTK_CELL_RENDERER_TEXT (cell);
  accel = GTK_CELL_RENDERER_ACCEL (cell);

  /* If the cell isn't editable we return NULL. */
  if (celltext->editable == FALSE)
    return NULL;

  g_return_val_if_fail (widget->window != NULL, NULL);
  
  if (gdk_keyboard_grab (widget->window, FALSE,
                         gdk_event_get_time (event)) != GDK_GRAB_SUCCESS)
    return NULL;

  if (gdk_pointer_grab (widget->window, FALSE,
                        GDK_BUTTON_PRESS_MASK,
                        NULL, NULL,
                        gdk_event_get_time (event)) != GDK_GRAB_SUCCESS)
    {
      gdk_display_keyboard_ungrab (gtk_widget_get_display (widget),
                                   gdk_event_get_time (event));
      return NULL;
    }
  
  accel->grab_widget = widget;

  g_signal_connect (G_OBJECT (widget), "key-press-event",
                    G_CALLBACK (grab_key_callback),
                    accel);

  eventbox = g_object_new (_gtk_cell_editable_event_box_get_type (), NULL);
  accel->edit_widget = eventbox;
  g_object_add_weak_pointer (G_OBJECT (accel->edit_widget),
                             (gpointer) &accel->edit_widget);
  
  label = gtk_label_new (NULL);
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  
  gtk_widget_modify_bg (eventbox, GTK_STATE_NORMAL,
                        &widget->style->bg[GTK_STATE_SELECTED]);

  gtk_widget_modify_fg (label, GTK_STATE_NORMAL,
                        &widget->style->fg[GTK_STATE_SELECTED]);
  
  /* This label is displayed in a treeview cell displaying
   * an accelerator when the cell is clicked to change the 
   * acelerator.
   */
  gtk_label_set_text (GTK_LABEL (label), _("New accelerator..."));

  gtk_container_add (GTK_CONTAINER (eventbox), label);
  
  g_object_set_data_full (G_OBJECT (accel->edit_widget), "gtk-cell-renderer-text",
                          g_strdup (path), g_free);
  
  gtk_widget_show_all (accel->edit_widget);

  g_signal_connect (G_OBJECT (accel->edit_widget), "unrealize",
                    G_CALLBACK (ungrab_stuff), accel);
  
  return GTK_CELL_EDITABLE (accel->edit_widget);
}
예제 #24
0
static gboolean
grab_key_callback (GtkWidget            *widget,
                   GdkEventKey          *event,
                   GtkCellRendererAccel *accel)
{
  GdkModifierType accel_mods = 0;
  guint accel_key;
  gchar *path;
  gboolean edited;
  gboolean cleared;
  GdkModifierType consumed_modifiers;
  GdkDisplay *display;

  display = gtk_widget_get_display (widget);

  if (event->is_modifier)
    return TRUE;

  edited = FALSE;
  cleared = FALSE;

  gdk_keymap_translate_keyboard_state (gdk_keymap_get_for_display (display),
				       event->hardware_keycode,
                                       event->state,
                                       event->group,
				       NULL, NULL, NULL, &consumed_modifiers);

  accel_key = gdk_keyval_to_lower (event->keyval);
  if (accel_key == GDK_ISO_Left_Tab) 
    accel_key = GDK_Tab;

  accel_mods = event->state & gtk_accelerator_get_default_mod_mask ();

  /* Filter consumed modifiers 
   */
  if (accel->accel_mode == GTK_CELL_RENDERER_ACCEL_MODE_GTK)
    accel_mods &= ~consumed_modifiers;
  
  /* Put shift back if it changed the case of the key, not otherwise.
   */
  if (accel_key != event->keyval)
    accel_mods |= GDK_SHIFT_MASK;
    
  if (accel_mods == 0)
    {
      switch (event->keyval)
	{
	case GDK_Escape:
	  goto out; /* cancel */
	case GDK_BackSpace:
	  /* clear the accelerator on Backspace */
	  cleared = TRUE;
	  goto out;
	default:
	  break;
	}
    }

  if (accel->accel_mode == GTK_CELL_RENDERER_ACCEL_MODE_GTK)
    {
      if (!gtk_accelerator_valid (accel_key, accel_mods))
	{
	  gtk_widget_error_bell (widget);

	  return TRUE;
	}
    }

  edited = TRUE;

 out:
  gdk_display_keyboard_ungrab (display, event->time);
  gdk_display_pointer_ungrab (display, event->time);

  path = g_strdup (g_object_get_data (G_OBJECT (accel->edit_widget), "gtk-cell-renderer-text"));

  gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (accel->edit_widget));
  gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (accel->edit_widget));
  accel->edit_widget = NULL;
  accel->grab_widget = NULL;
  
  if (edited)
    g_signal_emit (accel, signals[ACCEL_EDITED], 0, path, 
		   accel_key, accel_mods, event->hardware_keycode);
  else if (cleared)
    g_signal_emit (accel, signals[ACCEL_CLEARED], 0, path);

  g_free (path);

  return TRUE;
}
static GtkCellEditable *
egg_cell_renderer_keys_start_editing (GtkCellRenderer      *cell,
				      GdkEvent             *event,
				      GtkWidget            *widget,
				      const gchar          *path,
				      GdkRectangle         *background_area,
				      GdkRectangle         *cell_area,
				      GtkCellRendererState  flags)
{
  GtkCellRendererText *celltext;
  EggCellRendererKeys *keys;
  GtkWidget *label;
  GtkWidget *eventbox;
  GValue celltext_editable = {0};

  celltext = GTK_CELL_RENDERER_TEXT (cell);
  keys = EGG_CELL_RENDERER_KEYS (cell);

  /* If the cell isn't editable we return NULL. */
  g_value_init (&celltext_editable, G_TYPE_BOOLEAN);
  g_object_get_property (G_OBJECT (celltext), "editable", &celltext_editable);
  if (g_value_get_boolean (&celltext_editable) == FALSE)
    return NULL;
  g_return_val_if_fail (gtk_widget_get_window (widget) != NULL, NULL);

  if (gdk_keyboard_grab (gtk_widget_get_window (widget), FALSE,
                         gdk_event_get_time (event)) != GDK_GRAB_SUCCESS)
    return NULL;

  if (gdk_pointer_grab (gtk_widget_get_window (widget), FALSE,
                        GDK_BUTTON_PRESS_MASK,
                        NULL, NULL,
                        gdk_event_get_time (event)) != GDK_GRAB_SUCCESS)
    {
      gdk_keyboard_ungrab (gdk_event_get_time (event));
      return NULL;
    }

  keys->grab_widget = widget;

  g_signal_connect (G_OBJECT (widget), "key_press_event",
                    G_CALLBACK (grab_key_callback),
                    keys);

  eventbox = g_object_new (pointless_eventbox_subclass_get_type (),
                           NULL);
  keys->edit_widget = eventbox;
  g_object_add_weak_pointer (G_OBJECT (keys->edit_widget),
                             (void**) &keys->edit_widget);

  label = gtk_label_new (NULL);
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);

  gtk_widget_modify_bg (eventbox, GTK_STATE_NORMAL,
                        &gtk_widget_get_style (widget)->bg[GTK_STATE_SELECTED]);

  gtk_widget_modify_fg (label, GTK_STATE_NORMAL,
                        &gtk_widget_get_style (widget)->fg[GTK_STATE_SELECTED]);

  gtk_label_set_text (GTK_LABEL (label),
		  TOOLTIP_TEXT);

  gtk_container_add (GTK_CONTAINER (eventbox), label);

  g_object_set_data_full (G_OBJECT (keys->edit_widget), EGG_CELL_RENDERER_TEXT_PATH,
                          g_strdup (path), g_free);

  gtk_widget_show_all (keys->edit_widget);

  g_signal_connect (G_OBJECT (keys->edit_widget), "unrealize",
                    G_CALLBACK (ungrab_stuff), keys);

  keys->edit_key = keys->accel_key;

  return GTK_CELL_EDITABLE (keys->edit_widget);
}
static gboolean grab_key_callback(GtkWidget* widget, GdkEventKey* event, void* data)
{
	GdkModifierType accel_mods = 0;
	guint accel_keyval;
	EggCellRendererKeys *keys;
	char *path;
	gboolean edited;
	gboolean cleared;
	GdkModifierType consumed_modifiers;
	guint upper;
	GdkModifierType ignored_modifiers;

	keys = EGG_CELL_RENDERER_KEYS(data);

	if (is_modifier(event->hardware_keycode))
	{
		return TRUE;
	}

	edited = FALSE;
	cleared = FALSE;

	consumed_modifiers = 0;
	gdk_keymap_translate_keyboard_state(gdk_keymap_get_default(),
		event->hardware_keycode,
		event->state,
		event->group,
		NULL, NULL, NULL, &consumed_modifiers);

	upper = event->keyval;
	accel_keyval = gdk_keyval_to_lower(upper);

	if (accel_keyval == GDK_ISO_Left_Tab)
	{
		accel_keyval = GDK_Tab;
	}

	/* Put shift back if it changed the case of the key, not otherwise. */
	if (upper != accel_keyval && (consumed_modifiers & GDK_SHIFT_MASK))
	{
		consumed_modifiers &= ~(GDK_SHIFT_MASK);
	}

	egg_keymap_resolve_virtual_modifiers(gdk_keymap_get_default(),
		EGG_VIRTUAL_NUM_LOCK_MASK |
		EGG_VIRTUAL_SCROLL_LOCK_MASK |
		EGG_VIRTUAL_LOCK_MASK,
		&ignored_modifiers);

	/* http://bugzilla.gnome.org/show_bug.cgi?id=139605
	 * mouse keys should effect keybindings */
	ignored_modifiers |= GDK_BUTTON1_MASK |
		GDK_BUTTON2_MASK |
		GDK_BUTTON3_MASK |
		GDK_BUTTON4_MASK |
		GDK_BUTTON5_MASK;

	/* filter consumed/ignored modifiers */
	if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_GTK)
	{
		accel_mods = event->state & GDK_MODIFIER_MASK & ~(consumed_modifiers | ignored_modifiers);
	}
	else if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_X)
	{
		accel_mods = event->state & GDK_MODIFIER_MASK & ~(ignored_modifiers);
	}
	else
	{
		g_assert_not_reached();
	}

	if (accel_mods == 0 && accel_keyval == GDK_Escape)
	{
		goto out; /* cancel */
	}

	/* clear the accelerator on Backspace */
	if (accel_mods == 0 && accel_keyval == GDK_BackSpace)
	{
		cleared = TRUE;
		goto out;
	}

	if (keys->accel_mode == EGG_CELL_RENDERER_KEYS_MODE_GTK)
	{
		if (!gtk_accelerator_valid (accel_keyval, accel_mods))
		{
			accel_keyval = 0;
			accel_mods = 0;
		}
	}

	edited = TRUE;

	out:

	gdk_keyboard_ungrab(event->time);
	gdk_pointer_ungrab(event->time);

	path = g_strdup(g_object_get_data(G_OBJECT(keys->edit_widget), EGG_CELL_RENDERER_TEXT_PATH));

	gtk_cell_editable_editing_done(GTK_CELL_EDITABLE(keys->edit_widget));
	gtk_cell_editable_remove_widget(GTK_CELL_EDITABLE(keys->edit_widget));
	keys->edit_widget = NULL;
	keys->grab_widget = NULL;

	if (edited)
	{
		g_signal_emit_by_name(G_OBJECT(keys), "accel_edited", path, accel_keyval, accel_mods, event->hardware_keycode);
	}
	else if (cleared)
	{
		g_signal_emit_by_name(G_OBJECT(keys), "accel_cleared", path);
	}

	g_free (path);
	return TRUE;
}
예제 #27
0
start_editing_obj(GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path,
		  GdkRectangle *background_area, GdkRectangle *cell_area, GtkCellRendererState flags)
#endif
{
  return GTK_CELL_EDITABLE(create_object_cbox());
}
예제 #28
0
static GtkCellEditable*
marlin_text_renderer_start_editing (GtkCellRenderer     *cell,
                                    GdkEvent            *event,
                                    GtkWidget           *widget,
                                    const gchar         *path,
                                    const GdkRectangle  *background_area,
                                    const GdkRectangle  *cell_area,
                                    GtkCellRendererState flags)
{
    MarlinTextRenderer *text_renderer = MARLIN_TEXT_RENDERER (cell);
    gint xpad, ypad;
    gfloat xalign, yalign;
    gboolean mode, visible;

    /* verify that we are visible & editable */
    g_object_get (cell, "visible", &visible, "mode", &mode, NULL);
    if (!(visible && mode == GTK_CELL_RENDERER_MODE_EDITABLE))
        return NULL;
    //g_message ("%s %s\n", G_STRFUNC, path);

    gtk_cell_renderer_get_alignment (cell, &xalign, &yalign);

    /* allocate a new text entry widget to be used for editing */
    /*text_renderer->entry = g_object_new (GTK_TYPE_ENTRY,
                                         "has-frame", FALSE,
                                         "text", text_renderer->text,
                                         "visible", TRUE,
                                         "xalign", xalign,
                                         NULL);*/
    text_renderer->entry = eel_editable_label_new ("Test text");
    eel_editable_label_set_line_wrap (EEL_EDITABLE_LABEL (text_renderer->entry), TRUE);
    eel_editable_label_set_line_wrap_mode (EEL_EDITABLE_LABEL (text_renderer->entry), text_renderer->wrap_mode);
    eel_editable_label_set_draw_outline (EEL_EDITABLE_LABEL (text_renderer->entry), TRUE);

    /* presume we're in POSITION UNDER */
    if (text_renderer->wrap_width > 0)
        eel_editable_label_set_justify (EEL_EDITABLE_LABEL (text_renderer->entry), GTK_JUSTIFY_CENTER);

    //gtk_misc_set_alignment (GTK_MISC (text_renderer->entry), xalign, yalign);
    g_object_set (text_renderer->entry, "yalign", yalign, NULL);
    gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
    gtk_misc_set_padding (GTK_MISC (text_renderer->entry), xpad, ypad);

    if (text_renderer->zoom_level < MARLIN_ZOOM_LEVEL_NORMAL)
        g_object_set (text_renderer->entry, "small-size", TRUE, NULL);

    gtk_widget_set_size_request (text_renderer->entry, text_renderer->wrap_width, -1);
    eel_editable_label_set_text (EEL_EDITABLE_LABEL (text_renderer->entry),
                                 text_renderer->text);
    gtk_widget_show (text_renderer->entry);

    /* remember the tree path that we're editing */
    g_object_set_data_full (G_OBJECT (text_renderer->entry), "marlin-text-renderer-path", g_strdup (path), g_free);

    /* connect required signals */
    g_signal_connect (G_OBJECT (text_renderer->entry), "editing-done", G_CALLBACK (marlin_text_renderer_editing_done), text_renderer);
    g_signal_connect (G_OBJECT (text_renderer->entry), "focus-out-event", G_CALLBACK (marlin_text_renderer_focus_out_event), text_renderer);
    g_signal_connect (G_OBJECT (text_renderer->entry), "populate-popup", G_CALLBACK (marlin_text_renderer_populate_popup), text_renderer);

    return GTK_CELL_EDITABLE (text_renderer->entry);
}
예제 #29
0
static GtkCellEditable *
parasite_property_cell_renderer_start_editing(GtkCellRenderer *renderer,
        GdkEvent *event,
        GtkWidget *widget,
        const gchar *path,
        GdkRectangle *background_area,
        GdkRectangle *cell_area,
        GtkCellRendererState flags)
{
    PangoFontDescription *font_desc;
    GtkCellEditable *editable = NULL;
    GObject *object;
    const char *name;
    GValue gvalue = {0};
    GParamSpec *prop;

    g_object_get(renderer,
                 "object", &object,
                 "name", &name,
                 NULL);

    prop = g_object_class_find_property(G_OBJECT_GET_CLASS(object), name);

    if (!(prop->flags & G_PARAM_WRITABLE))
        return NULL;

    g_value_init(&gvalue, prop->value_type);
    g_object_get_property(object, name, &gvalue);

    if (G_VALUE_HOLDS_ENUM(&gvalue) || G_VALUE_HOLDS_BOOLEAN(&gvalue))
    {
        GtkWidget *combobox = gtk_combo_box_new_text();
        gtk_widget_show(combobox);
        g_object_set(G_OBJECT(combobox), "has-frame", FALSE, NULL);
        GList *renderers;

        if (G_VALUE_HOLDS_BOOLEAN(&gvalue))
        {
            gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), "FALSE");
            gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), "TRUE");

            gtk_combo_box_set_active(GTK_COMBO_BOX(combobox),
                                     g_value_get_boolean(&gvalue) ? 1 : 0);
        }
        else if (G_VALUE_HOLDS_ENUM(&gvalue))
        {
            gint value = g_value_get_enum(&gvalue);
            GEnumClass *enum_class = G_PARAM_SPEC_ENUM(prop)->enum_class;
            guint i;

            for (i = 0; i < enum_class->n_values; i++)
            {
                GEnumValue *enum_value = &enum_class->values[i];

                gtk_combo_box_append_text(GTK_COMBO_BOX(combobox),
                                          enum_value->value_name);

                if (enum_value->value == value)
                    gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), i);
            }

        }

        renderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(combobox));
        g_object_set(G_OBJECT(renderers->data), "scale", TREE_TEXT_SCALE, NULL);
        g_list_free(renderers);

        editable = GTK_CELL_EDITABLE(combobox);
    }
    else if (G_VALUE_HOLDS_STRING(&gvalue))
    {
        GtkWidget *entry = gtk_entry_new();
        gtk_widget_show(entry);
        gtk_entry_set_text(GTK_ENTRY(entry), g_value_get_string(&gvalue));

        editable = GTK_CELL_EDITABLE(entry);
    }
    else if (G_VALUE_HOLDS_INT(&gvalue)    ||
             G_VALUE_HOLDS_UINT(&gvalue)   ||
             G_VALUE_HOLDS_INT64(&gvalue)  ||
             G_VALUE_HOLDS_UINT64(&gvalue) ||
             G_VALUE_HOLDS_LONG(&gvalue)   ||
             G_VALUE_HOLDS_ULONG(&gvalue)  ||
             G_VALUE_HOLDS_DOUBLE(&gvalue))
    {
        double min, max, value;
        GtkWidget *spinbutton;
        guint digits = 0;

        if (G_VALUE_HOLDS_INT(&gvalue))
        {
            GParamSpecInt *paramspec = G_PARAM_SPEC_INT(prop);
            min = paramspec->minimum;
            max = paramspec->maximum;
            value = g_value_get_int(&gvalue);
        }
        else if (G_VALUE_HOLDS_UINT(&gvalue))
        {
            GParamSpecUInt *paramspec = G_PARAM_SPEC_UINT(prop);
            min = paramspec->minimum;
            max = paramspec->maximum;
            value = g_value_get_uint(&gvalue);
        }
        else if (G_VALUE_HOLDS_INT64(&gvalue))
        {
            GParamSpecInt64 *paramspec = G_PARAM_SPEC_INT64(prop);
            min = paramspec->minimum;
            max = paramspec->maximum;
            value = g_value_get_int64(&gvalue);
        }
        else if (G_VALUE_HOLDS_UINT64(&gvalue))
        {
            GParamSpecUInt64 *paramspec = G_PARAM_SPEC_UINT64(prop);
            min = paramspec->minimum;
            max = paramspec->maximum;
            value = g_value_get_uint64(&gvalue);
        }
        else if (G_VALUE_HOLDS_LONG(&gvalue))
        {
            GParamSpecLong *paramspec = G_PARAM_SPEC_LONG(prop);
            min = paramspec->minimum;
            max = paramspec->maximum;
            value = g_value_get_long(&gvalue);
        }
        else if (G_VALUE_HOLDS_ULONG(&gvalue))
        {
            GParamSpecULong *paramspec = G_PARAM_SPEC_ULONG(prop);
            min = paramspec->minimum;
            max = paramspec->maximum;
            value = g_value_get_ulong(&gvalue);
        }
        else if (G_VALUE_HOLDS_DOUBLE(&gvalue))
        {
            GParamSpecDouble *paramspec = G_PARAM_SPEC_DOUBLE(prop);
            min = paramspec->minimum;
            max = paramspec->maximum;
            value = g_value_get_double(&gvalue);
            digits = 2;
        }
        else
        {
            // Shouldn't really be able to happen.
            return NULL;
        }

        spinbutton = gtk_spin_button_new_with_range(min, max, 1);
        gtk_widget_show(spinbutton);
        gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbutton), value);
        gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinbutton), digits);

        editable = GTK_CELL_EDITABLE(spinbutton);
    }

    font_desc = pango_font_description_new();
    pango_font_description_set_size(font_desc, 8 * PANGO_SCALE);
    gtk_widget_modify_font(GTK_WIDGET(editable), font_desc);
    pango_font_description_free(font_desc);

    g_value_unset(&gvalue);

    g_signal_connect(G_OBJECT(editable), "editing_done",
                     G_CALLBACK(parasite_property_cell_renderer_stop_editing),
                     renderer);

    g_object_set_data_full(G_OBJECT(editable), "_prop_name", g_strdup(name),
                           g_free);
    g_object_set_data(G_OBJECT(editable), "_prop_object", object);

    return editable;
}
예제 #30
0
static void
gtk_cell_editable_entry_remove_widget_cb (G_GNUC_UNUSED GtkEntry *entry, GdauiEntryString *mgstr)
{
	gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (mgstr));
}