Exemplo n.º 1
0
/***********************************************
 * option_menu_get_props -
 *  
 *   Find Option Menu Size and Spacing
 *
 *   Taken from Smooth
 ***********************************************/ 
void
ge_option_menu_get_props (GtkWidget * widget,
                          GtkRequisition * indicator_size,
                          GtkBorder * indicator_spacing)
{
  GtkRequisition default_size = { 9, 5 };
  GtkBorder default_spacing = { 7, 5, 2, 2 };
  GtkRequisition *tmp_size = NULL;
  GtkBorder *tmp_spacing = NULL;
 
  if ((widget) && GE_IS_OPTION_MENU(widget))
    gtk_widget_style_get (widget,
			  "indicator_size", &tmp_size,
			  "indicator_spacing", &tmp_spacing, NULL);
 
  if (tmp_size)
    {
      *indicator_size = *tmp_size;
      gtk_requisition_free (tmp_size);
    }
  else
    *indicator_size = default_size;
 
  if (tmp_spacing)
    {
      *indicator_spacing = *tmp_spacing;
      gtk_border_free (tmp_spacing);
    }
  else
    *indicator_spacing = default_spacing;
}
Exemplo n.º 2
0
static void
resize_window(GtkWidget *widget, guint width, guint height, gpointer data)
{
	VteTerminal *terminal;

	if ((GTK_IS_WINDOW(data)) && (width >= 2) && (height >= 2)) {
                gint owidth, oheight, char_width, char_height, column_count, row_count;
                GtkBorder *inner_border;

		terminal = VTE_TERMINAL(widget);

		gtk_window_get_size(GTK_WINDOW(data), &owidth, &oheight);

		/* Take into account border overhead. */
                char_width = vte_terminal_get_char_width (terminal);
                char_height = vte_terminal_get_char_height (terminal);
                column_count = vte_terminal_get_column_count (terminal);
                row_count = vte_terminal_get_row_count (terminal);
                gtk_widget_style_get (widget, "inner-border", &inner_border, NULL);

                owidth -= char_width * column_count;
                oheight -= char_height * row_count;
                if (inner_border != NULL) {
                        owidth -= inner_border->left + inner_border->right;
                        oheight -= inner_border->top + inner_border->bottom;
                }
		gtk_window_resize(GTK_WINDOW(data),
				  width + owidth, height + oheight);
                gtk_border_free (inner_border);
	}
}
Exemplo n.º 3
0
static gint
gtk_button_style_set_callback( GtkWidget *m_widget, GtkStyle *WXUNUSED(style), wxButton *win )
{
    if (g_isIdle)
        wxapp_install_idle_handler();

    int left_border = 0;
    int right_border = 0;
    int top_border = 0;
    int bottom_border = 0;

    /* the default button has a border around it */
    if (GTK_WIDGET_CAN_DEFAULT(m_widget))
    {
        GtkBorder *default_border = NULL;
        gtk_widget_style_get( m_widget, "default_border", &default_border, NULL );
        if (default_border)
        {
            left_border += default_border->left;
            right_border += default_border->right;
            top_border += default_border->top;
            bottom_border += default_border->bottom;
            gtk_border_free( default_border );
        }
        win->MoveWindow(
            win->m_x - left_border,
            win->m_y - top_border,
            win->m_width + left_border + right_border,
            win->m_height + top_border + bottom_border);
    }

    return FALSE;
}
Exemplo n.º 4
0
gboolean cterm_onclick(GtkWidget* w, GdkEventButton* e, gpointer data) {
    CTerm* term = (CTerm*) data;
    char* match = NULL;
    VteTerminal* vte = cterm_get_current_vte(term);
    GtkBorder* inner_border;
    glong col, row;
    int char_width, char_height;
    int tag;

    if(e->type == GDK_BUTTON_PRESS && e->button == 3) {
        cterm_run_external(term);

    } else if(e->type == GDK_2BUTTON_PRESS && e->button == 1) {
        char_width = vte_terminal_get_char_width(VTE_TERMINAL(vte));
        char_height = vte_terminal_get_char_height(VTE_TERMINAL(vte));

        gtk_widget_style_get(GTK_WIDGET(vte), "inner-border", &inner_border, NULL);
        row = (e->y - (inner_border ? inner_border->top : 0)) / char_height;
        col = (e->x - (inner_border ? inner_border->left : 0)) / char_width;
        gtk_border_free(inner_border);

        match = vte_terminal_match_check(vte, col, row, &tag);
        if(match != NULL) {
            cterm_open_url(term, match);
            free(match);
        }
    }

    return FALSE;
}
Exemplo n.º 5
0
// This function is for replce the removed vte_terminal_get_padding()
void fake_vte_terminal_get_padding(VteTerminal *vte, gint *width, gint *height)
{
#ifdef DETAIL
	g_debug("! Launch fake_vte_terminal_get_padding() with vte = %p", vte);
#endif
#ifdef SAFEMODE
	if (vte==NULL) return;
#endif
	GtkBorder *inner_border = NULL;
	gtk_widget_style_get(GTK_WIDGET(vte), "inner-border", &inner_border, NULL);
#  ifdef SAFEMODE
	if (inner_border)
	{
#  endif
#ifdef SAFEMODE
		if (width)
#endif
			*width = inner_border->left + inner_border->right;
#ifdef SAFEMODE
		if (height)
#endif
			*height = inner_border->top + inner_border->bottom;
#  ifdef SAFEMODE
	}
#  endif
	gtk_border_free (inner_border);
}
Exemplo n.º 6
0
static void
char_size_realized(GtkWidget *widget, gpointer data)
{
	VteTerminal *terminal;
	GtkWindow *window;
	GdkGeometry geometry;
	guint width, height;
        GtkBorder *inner_border;

	g_assert(GTK_IS_WINDOW(data));
	g_assert(VTE_IS_TERMINAL(widget));

	terminal = VTE_TERMINAL(widget);
	window = GTK_WINDOW(data);
	if (!GTK_WIDGET_REALIZED (window))
		return;

        gtk_widget_style_get (widget, "inner-border", &inner_border, NULL);
	width = vte_terminal_get_char_width (terminal);
	height = vte_terminal_get_char_height (terminal);
	geometry.width_inc = width;
	geometry.height_inc = height;
	geometry.base_width = inner_border ? (inner_border->left + inner_border->right) : 0;
	geometry.base_height = inner_border ? (inner_border->top + inner_border->bottom) : 0;
	geometry.min_width = geometry.base_width + width * 2;
	geometry.min_height = geometry.base_height + height * 2;
        gtk_border_free (inner_border);

	gtk_window_set_geometry_hints(window, widget, &geometry,
				      GDK_HINT_RESIZE_INC |
				      GDK_HINT_BASE_SIZE |
				      GDK_HINT_MIN_SIZE);
}
Exemplo n.º 7
0
static void get_selector_border(GtkWidget *widget, GtkBorder *selector_border)
{
	GtkBorder *tmp_border;

	gtk_widget_style_get(widget, "value-border", &tmp_border, NULL);
	if (tmp_border) {
		*selector_border = *tmp_border;
		gtk_border_free(tmp_border);
	} else {
		*selector_border = default_selector_border;
    }
}
Exemplo n.º 8
0
bool wxTextEntry::DoSetMargins(const wxPoint& margins)
{
#if GTK_CHECK_VERSION(2,10,0)
    GtkEntry* entry = GetEntry();

    if ( !entry )
        return false;

    const GtkBorder* oldBorder = gtk_entry_get_inner_border(entry);
    GtkBorder* newBorder;

    if ( oldBorder )
    {
        newBorder = gtk_border_copy(oldBorder);
    }
    else
    {
    #if GTK_CHECK_VERSION(2,14,0)
        newBorder = gtk_border_new();
    #else
        newBorder = g_slice_new0(GtkBorder);
    #endif
        // Use some reasonable defaults for initial margins
        newBorder->left = 2;
        newBorder->right = 2;

        // These numbers seem to let the text remain vertically centered
        // in common use scenarios when margins.y == -1.
        newBorder->top = 3;
        newBorder->bottom = 3;
    }

    if ( margins.x != -1 )
        newBorder->left = (gint) margins.x;

    if ( margins.y != -1 )
        newBorder->top = (gint) margins.y;

    gtk_entry_set_inner_border(entry, newBorder);

#if GTK_CHECK_VERSION(2,14,0)
    gtk_border_free(newBorder);
#else
    g_slice_free(GtkBorder, newBorder);
#endif

    return true;
#else
    wxUnusedVar(margins);
    return false;
#endif
}
Exemplo n.º 9
0
static void get_vte_padding(VteTerminal *vte, int *w, int *h) {
    GtkBorder *border = NULL;

    gtk_widget_style_get(GTK_WIDGET(vte), "inner-border", &border, NULL);
    if (border == NULL) {
        g_warning("VTE's inner-border property unavailable");
        *w = *h = 0;
    } else {
        *w = border->left + border->right;
        *h = border->top + border->bottom;
        gtk_border_free(border);
    }
}
Exemplo n.º 10
0
gint
moz_gtk_button_get_inner_border(GtkWidget* widget, GtkBorder* inner_border)
{
    static const GtkBorder default_inner_border = { 1, 1, 1, 1 };
    GtkBorder *tmp_border;

    gtk_widget_style_get (widget, "inner-border", &tmp_border, NULL);

    if (tmp_border) {
        *inner_border = *tmp_border;
        gtk_border_free(tmp_border);
    }
    else
        *inner_border = default_inner_border;

    return MOZ_GTK_SUCCESS;
}
Exemplo n.º 11
0
static void getButtonInnerBorder(GtkWidget* button, int& left, int& top, int& right, int& bottom)
{
    GtkStyle* style = gtk_widget_get_style(button);
    int outerBorder = gtk_container_get_border_width(GTK_CONTAINER(button));
    static GtkBorder defaultInnerBorder = {1, 1, 1, 1};
    GtkBorder* innerBorder;
    gtk_widget_style_get(button, "inner-border", &innerBorder, NULL);
    if (!innerBorder)
        innerBorder = &defaultInnerBorder;

    left = outerBorder + innerBorder->left + style->xthickness;
    right = outerBorder + innerBorder->right + style->xthickness;
    top = outerBorder + innerBorder->top + style->ythickness;
    bottom = outerBorder + innerBorder->bottom + style->ythickness;

    if (innerBorder != &defaultInnerBorder)
        gtk_border_free(innerBorder);
}
Exemplo n.º 12
0
static void 
get_border                                      (GtkWidget *w, 
                                                 char *name, 
                                                 GtkBorder *b)
{
    GtkBorder *tb = NULL;

    gtk_widget_style_get (w, name, &tb, NULL);

    if (tb) {
        *b = *tb;
        gtk_border_free (tb);
    } else {
        b->left = 0;
        b->right = 0;
        b->top = 0;
        b->bottom = 0;
    }
}
Exemplo n.º 13
0
static void
wxgtk_button_style_set_callback(GtkWidget* widget, GtkStyle*, wxButton* win)
{
    /* the default button has a border around it */
    wxWindow* parent = win->GetParent();
    if (parent && parent->m_wxwindow && gtk_widget_get_can_default(widget))
    {
        GtkBorder* border = NULL;
        gtk_widget_style_get(widget, "default_border", &border, NULL);
        if (border)
        {
            win->MoveWindow(
                win->m_x - border->left,
                win->m_y - border->top,
                win->m_width + border->left + border->right,
                win->m_height + border->top + border->bottom);
            gtk_border_free(border);
        }
    }
}
Exemplo n.º 14
0
void
ge_button_get_default_border (GtkWidget *widget, 
                              GtkBorder *border)
{
	GtkBorder default_border = {1, 1, 1, 1};
	GtkBorder *tmp_border = NULL;
	
	if (widget && GE_IS_BUTTON (widget))
		gtk_widget_style_get (widget, "default-border", &tmp_border, NULL);

	if (tmp_border)
	{
		*border = *tmp_border;
		gtk_border_free (tmp_border);
	}
	else
	{
		*border = default_border;
	}
}
Exemplo n.º 15
0
static int
button_pressed(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
	VteTerminal *terminal;
	char *match;
	int tag;
        GtkBorder *inner_border;
        int char_width, char_height;

	switch (event->button) {
	case 3:
		terminal = VTE_TERMINAL(widget);

                gtk_widget_style_get (widget, "inner-border", &inner_border, NULL);
                char_width = vte_terminal_get_char_width (terminal);
                char_height = vte_terminal_get_char_height (terminal);
		match = vte_terminal_match_check(terminal,
						 (event->x - (inner_border ? inner_border->left : 0)) / char_width,
						 (event->y - (inner_border ? inner_border->top : 0)) / char_height,
						 &tag);
                gtk_border_free (inner_border);
		if (match != NULL) {
			g_print("Matched `%s' (%d).\n", match, tag);
			g_free(match);
			if (GPOINTER_TO_INT(data) != 0) {
				vte_terminal_match_remove(terminal, tag);
			}
		}
		break;
	case 1:
	case 2:
	default:
		break;
	}
	return FALSE;
}
Exemplo n.º 16
0
static void
photos_base_item_check_effects_and_update_info (PhotosBaseItem *self)
{
  PhotosBaseItemPrivate *priv = self->priv;
  GApplication *app;
  GIcon *pix;
  GList *emblem_icons = NULL;
  GList *windows;
  GdkPixbuf *emblemed_pixbuf = NULL;
  GdkPixbuf *thumbnailed_pixbuf = NULL;
  GdkWindow *window;
  gint scale;

  if (priv->original_icon == NULL)
    goto out;

  emblemed_pixbuf = g_object_ref (priv->original_icon);

  if (priv->favorite)
    {
      pix = photos_base_item_create_symbolic_emblem (PHOTOS_ICON_FAVORITE);
      emblem_icons = g_list_prepend (emblem_icons, pix);
    }

  if (g_list_length (emblem_icons) > 0)
    {
      GIcon *emblemed_icon;
      GList *l;
      GtkIconInfo *icon_info;
      GtkIconTheme *theme;
      gint height;
      gint size;
      gint width;

      emblem_icons = g_list_reverse (emblem_icons);
      emblemed_icon = g_emblemed_icon_new (G_ICON (priv->original_icon), NULL);
      for (l = emblem_icons; l != NULL; l = g_list_next (l))
        {
          GEmblem *emblem;
          GIcon *emblem_icon = G_ICON (l->data);

          emblem = g_emblem_new (emblem_icon);
          g_emblemed_icon_add_emblem (G_EMBLEMED_ICON (emblemed_icon), emblem);
          g_object_unref (emblem);
        }

      theme = gtk_icon_theme_get_default ();

      width = gdk_pixbuf_get_width (priv->original_icon);
      height = gdk_pixbuf_get_height (priv->original_icon);
      size = (width > height) ? width : height;

      icon_info = gtk_icon_theme_lookup_by_gicon (theme, emblemed_icon, size, GTK_ICON_LOOKUP_FORCE_SIZE);

      if (icon_info != NULL)
        {
          GError *error = NULL;
          GdkPixbuf *tmp;

          tmp = gtk_icon_info_load_icon (icon_info, &error);
          if (error != NULL)
            {
              g_warning ("Unable to render the emblem: %s", error->message);
              g_error_free (error);
            }
          else
            {
              g_object_unref (emblemed_pixbuf);
              emblemed_pixbuf = tmp;
            }

          g_object_unref (icon_info);
        }

      g_object_unref (emblemed_icon);
    }

  g_clear_pointer (&priv->surface, (GDestroyNotify) cairo_surface_destroy);

  if (priv->thumb_path != NULL)
    {
      GtkBorder *slice;

      slice = photos_utils_get_thumbnail_frame_border ();
      thumbnailed_pixbuf = gd_embed_image_in_frame (emblemed_pixbuf,
                                                    "resource:///org/gnome/photos/thumbnail-frame.png",
                                                    slice,
                                                    slice);
      gtk_border_free (slice);
    }
  else
    thumbnailed_pixbuf = g_object_ref (emblemed_pixbuf);

  app = g_application_get_default ();
  scale = photos_application_get_scale_factor (PHOTOS_APPLICATION (app));
  windows = gtk_application_get_windows (GTK_APPLICATION (app));
  window = gtk_widget_get_window (GTK_WIDGET (windows->data));
  priv->surface = gdk_cairo_surface_create_from_pixbuf (thumbnailed_pixbuf, scale, window);

  g_signal_emit (self, signals[INFO_UPDATED], 0);

 out:
  g_clear_object (&thumbnailed_pixbuf);
  g_clear_object (&emblemed_pixbuf);
  g_list_free_full (emblem_icons, g_object_unref);
}
Exemplo n.º 17
0
void conterm_init(void)
{
	GtkWidget *console;
#ifdef G_OS_UNIX
	gchar *error = NULL;
	int pty_master;
	char *pty_name;
#endif

	conterm_load_config();
#ifdef G_OS_UNIX
	program_window = get_widget("program_window");
	console = vte_terminal_new();
	gtk_widget_show(console);
	program_terminal = VTE_TERMINAL(console);
	g_object_ref(program_terminal);
	gtk_container_add(GTK_CONTAINER(program_window), console);
	g_signal_connect_after(program_terminal, "realize", G_CALLBACK(on_vte_realize), NULL);
	terminal_parent = get_widget("terminal_parent");
	g_signal_connect(terminal_parent, "delete-event", G_CALLBACK(on_terminal_parent_delete),
		NULL);
	terminal_window = get_widget("terminal_window");
	terminal_show = GTK_CHECK_MENU_ITEM(get_widget("terminal_show"));

	if (pref_terminal_padding)
	{
		gint vte_border_x, vte_border_y;

#if GTK_CHECK_VERSION(3, 4, 0)
		GtkStyleContext *context;
		GtkBorder border;

		context = gtk_widget_get_style_context (console);
		gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL, &border);
		vte_border_x = border.left + border.right;
		vte_border_y = border.top + border.bottom;
#elif VTE_CHECK_VERSION(0, 24, 0)
		GtkBorder *border = NULL;

		gtk_widget_style_get(console, "inner-border", &border, NULL);

		if (border)
		{
			vte_border_x = border->left + border->right;
			vte_border_y = border->top + border->bottom;
			gtk_border_free(border);
		}
		else
			vte_border_x = vte_border_y = 2;
#else  /* VTE 0.24.0 */
		/* VTE manual says "deprecated since 0.26", but it's since 0.24 */
		vte_terminal_get_padding(program_terminal, &vte_border_x, &vte_border_y);
#endif  /* VTE 0.24.0 */
		pref_terminal_width += vte_border_x;
		pref_terminal_height += vte_border_y;
		pref_terminal_padding = FALSE;
	}

	if (openpty(&pty_master, &pty_slave, NULL, NULL, NULL) == 0 &&
		grantpt(pty_master) == 0 && unlockpt(pty_master) == 0 &&
		(pty_name = ttyname(pty_slave)) != NULL)
	{
#if VTE_CHECK_VERSION(0, 25, 0)
		GError *gerror = NULL;
		VtePty *pty = vte_pty_new_foreign(pty_master, &gerror);

		if (pty)
		{
			vte_terminal_set_pty_object(program_terminal, pty);
			slave_pty_name = g_strdup(pty_name);
		}
		else
		{
			error = g_strdup(gerror->message);
			g_error_free(gerror);
		}
#else  /* VTE 0.25.0 */
		vte_terminal_set_pty(program_terminal, pty_master);
		slave_pty_name = g_strdup(pty_name);
#endif  /* VTE 0.25.0 */
	}
	else
		error = g_strdup_printf("pty: %s", g_strerror(errno));

	if (error)
	{
		gtk_widget_set_sensitive(program_window, FALSE);
		gtk_widget_set_sensitive(GTK_WIDGET(terminal_show), FALSE);
		msgwin_status_add(_("Scope: %s."), error);
		g_free(error);
	}
	else
		menu_connect("terminal_menu", &terminal_menu_info, GTK_WIDGET(program_terminal));
#else  /* G_OS_UNIX */
	gtk_widget_hide(get_widget("program_window"));
#endif  /* G_OS_UNIX */

#ifdef G_OS_UNIX
	if (pref_debug_console_vte)
	{
		console = vte_terminal_new();
		gtk_widget_show(console);
		debug_console = VTE_TERMINAL(console);
		dc_output = console_output;
		dc_output_nl = console_output_nl;
		g_signal_connect_after(debug_console, "realize", G_CALLBACK(on_vte_realize), NULL);
		menu_connect("console_menu", &console_menu_info, console);
	}
	else
#endif  /* G_OS_UNIX */
	{
		static const char *const colors[NFD] = { "#00C0C0", "#C0C0C0", "#C00000",
			"#C0C0C0", "#C000C0" };
		guint i;

		console = get_widget("debug_context");
		context_apply_config(console);
		debug_context = GTK_TEXT_VIEW(console);
		dc_output = context_output;
		dc_output_nl = context_output_nl;
		context = gtk_text_view_get_buffer(debug_context);

		for (i = 0; i < NFD; i++)
		{
			fd_tags[i] = gtk_text_buffer_create_tag(context, NULL, "foreground",
				colors[i], NULL);
		}
		g_signal_connect(console, "button-press-event",
			G_CALLBACK(on_console_button_3_press),
			menu_connect("console_menu", &console_menu_info, NULL));
	}

	gtk_container_add(GTK_CONTAINER(get_widget("debug_window")), console);
	g_signal_connect(console, "key-press-event", G_CALLBACK(on_console_key_press), NULL);
}