Esempio n. 1
0
File: fun.c Progetto: frugalware/fun
int
main (int argc, char **argv)
{
    /* initialize gthread */
    g_thread_init (NULL);

    /* set the locale */
    setlocale (LC_ALL, "");
    bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
    textdomain (GETTEXT_PACKAGE);

    /* initialize gtk library */
    gtk_init (&argc, &argv);

    /* initialize dbus and exit if init fails */
    if (fun_dbus_init() == FALSE)
    {
        fun_error (_("Error"), _("Failed to initialize dbus subsystem"));
        return -1;
    }
    /* initialize fun configuration */
    fun_config_init ();
    /* initialize fun user interface */
    if (!fun_glade_init())
    {
        fun_error (_("Error"), _("Failed to initialize interface"));
        return -1;
    }
    fun_news_backend_init ();
    fun_ui_init ();

    /* run the gtk+ main loop */
    gdk_threads_enter ();
    gtk_main ();
    gdk_threads_leave ();

    fun_ui_cleanup ();

    return 0;
}
Esempio n. 2
0
static void
query_callback (GObject      *object,
                GAsyncResult *result,
                gpointer      user_data)
{
  GtkSearchEngineTracker *tracker;
  TrackerSparqlConnection *connection;
  TrackerSparqlCursor *cursor;
  GError *error = NULL;

  gdk_threads_enter ();

  tracker = GTK_SEARCH_ENGINE_TRACKER (user_data);

  tracker->priv->query_pending = FALSE;

  connection = TRACKER_SPARQL_CONNECTION (object);
	cursor = tracker_sparql_connection_query_finish (connection,
	                                                 result,
	                                                 &error);

	g_debug ("Query returned cursor:%p", cursor);

  if (error)
    {
      _gtk_search_engine_error (GTK_SEARCH_ENGINE (tracker), error->message);
      g_error_free (error);
      gdk_threads_leave ();
      return;
    }

  if (!cursor)
	  {
		  _gtk_search_engine_finished (GTK_SEARCH_ENGINE (tracker));
		  gdk_threads_leave ();
		  return;
	  }

  cursor_next (tracker, cursor);
  gdk_threads_leave ();
}
Esempio n. 3
0
int main(int argc, char **argv)
{

	if (!g_thread_supported())
		g_thread_init(NULL);
	gdk_threads_init();

	gtk_init(&argc, &argv);
	window_login = create_login();
	gtk_widget_show_all(window_login);

//window_adduser=create_adduser();

//window_list=create_list();
//gtk_widget_show_all(window_list);
	gdk_threads_enter();
	gtk_main();
	gdk_threads_leave();

	return FALSE;
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_connectSignals
  (JNIEnv *env, jobject obj)
{
  void *ptr = NULL;
  jobject *gref = NULL;

  gdk_threads_enter ();

  ptr = NSA_GET_PTR (env, obj);
  gref = NSA_GET_GLOBAL_REF (env, obj);

  /* Checkbox signals */
  g_signal_connect (G_OBJECT (ptr), "toggled",
                    G_CALLBACK (item_toggled_cb), *gref);

  /* Component signals */
  cp_gtk_component_connect_signals (G_OBJECT (ptr), gref);

  gdk_threads_leave ();
}
Esempio n. 5
0
void *thread_go(struct _Ourarg *arg)
{
	static int x = 0;
	static int y = 0;
	gint sleep_val = 1000;
	for(;;)
	{
		x+=15;
		y+=15;
		g_usleep(sleep_val);

		gdk_threads_enter();
		gtk_fixed_move (GTK_FIXED (fixed),
								label,
								x,
								y); 
		printf("move label[%d:%d]\r\n", x, y);

		gdk_threads_leave();		
	}	
}
Esempio n. 6
0
static gboolean
gdk_event_source_prepare (GSource *source,
                          gint    *timeout)
{
  GdkDisplay *display = ((GdkEventSource*) source)->display;
  gboolean retval;

  gdk_threads_enter ();

  *timeout = -1;

  if (display->event_pause_count > 0)
    retval = _gdk_event_queue_find_first (display) != NULL;
  else
    retval = (_gdk_event_queue_find_first (display) != NULL ||
              gdk_check_xpending (display));

  gdk_threads_leave ();

  return retval;
}
Esempio n. 7
0
/* This gets called by the glib main loop every once in a while. */
static gboolean
animation_timeout_handler (gpointer data)
{
	(void) data;
	
	/*g_print("** TICK **\n");*/
	
	/* enter threads as update_animation_info will use gtk/gdk. */
	gdk_threads_enter ();
	g_hash_table_foreach_remove (animated_widgets, update_animation_info, NULL);
	/* leave threads again */
	gdk_threads_leave ();
	
	if(g_hash_table_size(animated_widgets)==0)
	{
		stop_timer ();
		return FALSE;
	}
	
	return TRUE;
}
/***************************************************************************
 *   Copyright (C) 2009 by Erik Sohns   *
 *   [email protected]   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "stdafx.h"

#include "IRC_client_gui_messagehandler.h"

#include "common_file_tools.h"

#include "common_ui_tools.h"

#include "rpg_common_macros.h"

#include "rpg_net_protocol_iIRCControl.h"
#include "rpg_net_protocol_tools.h"

#include "IRC_client_gui_callbacks.h"
#include "IRC_client_gui_connection.h"
#include "IRC_client_gui_defines.h"

// update callback
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
G_MODULE_EXPORT gboolean
update_display_cb(gpointer userData_in)
{
  RPG_TRACE(ACE_TEXT("::update_display_cb"));

  // sanity check(s)
  ACE_ASSERT(userData_in);
  IRC_Client_GUI_MessageHandler* message_handler = static_cast<IRC_Client_GUI_MessageHandler*>(userData_in);
  ACE_ASSERT(message_handler);

  // *WARNING*: callbacks scheduled via g_idle_add need to be protected by
  // gdk_threads_enter/gdk_threads_leave !
  gdk_threads_enter();

  message_handler->update();

  gdk_threads_leave();

  // --> reschedule
  return TRUE;
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkButtonSetLabel
  (JNIEnv *env, jobject obj, jstring label)
{
  const char *c_label;
  GtkWidget *label_widget;
  void *ptr;

  ptr = NSA_GET_PTR (env, obj);

  c_label = (*env)->GetStringUTFChars (env, label, NULL);

  gdk_threads_enter ();

  label_widget = gtk_bin_get_child (GTK_BIN (ptr));
  gtk_label_set_text (GTK_LABEL (label_widget), c_label);

  gdk_threads_leave ();

  (*env)->ReleaseStringUTFChars (env, label, c_label);
}
Esempio n. 10
0
static gint wxlistbox_idle_callback( gpointer gdata )
{
    wxlistbox_idle_struct* data = (wxlistbox_idle_struct*) gdata;
    gdk_threads_enter();

    gtk_idle_remove( data->m_tag );

    // check that the items haven't been deleted from the listbox since we had
    // installed this callback
    wxListBox *lbox = data->m_listbox;
    if ( data->m_item < (int)lbox->GetCount() )
    {
        lbox->SetFirstItem( data->m_item );
    }

    delete data;

    gdk_threads_leave();

    return TRUE;
}
JNIEXPORT void JNICALL 
Java_gnu_java_awt_peer_gtk_GtkChoicePeer_add 
  (JNIEnv *env, jobject obj, jstring item, jint index)
{
  void *ptr;
  const char *label;
  GtkWidget *bin;

  gdk_threads_enter ();

  ptr = NSA_GET_PTR (env, obj);
  bin = choice_get_widget (GTK_WIDGET (ptr));
    
  label = (*env)->GetStringUTFChars (env, item, 0);      

  gtk_combo_box_insert_text (GTK_COMBO_BOX (bin), index, label);

  (*env)->ReleaseStringUTFChars (env, item, label);

  gdk_threads_leave ();
}
Esempio n. 12
0
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_connectSignals
(JNIEnv *env, jobject obj)
{
    void *ptr = NULL;
    jobject *gref = NULL;

    gdk_threads_enter ();

    ptr = NSA_GET_PTR (env, obj);
    gref = NSA_GET_GLOBAL_REF (env, obj);

    /* FileDialog signals */
    g_signal_connect (G_OBJECT (ptr), "response",
                      G_CALLBACK (handle_response_cb), *gref);

    /* Component signals */
    cp_gtk_component_connect_signals (G_OBJECT (ptr), gref);

    gdk_threads_leave ();
}
Esempio n. 13
0
/*
 * Class:     sun_awt_X11_GtkFileDialogPeer
 * Method:    setBounds
 * Signature: (IIIII)V
 */
JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_setBounds
(JNIEnv * env, jobject jpeer, jint x, jint y, jint width, jint height, jint op)
{
    GtkWindow* dialog;

    gdk_threads_enter();

    dialog = (GtkWindow*)jlong_to_ptr(
        (*env)->GetLongField(env, jpeer, widgetFieldID));

    if (dialog != NULL) {
        if (x >= 0 && y >= 0) {
            gtk_window_move(dialog, (gint)x, (gint)y);
        }
        if (width > 0 && height > 0) {
            gtk_window_resize(dialog, (gint)width, (gint)height);
        }
    }

    gdk_threads_leave();
}
Esempio n. 14
0
gboolean on_update_labels( FilePropertiesDialogData* data )
{
    char buf[ 64 ];
    char buf2[ 32 ];

    gdk_threads_enter();

    vfs_file_size_to_string( buf2, data->total_size );
    sprintf( buf, _("%s ( %llu bytes )"), buf2, ( guint64 ) data->total_size );
    gtk_label_set_text( data->total_size_label, buf );

    vfs_file_size_to_string( buf2, data->size_on_disk );
    sprintf( buf, _("%s ( %llu bytes )"), buf2, ( guint64 ) data->size_on_disk );
    gtk_label_set_text( data->size_on_disk_label, buf );

    char* count;
    char* count_dir;
    if ( data->total_count_dir )
    {
        count_dir = g_strdup_printf( ngettext( "%d folder",
                                               "%d folders",
                                               data->total_count_dir ),
                                     data->total_count_dir );
        count = g_strdup_printf( ngettext( "%d file, %s",
                                           "%d files, %s",
                                           data->total_count ),
                                 data->total_count, count_dir );
        g_free( count_dir );
    }
    else
        count = g_strdup_printf( ngettext( "%d files", "%d files", 
                                 data->total_count), data->total_count );
 
     gtk_label_set_text( data->count_label, count );
    g_free( count );

    gdk_threads_leave();

    return !data->done;
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkWidgetModifyFont
  (JNIEnv *env, jobject obj, jstring name, jint style, jint size)
{
  const char *font_name;
  void *ptr;
  GtkWidget *button;
  GtkWidget *label;
  PangoFontDescription *font_desc;

  gdk_threads_enter();

  ptr = NSA_GET_PTR (env, obj);

  button = GTK_WIDGET (ptr);
  label = gtk_bin_get_child (GTK_BIN(button));

  if (!label)
    return;

  font_name = (*env)->GetStringUTFChars (env, name, NULL);

  font_desc = pango_font_description_from_string (font_name);
  pango_font_description_set_size (font_desc,
                                   size * cp_gtk_dpi_conversion_factor);

  if (style & AWT_STYLE_BOLD)
    pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);

  if (style & AWT_STYLE_ITALIC)
    pango_font_description_set_style (font_desc, PANGO_STYLE_OBLIQUE);
  
  gtk_widget_modify_font (GTK_WIDGET(label), font_desc);
  
  pango_font_description_free (font_desc);
  
  (*env)->ReleaseStringUTFChars (env, name, font_name);
  
  gdk_threads_leave();
}
Esempio n. 16
0
static int
ui_gtk_query_simple(char *header, char *body,
		      const char* true_op, const char *false_op)
{
	const char *templ = 
		"<big>%s</big>\n\n%s\n";
	char *str = 0, *tmp = 0, *tmp2 = 0, *op1 = 0, *op2 = 0;
	GtkDialog *diag = 0;
	int ret = 0;
	
	gdk_threads_enter();
	ASSERT_TRUE(tmp = ship_pangoify(header), err);
	ASSERT_TRUE(tmp2 = ship_pangoify(body), err);
	ASSERT_TRUE(op1 = strdup(true_op), err);
	ASSERT_TRUE(op2 = strdup(false_op), err);
	
	ASSERT_TRUE(str = malloc(strlen(templ) + strlen(tmp) + strlen(tmp2)+10), err);
	sprintf(str, templ, tmp, tmp2);
	
	op1[0] = toupper(op1[0]);
	op2[0] = toupper(op2[0]);
	
	ASSERT_TRUE(diag = (GtkDialog*)gtk_message_dialog_new_with_markup(NULL,
									  GTK_DIALOG_MODAL,
									  GTK_MESSAGE_QUESTION,
									  GTK_BUTTONS_NONE,
									  str,
									  NULL), err);
	gtk_dialog_add_buttons(diag, op1, 1, op2, 0, NULL);
	ret = gtk_dialog_run(diag);
	gtk_widget_destroy((GtkWidget*)diag);
 err:
	gdk_threads_leave();
	freez(op2);
	freez(op1);
	freez(tmp2);
	freez(tmp);
	freez(str);
	return ret;
}
Esempio n. 17
0
QIcon GnomeIconProvider::icon(const QFileInfo& info) const
{
    if (info.fileName().endsWith(".png", Qt::CaseInsensitive))
        {
            return QIcon(info.absoluteFilePath());
        }
    if (info.fileName().endsWith(".ico", Qt::CaseInsensitive))
    return QIcon(info.absoluteFilePath());

    gdk_threads_enter();
    GnomeIconLookupResultFlags resultFlags;
    char* file = gnome_icon_lookup_sync(gtk_icon_theme_get_default(),
                                        NULL,
                                        info.absoluteFilePath().toLocal8Bit().data(),
                                        NULL,
                                        GNOME_ICON_LOOKUP_FLAGS_NONE,
                                        &resultFlags);
    GtkIconInfo* icinfo = gtk_icon_theme_lookup_icon(gtk_icon_theme_get_default(),
                                                     file,
                                                     32,
                                                     GTK_ICON_LOOKUP_NO_SVG);
    
    GdkPixbuf* buff = gtk_icon_info_load_icon(icinfo, NULL);
    gchar* pixmap;
    gsize buflen;
    
    gdk_pixbuf_save_to_buffer (buff,
                               &pixmap,
                               &buflen,
                               "png",
                               NULL, NULL);
    QPixmap qp;
    qp.loadFromData((const uchar*) pixmap, buflen, "png");
    QIcon qico(qp);
    free(pixmap);
    g_object_unref(buff);
    gdk_threads_leave();
    
    return qp;
}
Esempio n. 18
0
    void VideoRenderer::RedrawRenderArea()
    {
	    gdk_threads_enter();

#ifdef GOCAST_PLUGIN
        pthread_mutex_lock(&pluginWinMutex);
        
        if(NULL != pThePluginWindow)
        {
            FB::PluginWindowX11* pThePluginWindowX11 = 
                reinterpret_cast<FB::PluginWindowX11*>(pThePluginWindow);
            m_pRenderArea = pThePluginWindowX11->getWidget();
#endif

        gdk_draw_rgb_32_image(
	      m_pRenderArea->window,
	      m_pRenderArea->style->fg_gc[GTK_STATE_NORMAL],

#ifdef GOCAST_PLUGIN
	      (m_rendererIndex=(m_pNext?(m_pNext->RendererIndex()+1):m_rendererIndex))*m_width,
#else
          0,
#endif

	      0,
	      m_width,
	      m_height,
	      GDK_RGB_DITHER_MAX,
	      m_spFrmBuf.get(),
	      m_width*4
	    );

#ifdef GOCAST_PLUGIN
        }
        
       pthread_mutex_unlock(&pluginWinMutex);
#endif

	    gdk_threads_leave();
    }
Esempio n. 19
0
File: main.c Progetto: 3Nigma/RAle
int main(int argc, char *argv[]) {
    FILE *fMesajAplicatie = NULL;

    /* redirecționăm toate mesajele de stare ale aplicației într-un fișier fizic */
    if ((fMesajAplicatie = fopen("mesaje_sesiune_" RPS_NUME_PSALE ".txt", "w")) != NULL) {
        g_log_set_handler("",
                G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
                inregistreazaMesaj, fMesajAplicatie);
    }

    FormularPrincipal *fprin = NULL;
    gboolean aplicatiaSaActualizatRecent = FALSE;

    if (incearca_actualizare_actualizator()) {
        g_debug("Am realizat cu succes înlocuirea actualizatorului cu o versiune mai nouă.");
    }

    if (argc == 2) {
        if (g_strcmp0(argv[1], "--proaspat-actualizata") == 0) {
            aplicatiaSaActualizatRecent = TRUE;
        }
    }

#ifdef G_OS_WIN32
    /* versiunea glib de windows cere această apelare pe când în versiunea curentă de linux, această funcție nu mai există */
    g_thread_init(NULL);
#endif
    gdk_threads_init();
    gtk_init(&argc, &argv);

    fprin = fp_initializeaza_formular_principal(aplicatiaSaActualizatRecent);
    fp_arata(fprin);

    gdk_threads_enter();
    gtk_main();
    gdk_threads_leave();
    fp_curata(fprin);
    if (fMesajAplicatie != NULL) fclose(fMesajAplicatie);
    return 0;
}
Esempio n. 20
0
/*****************************************************************************
 * GtkMain: Gtk+ thread
 *****************************************************************************
 * this part of the interface is in a separate thread so that we can call
 * gtk_main() from within it without annoying the rest of the program.
 *****************************************************************************/
static void GtkMain( vlc_object_t *p_this )
{
    /* gtk_init needs to know the command line. We don't care, so we
     * give it an empty one */
    static char  *p_args[] = { "", NULL };
#if defined(MODULE_NAME_IS_gtk_main) || defined(MODULE_NAME_IS_gtk2_main)
    static char **pp_args  = p_args;
#endif
    static int    i_args   = 1;

    /* FIXME: deprecated ? */
#if defined(MODULE_NAME_IS_gtk2_main) || defined(MODULE_NAME_IS_gnome2_main)
    gdk_threads_init();
#endif

#if defined(MODULE_NAME_IS_gnome_main)
    gnome_init( p_this->p_vlc->psz_object_name, VERSION, i_args, p_args );
#elif defined(MODULE_NAME_IS_gnome2_main)
    gnome_program_init( PACKAGE, VERSION, LIBGNOMEUI_MODULE,
                        i_args, p_args,
                        GNOME_PARAM_APP_DATADIR, "",//PACKAGE_DATA_DIR,
                        NULL );
#else
    gtk_set_locale();
    gtk_init( &i_args, &pp_args );
#endif

    gdk_threads_enter();

    vlc_thread_ready( p_this );

    /* If we don't add this simple timeout, gtk_main remains stuck if
     * we try to close the window without having sent any gtk event. */
    gtk_timeout_add( INTF_IDLE_SLEEP / 1000, foo, p_this );

    /* Enter Gtk mode */
    gtk_main();

    gdk_threads_leave();
}
Esempio n. 21
0
void *count_down_thread ()
{
	gchar  buf[1024];
	int countdown = settings->update_interval;

	for (;;)
	{

		sleep(1);

		if(timmer_running == TRUE)
		{
			gdk_threads_enter ();

			if(countdown == 1)
			{
				take_photo(config->image_file);
				sleep(1);
				update_image();

				countdown = settings->update_interval;

			} else
				countdown--;

			g_ascii_dtostr(buf, sizeof (buf), countdown);
			gtk_label_set_label(GTK_LABEL(lblUpdate), buf );

			gdk_threads_leave ();


		} else {
			countdown = settings->update_interval;
		}

	}

	return NULL;

}
Esempio n. 22
0
int main (int argc, char *argv[]){

    //Block SIGALRM in the main thread
    sigset_t sigset;
    sigemptyset(&sigset);
    sigaddset(&sigset, SIGALRM);
    pthread_sigmask(SIG_BLOCK, &sigset, NULL);

    //we need to initialize all these functions so that gtk knows
    //to be thread-aware
    if (!g_thread_supported ()){ g_thread_init(NULL); }
    gdk_threads_init();
    gdk_threads_enter();

    gtk_init(&argc, &argv);

    GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
    g_signal_connect(G_OBJECT(window), "expose_event", G_CALLBACK(on_window_expose_event), NULL);
    g_signal_connect(G_OBJECT(window), "configure_event", G_CALLBACK(on_window_configure_event), NULL);

    //this must be done before we define our pixmap so that it can reference
    //the colour depth and such
    gtk_widget_show_all(window);

    //set up our pixmap so it is ready for drawing
    pixmap = gdk_pixmap_new(window->window,500,500,-1);
    //because we will be painting our pixmap manually during expose events
    //we can turn off gtk's automatic painting and double buffering routines.
    gtk_widget_set_app_paintable(window, TRUE);
    gtk_widget_set_double_buffered(window, FALSE);

    (void)g_timeout_add(33, (GSourceFunc)timer_exe, window);


    gtk_main();
    gdk_threads_leave();

    return 0;
}
JNIEXPORT void JNICALL 
Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_setCaretPosition
  (JNIEnv *env, jobject obj, jint pos)
{
  void *ptr;
  GtkWidget *text = NULL;
  GtkTextBuffer *buf;
  GtkTextIter iter;
  GtkTextMark *oldmark;
  GtkTextIter olditer;
  int oldpos;

  gdk_threads_enter ();

  ptr = NSA_GET_PTR (env, obj);

  text = gtk_bin_get_child (GTK_BIN (ptr));

  buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));

  /* Save old position. */
  oldmark = gtk_text_buffer_get_insert (buf);
  gtk_text_buffer_get_iter_at_mark (buf, &olditer, oldmark);
  oldpos = gtk_text_iter_get_offset (&olditer);

  /* Move to new position. */
  gtk_text_buffer_get_iter_at_offset (buf, &iter, pos);
  gtk_text_buffer_place_cursor (buf, &iter);

  /* Scroll to new position. Alignment is determined
     comparing the new position to the old position. */
  if (oldpos > pos)
    gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (text),
                                  &iter, 0, TRUE, 0, 0);
  else if (oldpos < pos)
    gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (text),
                                  &iter, 0, TRUE, 1, 1);

  gdk_threads_leave ();
}
JNIEXPORT void JNICALL 
Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_create
  (JNIEnv *env, jobject obj,
   jint textview_width, jint textview_height,  jint scroll)
{
  GtkWidget *text, *sw;

  gdk_threads_enter ();

  /* Create global reference and save it for future use */
  NSA_SET_GLOBAL_REF (env, obj);

  text = gtk_text_view_new ();
  gtk_widget_set_size_request (text, textview_width, textview_height);
  gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW (text), TRUE);

  gtk_widget_show (text);

  sw = gtk_scrolled_window_new (NULL, NULL);
  gtk_container_add (GTK_CONTAINER (sw), text);

  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
     /* horizontal scrollbar */
     (scroll == AWT_TEXTAREA_SCROLLBARS_BOTH
      || scroll == AWT_TEXTAREA_SCROLLBARS_HORIZONTAL_ONLY) ? 
       GTK_POLICY_ALWAYS : GTK_POLICY_NEVER,
     /* vertical scrollbar */
     (scroll == AWT_TEXTAREA_SCROLLBARS_BOTH
      || scroll == AWT_TEXTAREA_SCROLLBARS_VERTICAL_ONLY) ? 
       GTK_POLICY_ALWAYS : GTK_POLICY_NEVER);

  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text),
			       (scroll == AWT_TEXTAREA_SCROLLBARS_BOTH
				|| scroll == AWT_TEXTAREA_SCROLLBARS_HORIZONTAL_ONLY)
			       ? GTK_WRAP_NONE : GTK_WRAP_WORD);

  NSA_SET_PTR (env, obj, sw);

  gdk_threads_leave ();
}
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_nativeSetHelpMenu
  (JNIEnv *env, jobject obj, jobject menupeer)
{
  static void *helpmenu;
  void *mbar, *menu;
  GList *list;

  mbar = NSA_GET_PTR (env, obj);
  menu = NSA_GET_PTR (env, menupeer);

  gdk_threads_enter ();
  if (helpmenu != NULL)
    {
      list = gtk_container_children (GTK_CONTAINER (mbar));
      while (list != NULL && list->data != helpmenu)
        list = list->next;
      if (list != NULL && list->data == helpmenu)
        gtk_container_remove (GTK_CONTAINER (mbar), GTK_WIDGET (list->data));
    }
  helpmenu = menu;
  gdk_threads_leave ();
}
JNIEXPORT jint JNICALL
Java_gnu_java_awt_peer_gtk_GtkFramePeer_getMenuBarHeight
  (JNIEnv *env, jobject obj)
{
  void *ptr;
  GList *children;
  jint height = 0;

  ptr = NSA_GET_PTR (env, obj);

  gdk_threads_enter ();
  children = gtk_container_children (GTK_CONTAINER (GTK_BIN (ptr)->child));
  if (g_list_length (children) == 2)
    {
      GtkWidget *menubar = GTK_WIDGET (children->data);
      height = menubar->allocation.height;

    }
  gdk_threads_leave ();

  return height;
}
Esempio n. 27
0
/**
 * 确保好友一定在线.
 * @return 好友数据
 */
PalInfo *UdpData::AssertPalOnline()
{
        PalInfo *pal;

        if ( (pal = cthrd.GetPalFromList(ipv4))) {
                /* 既然好友不在线,那么他自然不在列表中 */
                if (!FLAG_ISSET(pal->flags, 1)) {
                        FLAG_SET(pal->flags, 1);
                        gdk_threads_enter();
                        pthread_mutex_lock(cthrd.GetMutex());
                        cthrd.UpdatePalToList(ipv4);
                        pthread_mutex_unlock(cthrd.GetMutex());
                        mwin.AttachItemToPaltree(ipv4);
                        gdk_threads_leave();
                }
        } else {
                SomeoneLost();
                pal = cthrd.GetPalFromList(ipv4);
        }

        return pal;
}
JNIEXPORT jstring JNICALL
Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetIDString
(JNIEnv *env, jobject obj)
{
	GdkScreen *screen;
	gchar* displayName;
	jstring string;

    screen = (GdkScreen *) NSA_GET_SCREEN_PTR(env, obj);
	
	gdk_threads_enter();
	
	displayName = gdk_screen_make_display_name(screen);
	
	gdk_threads_leave();
	
    string = (*env)->NewStringUTF(env, displayName);
    
    g_free(displayName);
    
    return string;
}
JNIEXPORT void JNICALL 
Java_gnu_java_awt_peer_gtk_GtkWindowPeer_create 
  (JNIEnv *env, jobject obj, jint type)
{
  gpointer window;
  GtkWidget *vbox, *layout;

  gdk_threads_enter ();
  window = gtk_window_new (type);

  vbox = gtk_vbox_new (0, 0);
  layout = gtk_layout_new (NULL, NULL);
  gtk_box_pack_end (GTK_BOX (vbox), layout, 1, 1, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);

  gtk_widget_show (layout);
  gtk_widget_show (vbox);

  gdk_threads_leave ();

  NSA_SET_PTR (env, obj, window);
}
Esempio n. 30
0
WG_PRIVATE wg_status
set_pixbuf(Gui_display *display, wg_uint x, wg_uint y, 
        GdkPixbuf *pixbuf)
{
    gdk_threads_enter();

    g_object_ref(pixbuf);

    if (display->pixbuf != NULL){
        g_object_unref(display->pixbuf);
    }
 
    display->pixbuf = pixbuf;
    display->x = x;
    display->y = y;

    gtk_widget_queue_draw(display->widget);

    gdk_threads_leave();

    return WG_SUCCESS;
}